cso: unreference saved vertex buffers when restoring
authorMarek Olšák <maraeo@gmail.com>
Tue, 10 Apr 2012 06:28:23 +0000 (08:28 +0200)
committerMarek Olšák <maraeo@gmail.com>
Thu, 12 Apr 2012 17:17:47 +0000 (19:17 +0200)
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/auxiliary/cso_cache/cso_context.c

index 60a6e0262e0bc0bfb45145c66a169bf4715ec73f..43b834314dc8547fdfe51120ab55e6aa396db226 100644 (file)
@@ -863,10 +863,18 @@ void cso_save_vertex_buffers(struct cso_context *ctx)
 
 void cso_restore_vertex_buffers(struct cso_context *ctx)
 {
+   unsigned i;
+
    util_copy_vertex_buffers(ctx->vertex_buffers,
                             &ctx->nr_vertex_buffers,
                             ctx->vertex_buffers_saved,
                             ctx->nr_vertex_buffers_saved);
+
+   for (i = 0; i < ctx->nr_vertex_buffers_saved; i++) {
+      pipe_resource_reference(&ctx->vertex_buffers_saved[i].buffer, NULL);
+   }
+   ctx->nr_vertex_buffers_saved = 0;
+
    ctx->pipe->set_vertex_buffers(ctx->pipe, ctx->nr_vertex_buffers,
                                  ctx->vertex_buffers);
 }