r300-gallium: r500-fs: More texture fixes.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 11 Mar 2009 22:05:52 +0000 (15:05 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 11 Mar 2009 22:23:09 +0000 (15:23 -0700)
src/gallium/drivers/r300/r300_debug.c
src/gallium/drivers/r300/r300_state_shader.c
src/gallium/drivers/r300/r300_state_shader.h

index 4c6d2a24712951501166d1c1bd4399a6515098ae..10b0cf73532a003ef8e092df6de13c233f22e056 100644 (file)
@@ -200,15 +200,15 @@ void r500_fs_dump(struct r500_fragment_shader* fs)
                 debug_printf("    2: TEX_ADDR  0x%08x: "
                         "src: %d%s %s/%s/%s/%s dst: %d%s %s/%s/%s/%s\n",
                         inst, inst & 0x7f, inst & (1 << 7) ? "(rel)" : "",
-                        r500_fs_swiz[(inst >> 8) & 0x7],
-                        r500_fs_swiz[(inst >> 10) & 0x7],
-                        r500_fs_swiz[(inst >> 12) & 0x7],
-                        r500_fs_swiz[(inst >> 14) & 0x7],
+                        r500_fs_swiz[(inst >> 8) & 0x3],
+                        r500_fs_swiz[(inst >> 10) & 0x3],
+                        r500_fs_swiz[(inst >> 12) & 0x3],
+                        r500_fs_swiz[(inst >> 14) & 0x3],
                         (inst >> 16) & 0x7f, inst & (1 << 23) ? "(rel)" : "",
-                        r500_fs_swiz[(inst >> 24) & 0x7],
-                        r500_fs_swiz[(inst >> 26) & 0x7],
-                        r500_fs_swiz[(inst >> 28) & 0x7],
-                        r500_fs_swiz[(inst >> 30) & 0x7]);
+                        r500_fs_swiz[(inst >> 24) & 0x3],
+                        r500_fs_swiz[(inst >> 26) & 0x3],
+                        r500_fs_swiz[(inst >> 28) & 0x3],
+                        r500_fs_swiz[(inst >> 30) & 0x3]);
                 
                 inst = fs->instructions[i].inst3;
                 debug_printf("    3: TEX_DXDY  0x%08x\n", inst);
index 7629bfb1f433ced04bd46e215dce3c6ee8b6adc7..db84dbdc4ead3f8f4447704f39a6f25d773188d8 100644 (file)
@@ -133,6 +133,14 @@ static uint32_t r500_rgba_swiz(struct tgsi_full_src_register* reg)
     }
 }
 
+static uint32_t r500_strq_swiz(struct tgsi_full_src_register* reg)
+{
+    return reg->SrcRegister.SwizzleX |
+        (reg->SrcRegister.SwizzleY << 2) |
+        (reg->SrcRegister.SwizzleZ << 4) |
+        (reg->SrcRegister.SwizzleW << 6);
+}
+
 static INLINE uint32_t r500_rgb_swiz(struct tgsi_full_src_register* reg)
 {
     /* Only the first 9 bits... */
@@ -184,16 +192,19 @@ static INLINE void r500_emit_tex(struct r500_fragment_shader* fs,
     int i = fs->instruction_count;
 
     fs->instructions[i].inst0 = R500_INST_TYPE_TEX |
+        R500_TEX_WMASK(dst->DstRegister.WriteMask) |
         R500_INST_TEX_SEM_WAIT;
     fs->instructions[i].inst1 = R500_TEX_ID(0) |
         R500_TEX_SEM_ACQUIRE | R500_TEX_IGNORE_UNCOVERED |
         R500_TEX_INST_PROJ;
     fs->instructions[i].inst2 =
         R500_TEX_SRC_ADDR(r300_fs_src(assembler, &src->SrcRegister)) |
-        R500_SWIZ_TEX_STRQ(r500_rgba_swiz(src)) |
+        R500_SWIZ_TEX_STRQ(r500_strq_swiz(src)) |
         R500_TEX_DST_ADDR(r300_fs_dst(assembler, &dst->DstRegister)) |
         R500_TEX_DST_R_SWIZ_R | R500_TEX_DST_G_SWIZ_G |
         R500_TEX_DST_B_SWIZ_B | R500_TEX_DST_A_SWIZ_A;
+
+    fs->instruction_count++;
 }
 
 static void r500_fs_instruction(struct r500_fragment_shader* fs,
index a74dce47641358c3a2cb1eddbc50b1ee9a55cfd0..5dd3584459175c49338dd0f4b0948cda064768b8 100644 (file)
 #define R500_SWIZ_MOD_ABS 2
 #define R500_SWIZ_MOD_NEG_ABS 3
 /* Swizzles for inst2 */
-#define R500_SWIZ_TEX_STRQ(x) (x << 8)
-#define R500_SWIZ_TEX_RGBA(x) (x << 24)
+#define R500_SWIZ_TEX_STRQ(x) ((x) << 8)
+#define R500_SWIZ_TEX_RGBA(x) ((x) << 24)
 /* Swizzles for inst3 */
-#define R500_SWIZ_RGB_A(x) (x << 2)
-#define R500_SWIZ_RGB_B(x) (x << 15)
+#define R500_SWIZ_RGB_A(x) ((x) << 2)
+#define R500_SWIZ_RGB_B(x) ((x) << 15)
 /* Swizzles for inst4 */
-#define R500_SWIZ_ALPHA_A(x) (x << 14)
-#define R500_SWIZ_ALPHA_B(x) (x << 21)
+#define R500_SWIZ_ALPHA_A(x) ((x) << 14)
+#define R500_SWIZ_ALPHA_B(x) ((x) << 21)
 /* Swizzle for inst5 */
-#define R500_SWIZ_RGBA_C(x) (x << 14)
-#define R500_SWIZ_ALPHA_C(x) (x << 27)
+#define R500_SWIZ_RGBA_C(x) ((x) << 14)
+#define R500_SWIZ_ALPHA_C(x) ((x) << 27)
+/* Writemasks */
+#define R500_TEX_WMASK(x) ((x) << 11)
 
 /* Temporary struct used to hold assembly state while putting together
  * fragment programs. */