diff options
author | Corbin Simpson <[email protected]> | 2010-03-20 17:16:46 -0700 |
---|---|---|
committer | Corbin Simpson <[email protected]> | 2010-03-20 17:16:46 -0700 |
commit | 4711aa089ec7af70bb9118ad8d7830e475805297 (patch) | |
tree | 38baf404cadd552d9908a95ddbb09d9fed015418 /src/gallium/drivers | |
parent | 7c8221b46008cd4f217d3ddab59dcc4c488a54b3 (diff) |
r300g: Correctly hax max_index on pipe_vertex_buffers.
Still not happy with this, but at least things seem to work.
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/r300/r300_render.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 38 |
2 files changed, 28 insertions, 12 deletions
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c index 47100c83b0b..40c1a420428 100644 --- a/src/gallium/drivers/r300/r300_render.c +++ b/src/gallium/drivers/r300/r300_render.c @@ -307,7 +307,7 @@ static void r300_emit_draw_elements(struct r300_context *r300, assert((start * indexSize) % 4 == 0); assert(count < (1 << 24)); - maxIndex = MIN3(maxIndex, r300->vertex_buffer_max_index, count - minIndex); + maxIndex = MIN2(maxIndex, r300->vertex_buffer_max_index); DBG(r300, DBG_DRAW, "r300: Indexbuf of %u indices, min %u max %u\n", count, minIndex, maxIndex); diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index bdfe74ed2a0..6328374e301 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -1109,26 +1109,42 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe, const struct pipe_vertex_buffer* buffers) { struct r300_context* r300 = r300_context(pipe); - int i; - unsigned max_index = (1 << 24) - 1; - boolean any_user_buffer = false; + struct pipe_vertex_buffer *vbo; + unsigned i, max_index = (1 << 24) - 1; + boolean any_user_buffer = FALSE; if (count == r300->vertex_buffer_count && - memcmp(r300->vertex_buffer, buffers, count * sizeof(buffers[0])) == 0) + memcmp(r300->vertex_buffer, buffers, + sizeof(struct pipe_vertex_buffer) * count) == 0) { return; + } for (i = 0; i < count; i++) { - pipe_buffer_reference(&r300->vertex_buffer[i].buffer, buffers[i].buffer); - if (r300_buffer_is_user_buffer(buffers[i].buffer)) - any_user_buffer = true; - max_index = MIN2(buffers[i].max_index, max_index); + /* Why, yes, I AM casting away constness. How did you know? */ + vbo = (struct pipe_vertex_buffer*)&buffers[i]; + + /* Reference our buffer. */ + pipe_buffer_reference(&r300->vertex_buffer[i].buffer, vbo->buffer); + if (r300_buffer_is_user_buffer(vbo->buffer)) { + any_user_buffer = TRUE; + } + + if (vbo->max_index == ~0) { + /* Bogus value from broken state tracker; hax it. */ + vbo->max_index = + (vbo->buffer->size - vbo->buffer_offset) / vbo->stride; + } + + max_index = MIN2(vbo->max_index, max_index); } - for ( ; i < r300->vertex_buffer_count; i++) - pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL); + for (; i < r300->vertex_buffer_count; i++) { + /* Dereference any old buffers. */ + pipe_buffer_reference(&r300->vertex_buffer[i].buffer, NULL); + } memcpy(r300->vertex_buffer, buffers, - sizeof(struct pipe_vertex_buffer) * count); + sizeof(struct pipe_vertex_buffer) * count); r300->vertex_buffer_count = count; r300->vertex_buffer_max_index = max_index; |