svga: use new svga_age_texture_view() helper
authorBrian Paul <brianp@vmware.com>
Mon, 24 Jun 2013 20:44:08 +0000 (14:44 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 25 Jun 2013 23:54:24 +0000 (17:54 -0600)
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@vmware.com>
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_resource_texture.h

index cb825b4120623e746b1782991b3e18ec3fb9ceb8..fd07ea1e3bc7a5107aea7c0734ac71f6ff83afc0 100644 (file)
@@ -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
index b3a1a6d52f5530ba89d7cca32875503a2dbd897b..58646f70de56be37182eeeef9d9190f5277d3372 100644 (file)
@@ -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,