svga: use new svga_define_texture_level() helper
authorBrian Paul <brianp@vmware.com>
Mon, 24 Jun 2013 20:59:53 +0000 (14:59 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 25 Jun 2013 23:54:24 +0000 (17:54 -0600)
To get array bounds checking.

Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
src/gallium/drivers/svga/svga_resource_texture.c
src/gallium/drivers/svga/svga_resource_texture.h

index fd07ea1e3bc7a5107aea7c0734ac71f6ff83afc0..49509303553665eef78462ccd2a0ec7e0b175421 100644 (file)
@@ -364,9 +364,9 @@ svga_texture_transfer_unmap(struct pipe_context *pipe,
       ss->texture_timestamp++;
       svga_age_texture_view(tex, transfer->level);
       if (transfer->resource->target == PIPE_TEXTURE_CUBE)
-         tex->defined[transfer->box.z][transfer->level] = TRUE;
+         svga_define_texture_level(tex, transfer->box.z, transfer->level);
       else
-         tex->defined[0][transfer->level] = TRUE;
+         svga_define_texture_level(tex, 0, transfer->level);
    }
 
    FREE(st->swbuf);
index 58646f70de56be37182eeeef9d9190f5277d3372..7e2e61339e02ba457ee176f670a49f87929dcee3 100644 (file)
@@ -130,6 +130,19 @@ svga_age_texture_view(struct svga_texture *tex, unsigned level)
 }
 
 
+/**
+ * Mark the given texture face/level as being defined.
+ */
+static INLINE void
+svga_define_texture_level(struct svga_texture *tex,
+                          unsigned face,unsigned level)
+{
+   assert(face < Elements(tex->defined));
+   assert(level < Elements(tex->defined[0]));
+   tex->defined[face][level] = TRUE;
+}
+
+
 struct pipe_resource *
 svga_texture_create(struct pipe_screen *screen,
                     const struct pipe_resource *template);