Mesa (master): mesa/st: Clean up vertex buffer unreferencing

Thomas Hellstrom thomash at kemper.freedesktop.org
Wed Feb 9 00:49:53 PST 2011


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

Author: Thomas Hellstrom <thellstrom at vmware.com>
Date:   Tue Feb  8 11:36:56 2011 +0100

mesa/st: Clean up vertex buffer unreferencing

Avoid accessing draw module internal structures outside of the draw module.
Unreference vertex buffers in error path.

Signed-off-by: Thomas Hellstrom <thellstrom at vmware.com>

---

 src/mesa/state_tracker/st_draw_feedback.c |   19 +++++++++----------
 1 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index c11c769..545b32d 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -220,7 +220,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
          break;
       default:
          assert(0);
-	 return;
+	 goto out_unref_vertex;
       }
 
       if (bufobj && bufobj->Name) {
@@ -256,15 +256,6 @@ st_feedback_draw_vbo(struct gl_context *ctx,
    /*
     * unmap vertex/index buffers
     */
-   for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
-      if (draw->pt.vertex_buffer[i].buffer) {
-         pipe_buffer_unmap(pipe, vb_transfer[i]);
-         pipe_resource_reference(&draw->pt.vertex_buffer[i].buffer, NULL);
-         draw_set_mapped_vertex_buffer(draw, i, NULL);
-         pipe_resource_reference(&vbuffers[i].buffer, NULL);
-      }
-   }
-
    if (ib) {
       draw_set_mapped_index_buffer(draw, NULL);
       draw_set_index_buffer(draw, NULL);
@@ -273,6 +264,14 @@ st_feedback_draw_vbo(struct gl_context *ctx,
          pipe_buffer_unmap(pipe, ib_transfer);
       pipe_resource_reference(&ibuffer.buffer, NULL);
    }
+
+ out_unref_vertex:
+   for (attr = 0; attr < vp->num_inputs; attr++) {
+      pipe_buffer_unmap(pipe, vb_transfer[attr]);
+      draw_set_mapped_vertex_buffer(draw, attr, NULL);
+      pipe_resource_reference(&vbuffers[attr].buffer, NULL);
+   }
+   draw_set_vertex_buffers(draw, 0, NULL);
 }
 
 #endif /* FEATURE_feedback || FEATURE_rastpos */



More information about the mesa-commit mailing list