Mesa (master): mesa/main: Add functions to clear and dirty texture objects.

Brian Paul brianp at kemper.freedesktop.org
Wed Aug 5 22:09:33 UTC 2009


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

Author: Chia-I Wu <olvaffe at gmail.com>
Date:   Wed Aug  5 16:06:50 2009 -0600

mesa/main: Add functions to clear and dirty texture objects.

This commit adds a function to clear a texture object such that there is
no image data associated with it, and a function to dirty it so that it
will be re-tested for completeness.

Signed-off-by: Chia-I Wu <olvaffe at gmail.com>

---

 src/mesa/main/teximage.c |   17 +++++++++++++++++
 src/mesa/main/teximage.h |    4 ++++
 src/mesa/main/texobj.c   |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 src/mesa/main/texobj.h   |    8 +++++++-
 4 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 3549b68..83f025f 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1219,6 +1219,23 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
 
 
 /**
+ * Free and clear fields of the gl_texture_image struct.
+ *
+ * \param ctx GL context.
+ * \param texImage texture image structure to be cleared.
+ *
+ * After the call, \p texImage will have no data associated with it.  Its
+ * fields are cleared so that its parent object will test incomplete.
+ */
+void
+_mesa_clear_texture_image(GLcontext *ctx, struct gl_texture_image *texImage)
+{
+   ctx->Driver.FreeTexImageData(ctx, texImage);
+   clear_teximage_fields(texImage);
+}
+
+
+/**
  * This is the fallback for Driver.TestProxyTexImage().  Test the texture
  * level, width, height and depth against the ctx->Const limits for textures.
  *
diff --git a/src/mesa/main/teximage.h b/src/mesa/main/teximage.h
index eb60a1f..b0d7c1c 100644
--- a/src/mesa/main/teximage.h
+++ b/src/mesa/main/teximage.h
@@ -73,6 +73,10 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
 
 
 extern void
+_mesa_clear_texture_image(GLcontext *ctx, struct gl_texture_image *texImage);
+
+
+extern void
 _mesa_set_tex_image(struct gl_texture_object *tObj,
                     GLenum target, GLint level,
                     struct gl_texture_image *texImage);
diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c
index 2082f94..9a7773d 100644
--- a/src/mesa/main/texobj.c
+++ b/src/mesa/main/texobj.c
@@ -261,6 +261,32 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
 
 
 /**
+ * Clear all texture images of the given texture object.
+ *
+ * \param ctx GL context.
+ * \param t texture object.
+ *
+ * \sa _mesa_clear_texture_image().
+ */
+void
+_mesa_clear_texture_object(GLcontext *ctx, struct gl_texture_object *texObj)
+{
+   GLuint i, j;
+
+   if (texObj->Target == 0)
+      return;
+
+   for (i = 0; i < MAX_FACES; i++) {
+      for (j = 0; j < MAX_TEXTURE_LEVELS; j++) {
+         struct gl_texture_image *texImage = texObj->Image[i][j];
+         if (texImage)
+            _mesa_clear_texture_image(ctx, texImage);
+      }
+   }
+}
+
+
+/**
  * Check if the given texture object is valid by examining its Target field.
  * For debugging only.
  */
@@ -665,6 +691,24 @@ _mesa_test_texobj_completeness( const GLcontext *ctx,
 
 
 /**
+ * Mark a texture object dirty.  It forces the object to be incomplete
+ * and optionally forces the context to re-validate its state.
+ *
+ * \param ctx GL context.
+ * \param texObj texture object.
+ * \param invalidate_state also invalidate context state.
+ */
+void
+_mesa_dirty_texobj(GLcontext *ctx, struct gl_texture_object *texObj,
+                   GLboolean invalidate_state)
+{
+   texObj->_Complete = GL_FALSE;
+   if (invalidate_state)
+      ctx->NewState |= _NEW_TEXTURE;
+}
+
+
+/**
  * Return pointer to a default/fallback texture.
  * The texture is a 2D 8x8 RGBA texture with all texels = (0,0,0,1).
  * That's the value a sampler should get when sampling from an
@@ -715,7 +759,6 @@ _mesa_get_fallback_texture(GLcontext *ctx)
 }
 
 
-
 /*@}*/
 
 
diff --git a/src/mesa/main/texobj.h b/src/mesa/main/texobj.h
index 2599c08..9bfebd4 100644
--- a/src/mesa/main/texobj.h
+++ b/src/mesa/main/texobj.h
@@ -58,6 +58,9 @@ _mesa_copy_texture_object( struct gl_texture_object *dest,
                            const struct gl_texture_object *src );
 
 extern void
+_mesa_clear_texture_object(GLcontext *ctx, struct gl_texture_object *obj);
+
+extern void
 _mesa_reference_texobj(struct gl_texture_object **ptr,
                        struct gl_texture_object *tex);
 
@@ -65,6 +68,10 @@ extern void
 _mesa_test_texobj_completeness( const GLcontext *ctx,
                                 struct gl_texture_object *obj );
 
+extern void
+_mesa_dirty_texobj(GLcontext *ctx, struct gl_texture_object *texObj,
+                   GLboolean invalidate_state);
+
 extern struct gl_texture_object *
 _mesa_get_fallback_texture(GLcontext *ctx);
 
@@ -76,7 +83,6 @@ _mesa_lock_context_textures( GLcontext *ctx );
 
 /*@}*/
 
-
 /**
  * \name API functions
  */




More information about the mesa-commit mailing list