nvc0: fix blend factor mapping
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 16 Feb 2011 14:41:32 +0000 (15:41 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 16 Feb 2011 14:45:31 +0000 (15:45 +0100)
src/gallium/drivers/nvc0/nvc0_state.c

index ae5f335f9f247d7ea132eeb8f2f6b892a9a9770d..666e3802979631aa9f6b0c769dd19c8ff1a66316 100644 (file)
@@ -51,40 +51,35 @@ nvc0_colormask(unsigned mask)
     return ret;
 }
 
+#define NVC0_BLEND_FACTOR_CASE(a, b) \
+   case PIPE_BLENDFACTOR_##a: return NV50_3D_BLEND_FACTOR_##b
+
 static INLINE uint32_t
 nvc0_blend_fac(unsigned factor)
 {
-    static const uint16_t bf[] = {
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x00 */
-        NV50_3D_BLEND_FACTOR_ONE,
-        NV50_3D_BLEND_FACTOR_SRC_COLOR,
-        NV50_3D_BLEND_FACTOR_SRC_ALPHA,
-        NV50_3D_BLEND_FACTOR_DST_ALPHA,
-        NV50_3D_BLEND_FACTOR_DST_COLOR,
-        NV50_3D_BLEND_FACTOR_SRC_ALPHA_SATURATE,
-        NV50_3D_BLEND_FACTOR_CONSTANT_COLOR,
-        NV50_3D_BLEND_FACTOR_CONSTANT_ALPHA,
-        NV50_3D_BLEND_FACTOR_SRC1_COLOR,
-        NV50_3D_BLEND_FACTOR_SRC1_ALPHA,
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x0b */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x0c */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x0d */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x0e */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x0f */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x10 */
-        NV50_3D_BLEND_FACTOR_ZERO, /* 0x11 */
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_DST_COLOR,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,
-        NV50_3D_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
-    };
-
-    assert(factor < (sizeof(bf) / sizeof(bf[0])));
-    return bf[factor];
+   switch (factor) {
+   NVC0_BLEND_FACTOR_CASE(ONE, ONE);
+   NVC0_BLEND_FACTOR_CASE(SRC_COLOR, SRC_COLOR);
+   NVC0_BLEND_FACTOR_CASE(SRC_ALPHA, SRC_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(DST_ALPHA, DST_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(DST_COLOR, DST_COLOR);
+   NVC0_BLEND_FACTOR_CASE(SRC_ALPHA_SATURATE, SRC_ALPHA_SATURATE);
+   NVC0_BLEND_FACTOR_CASE(CONST_COLOR, CONSTANT_COLOR);
+   NVC0_BLEND_FACTOR_CASE(CONST_ALPHA, CONSTANT_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(SRC1_COLOR, SRC1_COLOR);
+   NVC0_BLEND_FACTOR_CASE(SRC1_ALPHA, SRC1_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(ZERO, ZERO);
+   NVC0_BLEND_FACTOR_CASE(INV_SRC_COLOR, ONE_MINUS_SRC_COLOR);
+   NVC0_BLEND_FACTOR_CASE(INV_SRC_ALPHA, ONE_MINUS_SRC_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(INV_DST_ALPHA, ONE_MINUS_DST_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(INV_DST_COLOR, ONE_MINUS_DST_COLOR);
+   NVC0_BLEND_FACTOR_CASE(INV_CONST_COLOR, ONE_MINUS_CONSTANT_COLOR);
+   NVC0_BLEND_FACTOR_CASE(INV_CONST_ALPHA, ONE_MINUS_CONSTANT_ALPHA);
+   NVC0_BLEND_FACTOR_CASE(INV_SRC1_COLOR, ONE_MINUS_SRC1_COLOR);
+   NVC0_BLEND_FACTOR_CASE(INV_SRC1_ALPHA, ONE_MINUS_SRC1_ALPHA);
+   default:
+      return NV50_3D_BLEND_FACTOR_ZERO;
+   }
 }
 
 static void *