+/**
+ * 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);
+}
+
+
+/**
+ * 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;
+}
+
+
+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));
+}
+