summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2014-02-08 09:51:14 -0800
committerBrian Paul <brianp@vmware.com>2014-02-14 08:21:44 -0700
commitc1e60a61e8ca3bdac0530ad1aeb3c751f273b73d (patch)
treedff3b68daf708876c083820dec96a1b6cceb5ae1 /src
parentf84c830b144fd4d53f862fc6ad05541e5bf60a3b (diff)
downloadexternal_mesa3d-c1e60a61e8ca3bdac0530ad1aeb3c751f273b73d.zip
external_mesa3d-c1e60a61e8ca3bdac0530ad1aeb3c751f273b73d.tar.gz
external_mesa3d-c1e60a61e8ca3bdac0530ad1aeb3c751f273b73d.tar.bz2
svga: add helpers for tracking rendering to textures
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Cc: "10.1" <mesa-stable@lists.freedesktop.org>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.c9
-rw-r--r--src/gallium/drivers/svga/svga_resource_texture.h59
2 files changed, 68 insertions, 0 deletions
diff --git a/src/gallium/drivers/svga/svga_resource_texture.c b/src/gallium/drivers/svga/svga_resource_texture.c
index 05f56cb..6d5b4c5 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.c
+++ b/src/gallium/drivers/svga/svga_resource_texture.c
@@ -232,6 +232,7 @@ svga_texture_destroy(struct pipe_screen *screen,
ss->total_resource_bytes -= tex->size;
+ FREE(tex->rendered_to);
FREE(tex);
}
@@ -475,9 +476,15 @@ svga_texture_create(struct pipe_screen *screen,
tex->size = util_resource_size(template);
svgascreen->total_resource_bytes += tex->size;
+ tex->rendered_to = CALLOC(template->depth0 * template->array_size,
+ sizeof(tex->rendered_to[0]));
+ if (!tex->rendered_to)
+ goto error2;
+
return &tex->b.b;
error2:
+ FREE(tex->rendered_to);
FREE(tex);
error1:
return NULL;
@@ -536,5 +543,7 @@ svga_texture_from_handle(struct pipe_screen *screen,
tex->key.cachable = 0;
tex->handle = srf;
+ tex->rendered_to = CALLOC(1, sizeof(tex->rendered_to[0]));
+
return &tex->b.b;
}
diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h
index 7e2e613..0602fa0 100644
--- a/src/gallium/drivers/svga/svga_resource_texture.h
+++ b/src/gallium/drivers/svga/svga_resource_texture.h
@@ -78,6 +78,9 @@ struct svga_texture
struct svga_winsys_surface *handle;
unsigned size; /**< Approximate size in bytes */
+
+ /** array indexed by cube face or 3D/array slice, one bit per mipmap level */
+ ushort *rendered_to;
};
@@ -143,6 +146,62 @@ svga_define_texture_level(struct svga_texture *tex,
}
+static INLINE bool
+svga_is_texture_level_defined(const struct svga_texture *tex,
+ unsigned face, unsigned level)
+{
+ assert(face < Elements(tex->defined));
+ assert(level < Elements(tex->defined[0]));
+ return tex->defined[face][level];
+}
+
+
+/** For debugging, check that face and level are legal */
+static inline void
+check_face_level(const struct svga_texture *tex,
+ unsigned face, unsigned level)
+{
+ if (tex->b.b.target == PIPE_TEXTURE_CUBE) {
+ assert(face < 6);
+ }
+ else if (tex->b.b.target == PIPE_TEXTURE_3D) {
+ assert(face < tex->b.b.depth0);
+ }
+ else {
+ assert(face < tex->b.b.array_size);
+ }
+
+ assert(level < 8 * sizeof(tex->rendered_to[0]));
+}
+
+
+static INLINE void
+svga_set_texture_rendered_to(struct svga_texture *tex,
+ unsigned face, unsigned level)
+{
+ check_face_level(tex, face, level);
+ tex->rendered_to[face] |= 1 << level;
+}
+
+
+static INLINE void
+svga_clear_texture_rendered_to(struct svga_texture *tex,
+ unsigned face, unsigned level)
+{
+ check_face_level(tex, face, level);
+ tex->rendered_to[face] &= ~(1 << level);
+}
+
+
+static INLINE boolean
+svga_was_texture_rendered_to(const struct svga_texture *tex,
+ unsigned face, unsigned level)
+{
+ check_face_level(tex, face, level);
+ return !!(tex->rendered_to[face] & (1 << level));
+}
+
+
struct pipe_resource *
svga_texture_create(struct pipe_screen *screen,
const struct pipe_resource *template);