summaryrefslogtreecommitdiff
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/r300/r300_state_shader.c27
-rw-r--r--src/gallium/drivers/r300/r300_state_shader.h23
2 files changed, 43 insertions, 7 deletions
diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c
index 7165efdc19..65d5c5a596 100644
--- a/src/gallium/drivers/r300/r300_state_shader.c
+++ b/src/gallium/drivers/r300/r300_state_shader.c
@@ -68,6 +68,19 @@ static void r300_fs_declare(struct r300_fs_asm* assembler,
assembler->temp_offset = assembler->color_count + assembler->tex_count;
}
+/* XXX cover extended cases */
+static INLINE uint32_t r500_rgb_swiz(struct tgsi_src_register* reg)
+{
+ uint32_t temp = reg->SwizzleX | (reg->SwizzleY << 3) |
+ (reg->SwizzleZ << 6);
+ return temp;
+}
+
+static INLINE uint32_t r500_alpha_swiz(struct tgsi_src_register* reg)
+{
+ return reg->SwizzleZ;
+}
+
static INLINE void r500_emit_mov(struct r500_fragment_shader* fs,
struct r300_fs_asm* assembler,
struct tgsi_full_src_register* src,
@@ -84,13 +97,13 @@ static INLINE void r500_emit_mov(struct r500_fragment_shader* fs,
fs->instructions[i].inst2 =
R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST;
- fs->instructions[i].inst3 =
- R500_ALU_RGB_SEL_A_SRC0 | R500_ALU_RGB_R_SWIZ_A_R |
- R500_ALU_RGB_G_SWIZ_A_G | R500_ALU_RGB_B_SWIZ_A_B |
- R500_ALU_RGB_SEL_B_SRC0 | R500_ALU_RGB_R_SWIZ_B_R |
- R500_ALU_RGB_B_SWIZ_B_G | R500_ALU_RGB_G_SWIZ_B_B,
- fs->instructions[i].inst4 =
- R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A;
+ fs->instructions[i].inst3 = R500_ALU_RGB_SEL_A_SRC0 |
+ R500_SWIZ_RGB_A(r500_rgb_swiz(&src->SrcRegister)) |
+ R500_ALU_RGB_SEL_B_SRC0 |
+ R500_SWIZ_RGB_B(r500_rgb_swiz(&src->SrcRegister));
+ fs->instructions[i].inst4 = R500_ALPHA_OP_CMP |
+ R500_SWIZ_ALPHA_A(r500_alpha_swiz(&src->SrcRegister)) |
+ R500_SWIZ_ALPHA_B(r500_alpha_swiz(&src->SrcRegister));
fs->instructions[i].inst5 =
R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h
index 333f0f5d05..410926a26a 100644
--- a/src/gallium/drivers/r300/r300_state_shader.h
+++ b/src/gallium/drivers/r300/r300_state_shader.h
@@ -29,6 +29,29 @@
#include "r300_reg.h"
#include "r300_screen.h"
+/* Swizzle tools */
+#define R500_SWIZZLE_ZERO 4
+#define R500_SWIZZLE_HALF 5
+#define R500_SWIZZLE_ONE 6
+#define R500_SWIZ_RGB_ZERO ((4 << 0) | (4 << 3) | (4 << 6))
+#define R500_SWIZ_RGB_ONE ((6 << 0) | (6 << 3) | (6 << 6))
+#define R500_SWIZ_RGB_RGB ((0 << 0) | (1 << 3) | (2 << 6))
+#define R500_SWIZ_MOD_NEG 1
+#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)
+/* Swizzles for inst3 */
+#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)
+/* Swizzle for inst5 */
+#define R500_SWIZ_RGBA_C(x) (x << 14)
+#define R500_SWIZ_ALPHA_C(x) (x << 27)
+
/* Temporary struct used to hold assembly state while putting together
* fragment programs. */
struct r300_fs_asm {