diff options
author | Corbin Simpson <[email protected]> | 2009-03-15 23:04:49 -0700 |
---|---|---|
committer | Corbin Simpson <[email protected]> | 2009-03-15 23:07:31 -0700 |
commit | 44adea1a0975ebad59790b9cfd03439aa44559fc (patch) | |
tree | afa2f5369432209d9efb6e4c6eaf1ba9a285b232 /src | |
parent | 1e56bb890bff5a9750dbd439e91ce03c87a750b8 (diff) |
r300-gallium: r500-fs: Setup immediates.
Textures still not working. RS block shenanigans expected.
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/r300/r300_context.c | 1 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 28 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_shader.c | 26 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_shader.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_surface.c | 4 |
5 files changed, 57 insertions, 8 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index 1affcbfdf41..df7f85b9371 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -59,7 +59,6 @@ static boolean r300_draw_range_elements(struct pipe_context* pipe, r300->shader_constants[PIPE_SHADER_VERTEX].user_count * (sizeof(float) * 4)); - /* Abandon all hope, ye who enter here. */ draw_arrays(r300->draw, mode, start, count); for (i = 0; i < r300->vertex_buffer_count; i++) { diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index c2ad3ac6f5d..3b580b7d51b 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -115,17 +115,19 @@ void r500_emit_fragment_shader(struct r300_context* r300, struct r500_fragment_shader* fs) { CS_LOCALS(r300); + struct r300_constant_buffer* constants = + &r300->shader_constants[PIPE_SHADER_FRAGMENT]; int i; - BEGIN_CS(9 + (fs->instruction_count * 6)); + BEGIN_CS(9 + (fs->instruction_count * 6) + (constants->count ? 3 : 0) + + (constants->count * 4)); OUT_CS_REG(R500_US_CONFIG, R500_ZERO_TIMES_ANYTHING_EQUALS_ZERO); 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(fs->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, - fs->instruction_count * 6); + OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, fs->instruction_count * 6); for (i = 0; i < fs->instruction_count; i++) { OUT_CS(fs->instructions[i].inst0); OUT_CS(fs->instructions[i].inst1); @@ -134,6 +136,19 @@ void r500_emit_fragment_shader(struct r300_context* r300, OUT_CS(fs->instructions[i].inst4); OUT_CS(fs->instructions[i].inst5); } + + if (constants->count) { + OUT_CS_REG(R500_GA_US_VECTOR_INDEX, + R500_GA_US_VECTOR_INDEX_TYPE_CONST); + OUT_CS_ONE_REG(R500_GA_US_VECTOR_DATA, constants->count * 4); + for (i = 0; i < constants->count; i++) { + OUT_CS(constants->constants[i][0]); + OUT_CS(constants->constants[i][1]); + OUT_CS(constants->constants[i][2]); + OUT_CS(constants->constants[i][3]); + } + } + END_CS; } @@ -229,6 +244,7 @@ void r300_emit_rs_block_state(struct r300_context* r300, } for (i = 0; i < 8; i++) { OUT_CS(rs->ip[i]); + //debug_printf("ip %d: 0x%08x\n", i, rs->ip[i]); } OUT_CS_REG_SEQ(R300_RS_COUNT, 2); @@ -242,8 +258,12 @@ void r300_emit_rs_block_state(struct r300_context* r300, } for (i = 0; i < 8; i++) { OUT_CS(rs->inst[i]); + //debug_printf("inst %d: 0x%08x\n", i, rs->inst[i]); } + /* debug_printf("count: 0x%08x inst_count: 0x%08x\n", rs->count, + rs->inst_count); */ + END_CS; } diff --git a/src/gallium/drivers/r300/r300_state_shader.c b/src/gallium/drivers/r300/r300_state_shader.c index 06dd6842ed8..519879114a9 100644 --- a/src/gallium/drivers/r300/r300_state_shader.c +++ b/src/gallium/drivers/r300/r300_state_shader.c @@ -82,6 +82,13 @@ static INLINE unsigned r300_fs_src(struct r300_fs_asm* assembler, case TGSI_FILE_TEMPORARY: return src->Index + assembler->temp_offset; break; + case TGSI_FILE_IMMEDIATE: + return src->Index + assembler->imm_offset | (1 << 8); + break; + case TGSI_FILE_CONSTANT: + /* XXX magic */ + return src->Index | (1 << 8); + break; default: debug_printf("r300: fs: Unimplemented src %d\n", src->File); break; @@ -269,11 +276,13 @@ void r300_translate_fragment_shader(struct r300_context* r300, void r500_translate_fragment_shader(struct r300_context* r300, struct r500_fragment_shader* fs) { + struct tgsi_parse_context parser; + int i, imm_const_offset; + struct r300_fs_asm* assembler = CALLOC_STRUCT(r300_fs_asm); if (assembler == NULL) { return; } - struct tgsi_parse_context parser; tgsi_parse_init(&parser, fs->shader.state.tokens); @@ -288,9 +297,24 @@ void r500_translate_fragment_shader(struct r300_context* r300, * of the program. */ r300_fs_declare(assembler, &parser.FullToken.FullDeclaration); break; + case TGSI_TOKEN_TYPE_IMMEDIATE: + assembler->imm_offset++; + imm_const_offset = assembler->imm_offset + + r300->shader_constants[PIPE_SHADER_FRAGMENT].user_count; + /* I am not amused by the length of these. */ + for (i = 0; i < 4; i++) { + r300->shader_constants[PIPE_SHADER_FRAGMENT].constants + [imm_const_offset][i] = + parser.FullToken.FullImmediate.u.ImmediateFloat32[i] + .Float; + } + r300->shader_constants[PIPE_SHADER_FRAGMENT].count = + imm_const_offset; + break; case TGSI_TOKEN_TYPE_INSTRUCTION: r500_fs_instruction(fs, assembler, &parser.FullToken.FullInstruction); + break; } } diff --git a/src/gallium/drivers/r300/r300_state_shader.h b/src/gallium/drivers/r300/r300_state_shader.h index 87a5c99648e..8011e1f5380 100644 --- a/src/gallium/drivers/r300/r300_state_shader.h +++ b/src/gallium/drivers/r300/r300_state_shader.h @@ -60,6 +60,8 @@ /* Temporary struct used to hold assembly state while putting together * fragment programs. */ struct r300_fs_asm { + /* Pipe context. */ + struct r300_context* r300; /* Number of colors. */ unsigned color_count; /* Number of texcoords. */ @@ -70,6 +72,10 @@ struct r300_fs_asm { unsigned temp_offset; /* Number of requested temporary registers. */ unsigned temp_count; + /* Offset for immediate constants. Neither R300 nor R500 can do four + * inline constants per source, so instead we copy immediates into the + * constant buffer. */ + unsigned imm_offset; }; void r300_translate_fragment_shader(struct r300_context* r300, diff --git a/src/gallium/drivers/r300/r300_surface.c b/src/gallium/drivers/r300/r300_surface.c index a49bec99101..744d60364bd 100644 --- a/src/gallium/drivers/r300/r300_surface.c +++ b/src/gallium/drivers/r300/r300_surface.c @@ -36,9 +36,9 @@ static void r300_surface_fill(struct pipe_context* pipe, struct r300_capabilities* caps = r300_screen(pipe->screen)->caps; struct r300_texture* tex = (struct r300_texture*)dest->texture; int i; - - float r, g, b, a; + float r, g, b, a, depth; unsigned pixpitch = tex->stride / tex->tex.block.size; + r = (float)((color >> 16) & 0xff) / 255.0f; g = (float)((color >> 8) & 0xff) / 255.0f; b = (float)((color >> 0) & 0xff) / 255.0f; |