From 735d0d93a7d748c2e0c0f13fcd6da0c13b678da9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Fri, 11 May 2012 23:33:50 +0200 Subject: [PATCH] r300g/swtcl: move index buffer updates from swtcl_draw_vbo into set_index_buffer --- src/gallium/drivers/r300/r300_render.c | 10 --------- src/gallium/drivers/r300/r300_state.c | 29 +++++++++++++++++++++----- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index d98b28896be..ea82e49d450 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -879,16 +879,6 @@ static void r300_swtcl_draw_vbo(struct pipe_context* pipe, } } - if (indexed) { - if (r300->index_buffer.user_buffer) { - draw_set_mapped_index_buffer(r300->draw, - r300->index_buffer.user_buffer); - } else if (r300->index_buffer.buffer) { - draw_set_mapped_index_buffer(r300->draw, - r300_resource(r300->index_buffer.buffer)->malloced_buffer); - } - } - r300->draw_vbo_locked = TRUE; r300->draw_first_emitted = FALSE; draw_vbo(r300->draw, info); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 758fb40fea4..cecbfd213f3 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1614,8 +1614,8 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, } } -static void r300_set_index_buffer(struct pipe_context* pipe, - const struct pipe_index_buffer *ib) +static void r300_set_index_buffer_hwtcl(struct pipe_context* pipe, + const struct pipe_index_buffer *ib) { struct r300_context* r300 = r300_context(pipe); @@ -1625,9 +1625,23 @@ static void r300_set_index_buffer(struct pipe_context* pipe, } else { pipe_resource_reference(&r300->index_buffer.buffer, NULL); } +} + +static void r300_set_index_buffer_swtcl(struct pipe_context* pipe, + const struct pipe_index_buffer *ib) +{ + struct r300_context* r300 = r300_context(pipe); + + draw_set_index_buffer(r300->draw, ib); - if (!r300->screen->caps.has_tcl) { - draw_set_index_buffer(r300->draw, ib); + if (ib) { + if (ib->user_buffer) { + draw_set_mapped_index_buffer(r300->draw, + ib->user_buffer); + } else if (ib->buffer) { + draw_set_mapped_index_buffer(r300->draw, + r300_resource(ib->buffer)->malloced_buffer); + } } } @@ -1939,7 +1953,12 @@ void r300_init_state_functions(struct r300_context* r300) r300->context.set_viewport_state = r300_set_viewport_state; r300->context.set_vertex_buffers = r300_set_vertex_buffers; - r300->context.set_index_buffer = r300_set_index_buffer; + + if (r300->screen->caps.has_tcl) { + r300->context.set_index_buffer = r300_set_index_buffer_hwtcl; + } else { + r300->context.set_index_buffer = r300_set_index_buffer_swtcl; + } r300->context.create_vertex_elements_state = r300_create_vertex_elements_state; r300->context.bind_vertex_elements_state = r300_bind_vertex_elements_state; -- 2.30.2