Mesa (master): util: reference vertex buffers in blitter

Marek Olšák mareko at kemper.freedesktop.org
Tue Jun 8 17:27:03 PDT 2010


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

Author: Marek Olšák <maraeo at gmail.com>
Date:   Wed Jun  9 02:13:10 2010 +0200

util: reference vertex buffers in blitter

---

 src/gallium/auxiliary/util/u_blitter.c |    8 ++++++++
 src/gallium/auxiliary/util/u_blitter.h |   10 ++++++++++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c
index ae4c80c..dfe2101 100644
--- a/src/gallium/auxiliary/util/u_blitter.c
+++ b/src/gallium/auxiliary/util/u_blitter.c
@@ -282,6 +282,7 @@ static void blitter_check_saved_CSOs(struct blitter_context_priv *ctx)
 static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
 {
    struct pipe_context *pipe = ctx->pipe;
+   unsigned i;
 
    /* restore the state objects which are always required to be saved */
    pipe->bind_blend_state(pipe, ctx->blitter.saved_blend_state);
@@ -328,6 +329,13 @@ static void blitter_restore_CSOs(struct blitter_context_priv *ctx)
       pipe->set_vertex_buffers(pipe,
                                ctx->blitter.saved_num_vertex_buffers,
                                ctx->blitter.saved_vertex_buffers);
+
+      for (i = 0; i < ctx->blitter.saved_num_vertex_buffers; i++) {
+         if (ctx->blitter.saved_vertex_buffers[i].buffer) {
+            pipe_resource_reference(&ctx->blitter.saved_vertex_buffers[i].buffer,
+                                    NULL);
+         }
+      }
       ctx->blitter.saved_num_vertex_buffers = ~0;
    }
 }
diff --git a/src/gallium/auxiliary/util/u_blitter.h b/src/gallium/auxiliary/util/u_blitter.h
index 10143a5..2284928 100644
--- a/src/gallium/auxiliary/util/u_blitter.h
+++ b/src/gallium/auxiliary/util/u_blitter.h
@@ -27,6 +27,7 @@
 #ifndef U_BLITTER_H
 #define U_BLITTER_H
 
+#include "util/u_inlines.h"
 #include "util/u_memory.h"
 
 #include "pipe/p_state.h"
@@ -259,9 +260,18 @@ util_blitter_save_vertex_buffers(struct blitter_context *blitter,
                                          int num_vertex_buffers,
                                          struct pipe_vertex_buffer *vertex_buffers)
 {
+   unsigned i;
    assert(num_vertex_buffers <= Elements(blitter->saved_vertex_buffers));
 
    blitter->saved_num_vertex_buffers = num_vertex_buffers;
+
+   for (i = 0; i < num_vertex_buffers; i++) {
+      if (vertex_buffers[i].buffer) {
+         pipe_resource_reference(&blitter->saved_vertex_buffers[i].buffer,
+                                 vertex_buffers[i].buffer);
+      }
+   }
+
    memcpy(blitter->saved_vertex_buffers,
           vertex_buffers,
           num_vertex_buffers * sizeof(struct pipe_vertex_buffer));



More information about the mesa-commit mailing list