summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCorbin Simpson <[email protected]>2009-02-12 20:01:09 -0800
committerCorbin Simpson <[email protected]>2009-02-12 20:01:09 -0800
commit637b24a5904ab78cbd3fc61ea5fe39c52be711ce (patch)
tree463da95efc3b1a40cd17332c9915528cabd9375d /src
parentf2a36d334c6fbe3787d44c6203f54ccb184fb923 (diff)
r300-gallium: Add r300 passthrough shader.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/r300_context.h29
-rw-r--r--src/gallium/drivers/r300/r300_cs_inlines.h2
-rw-r--r--src/gallium/drivers/r300/r300_emit.c63
-rw-r--r--src/gallium/drivers/r300/r300_state_shader.c12
4 files changed, 87 insertions, 19 deletions
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index a29201eabaf..54879f88f54 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -108,9 +108,6 @@ 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;
};
@@ -118,12 +115,38 @@ struct r3xx_fragment_shader {
struct r300_fragment_shader {
/* Parent class */
struct r3xx_fragment_shader shader;
+
+ /* Number of ALU instructions */
+ int alu_instruction_count;
+
+ /* Number of texture instructions */
+ int tex_instruction_count;
+
+ /* Number of texture indirections */
+ int indirections;
+
+ /* Indirection node offsets */
+ int offset0;
+ int offset1;
+ int offset2;
+ int offset3;
+
+ /* Machine instructions */
+ struct {
+ uint32_t alu_rgb_inst;
+ uint32_t alu_rgb_addr;
+ uint32_t alu_alpha_inst;
+ uint32_t alu_alpha_addr;
+ } instructions[64]; /* XXX magic num */
};
struct r500_fragment_shader {
/* Parent class */
struct r3xx_fragment_shader shader;
+ /* Number of used instructions */
+ int instruction_count;
+
/* Machine instructions */
struct {
uint32_t inst0;
diff --git a/src/gallium/drivers/r300/r300_cs_inlines.h b/src/gallium/drivers/r300/r300_cs_inlines.h
index 2ca907dd901..a3ea4f900b5 100644
--- a/src/gallium/drivers/r300/r300_cs_inlines.h
+++ b/src/gallium/drivers/r300/r300_cs_inlines.h
@@ -28,7 +28,7 @@
#define RADEON_ONE_REG_WR (1 << 15)
-#define CS_OUT_ONE_REG(register, count) \
+#define OUT_CS_ONE_REG(register, count) \
OUT_CS_REG_SEQ(register, (count | RADEON_ONE_REG_WR))
#define R300_PACIFY do { \
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 4d1b10de230..634a72991ce 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -80,33 +80,58 @@ void r300_emit_dsa_state(struct r300_context* r300,
}
void r300_emit_fragment_shader(struct r300_context* r300,
- struct r300_fragment_shader* shader)
+ struct r300_fragment_shader* fs)
{
CS_LOCALS(r300);
+ int i;
+ BEGIN_CS(0);
+
+ OUT_CS_REG(R300_US_CONFIG, MAX(fs->indirections - 1, 0));
+ OUT_CS_REG(R300_US_PIXSIZE, fs->shader.stack_size);
+ /* XXX figure out exactly how big the sizes are on this reg */
+ OUT_CS_REG(R300_US_CODE_OFFSET, 0x0);
+ /* XXX figure these ones out a bit better kthnx */
+ OUT_CS_REG(R300_US_CODE_ADDR_0, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
+ OUT_CS_REG(R300_US_CODE_ADDR_3, R300_RGBA_OUT);
+
+ for (i = 0; i < fs->alu_instruction_count; i++) {
+ OUT_CS_REG(R300_US_ALU_RGB_INST_0 + (4 * i),
+ fs->instructions[i].alu_rgb_inst);
+ OUT_CS_REG(R300_US_ALU_RGB_ADDR_0 + (4 * i),
+ fs->instructions[i].alu_rgb_addr);
+ OUT_CS_REG(R300_US_ALU_ALPHA_INST_0 + (4 * i),
+ fs->instructions[i].alu_alpha_inst);
+ OUT_CS_REG(R300_US_ALU_ALPHA_ADDR_0 + (4 * i),
+ fs->instructions[i].alu_alpha_addr);
+ }
+
+ END_CS;
}
void r500_emit_fragment_shader(struct r300_context* r300,
- struct r500_fragment_shader* shader)
+ struct r500_fragment_shader* fs)
{
CS_LOCALS(r300);
- int i = 0;
+ int i;
- BEGIN_CS(8 + (shader->shader.instruction_count * 6) + 6);
+ BEGIN_CS(8 + (fs->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_PIXSIZE, fs->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));
+ R500_US_CODE_END_ADDR(fs->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);
+ fs->instruction_count * 6);
+ for (i = 0; i < fs->instruction_count; i++) {
+ OUT_CS(fs->instructions[i].inst0);
+ OUT_CS(fs->instructions[i].inst1);
+ OUT_CS(fs->instructions[i].inst2);
+ OUT_CS(fs->instructions[i].inst3);
+ OUT_CS(fs->instructions[i].inst4);
+ OUT_CS(fs->instructions[i].inst5);
}
R300_PACIFY;
END_CS;
@@ -173,6 +198,16 @@ static void r300_emit_dirty_state(struct r300_context* r300)
r300_emit_dsa_state(r300, r300->dsa_state);
}
+ if (r300->dirty_state & R300_NEW_FRAGMENT_SHADER) {
+ if (r300screen->caps->is_r500) {
+ r500_emit_fragment_shader(r300,
+ (struct r500_fragment_shader*)r300->fs);
+ } else {
+ r300_emit_fragment_shader(r300,
+ (struct r300_fragment_shader*)r300->fs);
+ }
+ }
+
if (r300->dirty_state & R300_NEW_RASTERIZER) {
r300_emit_rs_state(r300, r300->rs_state);
}
diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c
index 710b7ee0a60..824dbeb0aa2 100644
--- a/src/gallium/drivers/r300/r300_state_shader.c
+++ b/src/gallium/drivers/r300/r300_state_shader.c
@@ -24,11 +24,21 @@
void r300_make_passthrough_fragment_shader(struct r300_fragment_shader* fs)
{
+ fs->alu_instruction_count = 1;
+ fs->tex_instruction_count = 0;
+ fs->indirections = 1;
+ fs->shader.stack_size = 2;
+
+ /* XXX decode these */
+ fs->instructions[0].alu_rgb_inst = 0x50A80;
+ fs->instructions[0].alu_rgb_inst = 0x1C000000;
+ fs->instructions[0].alu_alpha_inst = 0x40889;
+ fs->instructions[0].alu_alpha_inst = 0x1000000;
}
void r500_make_passthrough_fragment_shader(struct r500_fragment_shader* fs)
{
- fs->shader.instruction_count = 1;
+ fs->instruction_count = 1;
fs->shader.stack_size = 0;
fs->instructions[0].inst0 = R500_INST_TYPE_OUT |