Mesa (master): svga: use new svga_age_texture_view() helper

Brian Paul brianp at kemper.freedesktop.org
Tue Jun 25 23:57:03 UTC 2013


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Jun 24 14:44:08 2013 -0600

svga: use new svga_age_texture_view() helper

The function does array bounds checking.  Note, this exposes a
bug in the svga_mark_surface_dirty() function: we're calling
svga_age_texture_view() with a texture slice instead of mipmap
level.  This can lead to a failed assertion.  That'll be fixed next.

Reviewed-by: Jose Fonseca <jfonseca at vmware.com>

---

 src/gallium/drivers/svga/svga_resource_texture.c |    2 +-
 src/gallium/drivers/svga/svga_resource_texture.h |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index cb825b4..fd07ea1 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -362,7 +362,7 @@ svga_texture_transfer_unmap(struct pipe_context *pipe,
 
       svga_transfer_dma(svga, st, SVGA3D_WRITE_HOST_VRAM, flags);
       ss->texture_timestamp++;
-      tex->view_age[transfer->level] = ++(tex->age);
+      svga_age_texture_view(tex, transfer->level);
       if (transfer->resource->target == PIPE_TEXTURE_CUBE)
          tex->defined[transfer->box.z][transfer->level] = TRUE;
       else
diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index b3a1a6d..58646f7 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -30,6 +30,7 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
 #include "util/u_inlines.h"
+#include "util/u_memory.h"
 #include "util/u_transfer.h"
 #include "svga_screen_cache.h"
 
@@ -116,6 +117,18 @@ svga_transfer(struct pipe_transfer *transfer)
 }
 
 
+/**
+ * Increment the age of a view into a texture
+ * This is used to track updates to textures when we draw into
+ * them via a surface.
+ */
+static INLINE void
+svga_age_texture_view(struct svga_texture *tex, unsigned level)
+{
+   assert(level < Elements(tex->view_age));
+   tex->view_age[level] = ++(tex->age);
+}
+
 
 struct pipe_resource *
 svga_texture_create(struct pipe_screen *screen,




More information about the mesa-commit mailing list