Cell: minor optimization for flat shading
authorBrian <brian.paul@tungstengraphics.com>
Tue, 29 Jan 2008 00:32:23 +0000 (17:32 -0700)
committerBen Skeggs <skeggsb@gmail.com>
Fri, 15 Feb 2008 02:50:24 +0000 (13:50 +1100)
src/mesa/pipe/cell/spu/spu_tri.c

index aad28f1036f87b14e947348a19b8c0e23712f31c..19a231d9c4de9d4bc9ec79cf7ea321720e8d1d3d 100644 (file)
@@ -200,16 +200,35 @@ static INLINE void
 eval_coeff( struct setup_stage *setup, uint slot,
             float x, float y, float result[4][4])
 {
-   uint i;
-   const float *dadx = setup->coef[slot].dadx;
-   const float *dady = setup->coef[slot].dady;
+   switch (spu.vertex_info.interp_mode[slot]) {
+   case INTERP_CONSTANT:
+      {
+         uint i;
+         for (i = 0; i < 4; i++) {
+            result[QUAD_TOP_LEFT][i] =
+            result[QUAD_TOP_RIGHT][i] =
+            result[QUAD_BOTTOM_LEFT][i] =
+            result[QUAD_BOTTOM_RIGHT][i] = setup->coef[slot].a0[i];
+         }
+      }
+      break;
 
-   /* loop over XYZW comps */
-   for (i = 0; i < 4; i++) {
-      result[QUAD_TOP_LEFT][i] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i];
-      result[QUAD_TOP_RIGHT][i] = result[0][i] + dadx[i];
-      result[QUAD_BOTTOM_LEFT][i] = result[0][i] + dady[i];
-      result[QUAD_BOTTOM_RIGHT][i] = result[0][i] + dadx[i] + dady[i];
+   case INTERP_LINEAR:
+      /* fall-through, for now */
+   default:
+      {
+         uint i;
+         const float *dadx = setup->coef[slot].dadx;
+         const float *dady = setup->coef[slot].dady;
+
+         /* loop over XYZW comps */
+         for (i = 0; i < 4; i++) {
+            result[QUAD_TOP_LEFT][i] = setup->coef[slot].a0[i] + x * dadx[i] + y * dady[i];
+            result[QUAD_TOP_RIGHT][i] = result[0][i] + dadx[i];
+            result[QUAD_BOTTOM_LEFT][i] = result[0][i] + dady[i];
+            result[QUAD_BOTTOM_RIGHT][i] = result[0][i] + dadx[i] + dady[i];
+         }
+      }
    }
 }