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,
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 |
#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 {