Fill in remaining switch cases. Only call next stage if quad->mask != 0.
authorBrian <brian.paul@tungstengraphics.com>
Tue, 10 Jul 2007 22:25:43 +0000 (16:25 -0600)
committerBrian <brian.paul@tungstengraphics.com>
Tue, 10 Jul 2007 22:25:43 +0000 (16:25 -0600)
src/mesa/pipe/softpipe/sp_quad_alpha_test.c
src/mesa/pipe/softpipe/sp_quad_depth_test.c

index e0f7225..8c28a82 100644 (file)
@@ -15,8 +15,8 @@ static void
 alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
 {
    struct softpipe_context *softpipe = qs->softpipe;
-   GLuint j;
    const GLfloat ref = softpipe->alpha_test.ref;
+   GLuint passMask = 0x0, j;
 
    switch (softpipe->alpha_test.func) {
    case PIPE_FUNC_NEVER:
@@ -24,44 +24,61 @@ alpha_test_quad(struct quad_stage *qs, struct quad_header *quad)
       break;
    case PIPE_FUNC_LESS:
       /*
-       * If quad->mask were an array [4] we could do this SIMD-style:
-       * quad->mask &= (quad->outputs.color[3] <= vec4(ref));
+       * If mask were an array [4] we could do this SIMD-style:
+       * passMask = (quad->outputs.color[3] <= vec4(ref));
        */
       for (j = 0; j < QUAD_SIZE; j++) {
-         if (quad->mask & (1 << j)) {
-            if (quad->outputs.color[3][j] >= ref) {
-               /* fail */
-               quad->mask &= (1 << j);
-            }
+         if (quad->outputs.color[3][j] < ref) {
+            passMask |= (1 << j);
          }
       }
       break;
    case PIPE_FUNC_EQUAL:
       for (j = 0; j < QUAD_SIZE; j++) {
-         if (quad->mask & (1 << j)) {
-            if (quad->outputs.color[3][j] != ref) {
-               /* fail */
-               quad->mask &= (1 << j);
-            }
+         if (quad->outputs.color[3][j] == ref) {
+            passMask |= (1 << j);
          }
       }
       break;
    case PIPE_FUNC_LEQUAL:
       for (j = 0; j < QUAD_SIZE; j++) {
-         if (quad->mask & (1 << j)) {
-            if (quad->outputs.color[3][j] > ref) {
-               /* fail */
-               quad->mask &= (1 << j);
-            }
+         if (quad->outputs.color[3][j] <= ref) {
+            passMask |= (1 << j);
          }
       }
       break;
-      /* XXX fill in remaining cases */
+   case PIPE_FUNC_GREATER:
+      for (j = 0; j < QUAD_SIZE; j++) {
+         if (quad->outputs.color[3][j] > ref) {
+            passMask |= (1 << j);
+         }
+      }
+      break;
+   case PIPE_FUNC_NOTEQUAL:
+      for (j = 0; j < QUAD_SIZE; j++) {
+         if (quad->outputs.color[3][j] != ref) {
+            passMask |= (1 << j);
+         }
+      }
+      break;
+   case PIPE_FUNC_GEQUAL:
+      for (j = 0; j < QUAD_SIZE; j++) {
+         if (quad->outputs.color[3][j] >= ref) {
+            passMask |= (1 << j);
+         }
+      }
+      break;
+   case PIPE_FUNC_ALWAYS:
+      passMask = MASK_ALL;
+      break;
    default:
       abort();
    }
 
-   qs->next->run(qs->next, quad);
+   quad->mask &= passMask;
+
+   if (quad->mask)
+      qs->next->run(qs->next, quad);
 }
 
 
index 0b5d909..268a1f9 100644 (file)
@@ -74,6 +74,7 @@ depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
 
    switch (softpipe->depth_test.func) {
    case PIPE_FUNC_NEVER:
+      /* zmask = 0 */
       break;
    case PIPE_FUNC_LESS:
       /* Note this is pretty much a single sse or cell instruction.  
@@ -96,7 +97,27 @@ depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
            zmask |= (1 << j);
       }
       break;
-      /* XXX fill in remaining cases */
+   case PIPE_FUNC_GREATER:
+      for (j = 0; j < QUAD_SIZE; j++) {
+        if (qzzzz[j] > bzzzz[j]) 
+           zmask |= (1 << j);
+      }
+      break;
+   case PIPE_FUNC_NOTEQUAL:
+      for (j = 0; j < QUAD_SIZE; j++) {
+        if (qzzzz[j] != bzzzz[j]) 
+           zmask |= (1 << j);
+      }
+      break;
+   case PIPE_FUNC_GEQUAL:
+      for (j = 0; j < QUAD_SIZE; j++) {
+        if (qzzzz[j] >= bzzzz[j]) 
+           zmask |= (1 << j);
+      }
+      break;
+   case PIPE_FUNC_ALWAYS:
+      zmask = MASK_ALL;
+      break;
    default:
       abort();
    }
@@ -117,7 +138,8 @@ depth_test_quad(struct quad_stage *qs, struct quad_header *quad)
       sps->write_quad_z(sps, quad->x0, quad->y0, bzzzz);
    }
 
-   qs->next->run(qs->next, quad);
+   if (quad->mask)
+      qs->next->run(qs->next, quad);
 }