From c1365606c5b89872af4a0931e20f5cb78875eea6 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Fri, 3 Dec 2010 20:53:39 +1000 Subject: r300g: try and use all of vertex constant space MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Finished up by Marek Olšák. We can set the constant space to use a different area per-call to the shader, we can avoid flushing the PVS as often as we do by spreading out the constants across the whole constant space. Signed-off-by: Marek Olšák --- src/gallium/drivers/r300/r300_state.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/gallium/drivers/r300/r300_state.c') diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 5689275550..4eef9da06a 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1765,15 +1765,13 @@ static void r300_bind_vs_state(struct pipe_context* pipe, void* shader) r300->vs_state.dirty = TRUE; r300->vs_state.size = vs->code.length + 9 + - (vs->immediates_count ? vs->immediates_count * 4 + 3 : 0) + (vs->code.num_fc_ops ? vs->code.num_fc_ops * fc_op_dwords + 4 : 0); - if (vs->externals_count) { - r300->vs_constants.dirty = TRUE; - r300->vs_constants.size = vs->externals_count * 4 + 3; - } else { - r300->vs_constants.size = 0; - } + r300->vs_constants.dirty = TRUE; + r300->vs_constants.size = + 2 + + (vs->externals_count ? vs->externals_count * 4 + 3 : 0) + + (vs->immediates_count ? vs->immediates_count * 4 + 3 : 0); ((struct r300_constant_buffer*)r300->vs_constants.state)->remap_table = vs->code.constants_remap_table; @@ -1835,10 +1833,22 @@ static void r300_set_constant_buffer(struct pipe_context *pipe, if (shader == PIPE_SHADER_VERTEX) { if (r300->screen->caps.has_tcl) { - if (r300->vs_constants.size) { - r300->vs_constants.dirty = TRUE; + struct r300_vertex_shader *vs = + (struct r300_vertex_shader*)r300->vs_state.state; + + if (!vs) { + cbuf->buffer_base = 0; + return; } - r300->pvs_flush.dirty = TRUE; + + cbuf->buffer_base = r300->vs_const_base; + r300->vs_const_base += vs->code.constants.Count; + if (r300->vs_const_base > R500_MAX_PVS_CONST_VECS) { + r300->vs_const_base = vs->code.constants.Count; + cbuf->buffer_base = 0; + r300->pvs_flush.dirty = TRUE; + } + r300->vs_constants.dirty = TRUE; } else if (r300->draw) { draw_set_mapped_constant_buffer(r300->draw, PIPE_SHADER_VERTEX, 0, mapped, buf->width0); -- cgit v1.2.3