Mesa (master): st/mesa: fix crash when using both user and vbo buffers with the same stride

Marek Olšák mareko at kemper.freedesktop.org
Tue Feb 22 13:11:29 UTC 2011


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Sun Feb 20 18:05:24 2011 +0100

st/mesa: fix crash when using both user and vbo buffers with the same stride

If two buffers had the same stride where one buffer is a user one and
the other is a vbo, it was considered to be one interleaved buffer,
resulting in incorrect rendering and crashes.

This patch makes sure that the interleaved buffer is either user or vbo,
not both.

---

 src/mesa/state_tracker/st_draw.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 5475e87..11ebd06 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -249,6 +249,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
    const struct gl_buffer_object *firstBufObj = NULL;
    GLint firstStride = -1;
    const GLubyte *client_addr = NULL;
+   GLboolean user_memory;
 
    for (attr = 0; attr < vpv->num_inputs; attr++) {
       const GLuint mesaAttr = vp->index_to_input[attr];
@@ -257,6 +258,7 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
 
       if (firstStride < 0) {
          firstStride = stride;
+         user_memory = !bufObj || !bufObj->Name;
       }
       else if (firstStride != stride) {
          return GL_FALSE;
@@ -266,6 +268,9 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
          /* Try to detect if the client-space arrays are
           * "close" to each other.
           */
+         if (!user_memory) {
+            return GL_FALSE;
+         }
          if (!client_addr) {
             client_addr = arrays[mesaAttr]->Ptr;
          }
@@ -275,6 +280,9 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
          }
       }
       else if (!firstBufObj) {
+         if (user_memory) {
+            return GL_FALSE;
+         }
          firstBufObj = bufObj;
       }
       else if (bufObj != firstBufObj) {




More information about the mesa-commit mailing list