Mesa (master): svga: Describe svga_sampler_views for refcnt debugging

Jakob Bornecrantz wallbraker at kemper.freedesktop.org
Fri Feb 18 14:49:26 UTC 2011


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

Author: Jakob Bornecrantz <jakob at vmware.com>
Date:   Thu Feb 17 14:58:55 2011 +0000

svga: Describe svga_sampler_views for refcnt debugging

Signed-off-by: Jakob Bornecrantz <jakob at vmware.com>

---

 src/gallium/drivers/svga/svga_sampler_view.c |   16 ++++++++++++++++
 src/gallium/drivers/svga/svga_sampler_view.h |    6 +++++-
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_sampler_view.c b/src/gallium/drivers/svga/svga_sampler_view.c
index 079046e..4d9ac6c 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.c
+++ b/src/gallium/drivers/svga/svga_sampler_view.c
@@ -32,6 +32,7 @@
 #include "util/u_format.h"
 #include "util/u_math.h"
 #include "util/u_memory.h"
+#include "util/u_string.h"
 
 #include "svga_screen.h"
 #include "svga_context.h"
@@ -41,6 +42,14 @@
 #include "svga_surface.h"
 
 
+void
+svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv)
+{
+   char res[128];
+   debug_describe_resource(res, sv->texture);
+   util_sprintf(buf, "svga_sampler_view<%s,[%u,%u]>", res, sv->min_lod, sv->max_lod);
+}
+
 struct svga_sampler_view *
 svga_get_tex_sampler_view(struct pipe_context *pipe,
 			  struct pipe_resource *pt,
@@ -114,6 +123,8 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
                pt->last_level);
       sv->key.cachable = 0;
       sv->handle = tex->handle;
+      debug_reference(&sv->reference,
+                      (debug_reference_descriptor)svga_debug_describe_sampler_view, 0);
       return sv;
    }
 
@@ -137,6 +148,8 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
       assert(0);
       sv->key.cachable = 0;
       sv->handle = tex->handle;
+      debug_reference(&sv->reference,
+                      (debug_reference_descriptor)svga_debug_describe_sampler_view, 0);
       return sv;
    }
 
@@ -144,6 +157,9 @@ svga_get_tex_sampler_view(struct pipe_context *pipe,
    svga_sampler_view_reference(&tex->cached_view, sv);
    pipe_mutex_unlock(ss->tex_mutex);
 
+   debug_reference(&sv->reference,
+                   (debug_reference_descriptor)svga_debug_describe_sampler_view, 0);
+
    return sv;
 }
 
diff --git a/src/gallium/drivers/svga/svga_sampler_view.h b/src/gallium/drivers/svga/svga_sampler_view.h
index e64665f..2087c1b 100644
--- a/src/gallium/drivers/svga/svga_sampler_view.h
+++ b/src/gallium/drivers/svga/svga_sampler_view.h
@@ -83,12 +83,16 @@ svga_validate_sampler_view(struct svga_context *svga, struct svga_sampler_view *
 void
 svga_destroy_sampler_view_priv(struct svga_sampler_view *v);
 
+void
+svga_debug_describe_sampler_view(char *buf, const struct svga_sampler_view *sv);
+
 static INLINE void
 svga_sampler_view_reference(struct svga_sampler_view **ptr, struct svga_sampler_view *v)
 {
    struct svga_sampler_view *old = *ptr;
 
-   if (pipe_reference(&(*ptr)->reference, &v->reference))
+   if (pipe_reference_described(&(*ptr)->reference, &v->reference, 
+                                (debug_reference_descriptor)svga_debug_describe_sampler_view))
       svga_destroy_sampler_view_priv(old);
    *ptr = v;
 }




More information about the mesa-commit mailing list