r300g: always emit the correct max vertex index to avoid DRM errors

Fixing bizarre reports that a vertex buffer is not large enough.
This commit is contained in:
Marek Olšák 2010-02-27 00:37:01 +01:00
parent dba7ad8953
commit 93da152209
3 changed files with 13 additions and 2 deletions

View File

@ -326,6 +326,7 @@ struct r300_context {
/* Vertex buffers for Gallium. */
struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
int vertex_buffer_count;
int vertex_buffer_max_index;
/* Vertex elements for Gallium. */
struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
int vertex_element_count;

View File

@ -452,8 +452,11 @@ void r300_draw_elements(struct pipe_context* pipe,
unsigned indexSize, unsigned mode,
unsigned start, unsigned count)
{
pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0, ~0,
mode, start, count);
struct r300_context *r300 = r300_context(pipe);
pipe->draw_range_elements(pipe, indexBuffer, indexSize, 0,
r300->vertex_buffer_max_index,
mode, start, count);
}
void r300_draw_arrays(struct pipe_context* pipe, unsigned mode,

View File

@ -1026,10 +1026,17 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
const struct pipe_vertex_buffer* buffers)
{
struct r300_context* r300 = r300_context(pipe);
unsigned i, max_index = ~0;
memcpy(r300->vertex_buffer, buffers,
sizeof(struct pipe_vertex_buffer) * count);
for (i = 0; i < count; i++) {
max_index = MIN2(buffers[i].max_index, max_index);
}
r300->vertex_buffer_count = count;
r300->vertex_buffer_max_index = max_index;
if (r300->draw) {
draw_flush(r300->draw);