diff options
author | Corbin Simpson <MostAwesomeDude@gmail.com> | 2009-02-12 16:53:06 -0800 |
---|---|---|
committer | Corbin Simpson <MostAwesomeDude@gmail.com> | 2009-02-12 18:09:14 -0800 |
commit | affe0311fa60489e56b854c09f713fae024a0b00 (patch) | |
tree | 2c0d4f6f9e43a8d3e8b02cf7961498d15d7cdedf | |
parent | 08e324fff3b295bfd5b176ed1242ad838c6d5f25 (diff) |
r300-gallium: Add r500 passthrough shader assembly.
This allows a simple passthrough fragment shader to be provided on r500.
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 16 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_cs_inlines.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 33 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_reg.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_shader.c | 37 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_shader.h | 1 |
7 files changed, 98 insertions, 0 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 376c57639d8..a29201eabaf 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -107,6 +107,12 @@ struct r3xx_fragment_shader { /* 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 { @@ -117,6 +123,16 @@ 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 { diff --git a/src/gallium/drivers/r300/r300_cs_inlines.h b/src/gallium/drivers/r300/r300_cs_inlines.h index 71e66236991..b7c04fde1a8 100644 --- a/src/gallium/drivers/r300/r300_cs_inlines.h +++ b/src/gallium/drivers/r300/r300_cs_inlines.h @@ -26,6 +26,11 @@ #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) | \ diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 585a9e729d7..4d1b10de230 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -79,6 +79,39 @@ void r300_emit_dsa_state(struct r300_context* r300, 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) diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h index dbd0cc28e23..9e86423efbd 100644 --- a/src/gallium/drivers/r300/r300_reg.h +++ b/src/gallium/drivers/r300/r300_reg.h @@ -2973,6 +2973,7 @@ enum { # 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) diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 9392d723427..5fe2b8ea3ef 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -432,6 +432,11 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader) } } + 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; diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index e87172128fa..710b7ee0a60 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -22,12 +22,49 @@ #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); } diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index a20bd4276c6..030ecaa56ee 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -24,6 +24,7 @@ #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, |