diff options
author | José Fonseca <[email protected]> | 2011-04-06 14:38:26 +0100 |
---|---|---|
committer | José Fonseca <[email protected]> | 2011-04-07 12:20:06 +0100 |
commit | aa61b1535187129c61dd772471f23c633971665d (patch) | |
tree | fd0c840f06564ef32791ee8f143f02fb71540ea1 /src | |
parent | 66b66295d0bc856c69fdcccc22575580c7ecee16 (diff) |
mesa/st: Handle feedback draw when VBO offsets are not sorted in ascending order.
Simply port the same logic from setup_interleaved_attribs().
Avoids overflow in mustpass.c and feedback.c conform tests.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/state_tracker/st_draw_feedback.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c index 1e1220bfe52..96a08b39100 100644 --- a/src/mesa/state_tracker/st_draw_feedback.c +++ b/src/mesa/state_tracker/st_draw_feedback.c @@ -111,6 +111,7 @@ st_feedback_draw_vbo(struct gl_context *ctx, struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS]; struct pipe_transfer *ib_transfer = NULL; GLuint attr, i; + const GLubyte *low_addr = NULL; const void *mapped_indices = NULL; assert(draw); @@ -141,6 +142,16 @@ st_feedback_draw_vbo(struct gl_context *ctx, draw_bind_vertex_shader(draw, st->vp_variant->draw_shader); set_feedback_vertex_format(ctx); + /* Find the lowest address of the arrays we're drawing */ + if (vp->num_inputs) { + low_addr = arrays[vp->index_to_input[0]]->Ptr; + + for (attr = 1; attr < vp->num_inputs; attr++) { + const GLubyte *start = arrays[vp->index_to_input[attr]]->Ptr; + low_addr = MIN2(low_addr, start); + } + } + /* loop over TGSI shader inputs to determine vertex buffer * and attribute info */ @@ -159,8 +170,8 @@ st_feedback_draw_vbo(struct gl_context *ctx, vbuffers[attr].buffer = NULL; pipe_resource_reference(&vbuffers[attr].buffer, stobj->buffer); - vbuffers[attr].buffer_offset = pointer_to_offset(arrays[0]->Ptr); - velements[attr].src_offset = arrays[mesaAttr]->Ptr - arrays[0]->Ptr; + vbuffers[attr].buffer_offset = pointer_to_offset(low_addr); + velements[attr].src_offset = arrays[mesaAttr]->Ptr - low_addr; } else { /* attribute data is in user-space memory, not a VBO */ |