Mesa (master): mesa/st: Handle feedback draw when VBO offsets are not sorted in ascending order.

Jose Fonseca jrfonseca at kemper.freedesktop.org
Thu Apr 7 04:20:29 PDT 2011


Module: Mesa
Branch: master
Commit: aa61b1535187129c61dd772471f23c633971665d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=aa61b1535187129c61dd772471f23c633971665d

Author: José Fonseca <jfonseca at vmware.com>
Date:   Wed Apr  6 14:38:26 2011 +0100

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.

---

 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 1e1220b..96a08b3 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 */



More information about the mesa-commit mailing list