diff options
author | Marek Olšák <[email protected]> | 2010-02-12 04:49:30 +0100 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2010-02-13 15:44:43 +0100 |
commit | 8eb4cd5b825db7bf26da240ccddaf9a7e5e55a62 (patch) | |
tree | e159044848c055c6147ff0f8f479a561150aa41b | |
parent | 67049b59fdc3fb8dff6a04cb4929f48c28cd88ca (diff) |
r300g: cleanup the emission of RS block state
Emit as few regs as possible.
-rw-r--r-- | src/gallium/drivers/r300/r300_emit.c | 16 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_derived.c | 6 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c index 7399ab8ef39..3b59367a0b1 100644 --- a/src/gallium/drivers/r300/r300_emit.c +++ b/src/gallium/drivers/r300/r300_emit.c @@ -629,17 +629,19 @@ void r300_emit_rs_block_state(struct r300_context* r300, void* state) struct r300_rs_block* rs = (struct r300_rs_block*)state; unsigned i; struct r300_screen* r300screen = r300_screen(r300->context.screen); + /* It's the same for both INST and IP tables */ + unsigned count = (rs->inst_count & R300_RS_INST_COUNT_MASK) + 1; CS_LOCALS(r300); DBG(r300, DBG_DRAW, "r300: RS emit:\n"); - BEGIN_CS(21); + BEGIN_CS(5 + count*2); if (r300screen->caps->is_r500) { - OUT_CS_REG_SEQ(R500_RS_IP_0, 8); + OUT_CS_REG_SEQ(R500_RS_IP_0, count); } else { - OUT_CS_REG_SEQ(R300_RS_IP_0, 8); + OUT_CS_REG_SEQ(R300_RS_IP_0, count); } - for (i = 0; i < 8; i++) { + for (i = 0; i < count; i++) { OUT_CS(rs->ip[i]); DBG(r300, DBG_DRAW, " : ip %d: 0x%08x\n", i, rs->ip[i]); } @@ -649,11 +651,11 @@ void r300_emit_rs_block_state(struct r300_context* r300, void* state) OUT_CS(rs->inst_count); if (r300screen->caps->is_r500) { - OUT_CS_REG_SEQ(R500_RS_INST_0, 8); + OUT_CS_REG_SEQ(R500_RS_INST_0, count); } else { - OUT_CS_REG_SEQ(R300_RS_INST_0, 8); + OUT_CS_REG_SEQ(R300_RS_INST_0, count); } - for (i = 0; i < 8; i++) { + for (i = 0; i < count; i++) { OUT_CS(rs->inst[i]); DBG(r300, DBG_DRAW, " : inst %d: 0x%08x\n", i, rs->inst[i]); } diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c index bad9e76067c..2cbce9210a7 100644 --- a/src/gallium/drivers/r300/r300_state_derived.c +++ b/src/gallium/drivers/r300/r300_state_derived.c @@ -306,7 +306,7 @@ static void r300_update_rs_block(struct r300_context* r300, struct r300_shader_semantics* fs_inputs) { struct r300_rs_block rs = { { 0 } }; - int i, col_count = 0, tex_count = 0, fp_offset = 0; + int i, col_count = 0, tex_count = 0, fp_offset = 0, count; void (*rX00_rs_col)(struct r300_rs_block*, int, int, boolean); void (*rX00_rs_col_write)(struct r300_rs_block*, int, int); void (*rX00_rs_tex)(struct r300_rs_block*, int, int, boolean); @@ -410,11 +410,13 @@ static void r300_update_rs_block(struct r300_context* r300, rs.count = (tex_count*4) | (col_count << R300_IC_COUNT_SHIFT) | R300_HIRES_EN; - rs.inst_count = MAX3(col_count - 1, tex_count - 1, 0); + count = MAX3(col_count, tex_count, 1); + rs.inst_count = count - 1; /* Now, after all that, see if we actually need to update the state. */ if (memcmp(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block))) { memcpy(r300->rs_block_state.state, &rs, sizeof(struct r300_rs_block)); + r300->rs_block_state.size = 5 + count; r300->rs_block_state.dirty = TRUE; } } |