This allows a simple passthrough fragment shader to be provided on r500.
/* Has this shader been translated yet? */
boolean translated;
+
+ /* Number of used instructions */
+ int instruction_count;
+
+ /* Pixel stack size */
+ int stack_size;
};
struct r300_fragment_shader {
struct r500_fragment_shader {
/* Parent class */
struct r3xx_fragment_shader shader;
+
+ /* Machine instructions */
+ struct {
+ uint32_t inst0;
+ uint32_t inst1;
+ uint32_t inst2;
+ uint32_t inst3;
+ uint32_t inst4;
+ uint32_t inst5;
+ } instructions[256]; /*< XXX magic number */
};
struct r300_texture {
#ifdef R300_CS_H
+#define RADEON_ONE_REG_WR (1 << 15)
+
+#define CS_OUT_ONE_REG(register, count) \
+ OUT_CS_REG_SEQ(register, (count | RADEON_ONE_REG_WR))
+
#define R300_PACIFY do { \
OUT_CS_REG(R300_SC_SCREENDOOR, 0x0); \
OUT_CS_REG(RADEON_WAIT_UNTIL, (1 << 15) | (1 << 17) | \
END_CS;
}
+void r300_emit_fragment_shader(struct r300_context* r300,
+ struct r300_fragment_shader* shader)
+{
+ CS_LOCALS(r300);
+}
+
+void r500_emit_fragment_shader(struct r300_context* r300,
+ struct r500_fragment_shader* shader)
+{
+ CS_LOCALS(r300);
+ int i = 0;
+
+ BEGIN_CS(8 + (shader->shader.instruction_count * 6) + 6);
+ OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO);
+ OUT_CS_REG(R500_US_PIXSIZE, shader->shader.stack_size);
+ OUT_CS_REG(R500_US_CODE_ADDR, R500_US_CODE_START_ADDR(0) |
+ R500_US_CODE_END_ADDR(shader->shader.instruction_count));
+
+ OUT_CS_REG(R500_GA_US_VECTOR_INDEX, R500_GA_US_VECTOR_INDEX_TYPE_INSTR);
+ OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA,
+ shader->shader.instruction_count * 6);
+ for (i = 0; i < shader->shader.instruction_count; i++) {
+ CS_OUT(shader->instructions[i].inst0);
+ CS_OUT(shader->instructions[i].inst1);
+ CS_OUT(shader->instructions[i].inst2);
+ CS_OUT(shader->instructions[i].inst3);
+ CS_OUT(shader->instructions[i].inst4);
+ CS_OUT(shader->instructions[i].inst5);
+ }
+ R300_PACIFY;
+ END_CS;
+}
+
/* XXX add pitch, stride, z/stencil buf */
void r300_emit_fb_state(struct r300_context* r300,
struct pipe_framebuffer_state* fb)
# define R500_INST_RGB_OMASK_R (1 << 15)
# define R500_INST_RGB_OMASK_G (1 << 16)
# define R500_INST_RGB_OMASK_B (1 << 17)
+# define R500_INST_RGB_OMASK_RGB (7 << 15)
# define R500_INST_ALPHA_OMASK (1 << 18)
# define R500_INST_RGB_CLAMP (1 << 19)
# define R500_INST_ALPHA_CLAMP (1 << 20)
}
}
+ if (!fs->translated) {
+ debug_printf("r300: Couldn't assemble fragment shader...\n");
+ /* XXX exit here */
+ }
+
r300->fs = fs;
r300->dirty_state |= R300_NEW_FRAGMENT_SHADER;
#include "r300_state_shader.h"
+void r300_make_passthrough_fragment_shader(struct r300_fragment_shader* fs)
+{
+}
+
+void r500_make_passthrough_fragment_shader(struct r500_fragment_shader* fs)
+{
+ fs->shader.instruction_count = 1;
+ fs->shader.stack_size = 0;
+
+ fs->instructions[0].inst0 = R500_INST_TYPE_OUT |
+ R500_INST_TEX_SEM_WAIT |
+ R500_INST_LAST |
+ R500_INST_RGB_OMASK_RGB | R500_INST_ALPHA_OMASK |
+ R500_INST_RGB_CLAMP | R500_INST_ALPHA_CLAMP;
+ fs->instructions[0].inst1 =
+ R500_RGB_ADDR0(0) | R500_RGB_ADDR1(0) | R500_RGB_ADDR1_CONST |
+ R500_RGB_ADDR2(0) | R500_RGB_ADDR2_CONST;
+ fs->instructions[0].inst2 =
+ R500_ALPHA_ADDR0(0) | R500_ALPHA_ADDR1(0) | R500_ALPHA_ADDR1_CONST |
+ R500_ALPHA_ADDR2(0) | R500_ALPHA_ADDR2_CONST;
+ fs->instructions[0].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[0].inst4 =
+ R500_ALPHA_OP_CMP | R500_ALPHA_SWIZ_A_A | R500_ALPHA_SWIZ_B_A;
+ fs->instructions[0].inst5 =
+ R500_ALU_RGBA_OP_CMP | R500_ALU_RGBA_R_SWIZ_0 |
+ R500_ALU_RGBA_G_SWIZ_0 | R500_ALU_RGBA_B_SWIZ_0 |
+ R500_ALU_RGBA_A_SWIZ_0;
+
+ fs->shader.translated = true;
+}
+
void r300_translate_shader(struct r300_context* r300,
struct r300_fragment_shader* fs)
{
+ r300_make_passthrough_fragment_shader(fs);
}
void r500_translate_shader(struct r300_context* r300,
struct r500_fragment_shader* fs)
{
+ r500_make_passthrough_fragment_shader(fs);
}
#define R300_STATE_SHADER_H
#include "r300_context.h"
+#include "r300_reg.h"
#include "r300_screen.h"
void r300_translate_shader(struct r300_context* r300,