Mesa (master): galahad: do map/unmap counting for resources

Brian Paul brianp at kemper.freedesktop.org
Fri Sep 3 22:35:36 UTC 2010


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

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Sep  3 16:35:07 2010 -0600

galahad: do map/unmap counting for resources

---

 src/gallium/drivers/galahad/glhd_context.c |   16 ++++++++++++++++
 src/gallium/drivers/galahad/glhd_objects.h |    2 ++
 2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/src/gallium/drivers/galahad/glhd_context.c b/src/gallium/drivers/galahad/glhd_context.c
index 383c448..5b56a4d 100644
--- a/src/gallium/drivers/galahad/glhd_context.c
+++ b/src/gallium/drivers/galahad/glhd_context.c
@@ -54,6 +54,10 @@ galahad_draw_vbo(struct pipe_context *_pipe,
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
 
+   /* XXX we should check that all bound resources are unmapped
+    * before drawing.
+    */
+
    pipe->draw_vbo(pipe, info);
 }
 
@@ -860,6 +864,10 @@ galahad_context_transfer_map(struct pipe_context *_context,
    struct pipe_context *context = glhd_context->pipe;
    struct pipe_transfer *transfer = glhd_transfer->transfer;
 
+   struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
+
+   glhd_resource->map_count++;
+
    return context->transfer_map(context,
                                 transfer);
 }
@@ -890,6 +898,14 @@ galahad_context_transfer_unmap(struct pipe_context *_context,
    struct galahad_transfer *glhd_transfer = galahad_transfer(_transfer);
    struct pipe_context *context = glhd_context->pipe;
    struct pipe_transfer *transfer = glhd_transfer->transfer;
+   struct galahad_resource *glhd_resource = galahad_resource(_transfer->resource);
+
+   if (glhd_resource->map_count < 1) {
+      glhd_warn("context::transfer_unmap() called too many times"
+                " (count = %d)\n", glhd_resource->map_count);      
+   }
+
+   glhd_resource->map_count--;
 
    context->transfer_unmap(context,
                            transfer);
diff --git a/src/gallium/drivers/galahad/glhd_objects.h b/src/gallium/drivers/galahad/glhd_objects.h
index 9358039..dc74c5b 100644
--- a/src/gallium/drivers/galahad/glhd_objects.h
+++ b/src/gallium/drivers/galahad/glhd_objects.h
@@ -42,6 +42,8 @@ struct galahad_resource
    struct pipe_resource base;
 
    struct pipe_resource *resource;
+
+   int map_count;
 };
 
 




More information about the mesa-commit mailing list