Mesa (master): mesa: new glTexImage error checks for GL_ARB_texture_storage

Brian Paul brianp at kemper.freedesktop.org
Mon Oct 31 10:07:31 PDT 2011


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Oct 31 10:52:56 2011 -0600

mesa: new glTexImage error checks for GL_ARB_texture_storage

If the texture memory was allocated with glTexStorage1/2/3D() we can
only change the image data with glTexSubImage calls.

---

 src/mesa/main/teximage.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index acf7187..58b0e5d 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1433,6 +1433,23 @@ legal_texsubimage_target(struct gl_context *ctx, GLuint dims, GLenum target)
 
 
 /**
+ * Helper function to determine if a texture object is mutable (in terms
+ * of GL_ARB_texture_storage).
+ */
+static GLboolean
+mutable_tex_object(struct gl_context *ctx, GLenum target)
+{
+   if (ctx->Extensions.ARB_texture_storage) {
+      struct gl_texture_object *texObj =
+         _mesa_get_current_tex_object(ctx, target);
+      return !texObj->Immutable;
+   }
+   return GL_TRUE;
+}
+
+
+
+/**
  * Test the glTexImage[123]D() parameters for errors.
  * 
  * \param ctx GL context.
@@ -1643,6 +1660,12 @@ texture_error_check( struct gl_context *ctx,
       return GL_TRUE;
    }
 
+   if (!mutable_tex_object(ctx, target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glTexImage%dD(immutable texture)", dimensions);
+      return GL_TRUE;
+   }
+
    /* if we get here, the parameters are OK */
    return GL_FALSE;
 }
@@ -1906,6 +1929,12 @@ copytexture_error_check( struct gl_context *ctx, GLuint dimensions,
       }
    }
 
+   if (!mutable_tex_object(ctx, target)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCopyTexImage%dD(immutable texture)", dimensions);
+      return GL_TRUE;
+   }
+
    /* if we get here, the parameters are OK */
    return GL_FALSE;
 }
@@ -3107,6 +3136,11 @@ compressed_texture_error_check(struct gl_context *ctx, GLint dimensions,
       return GL_INVALID_VALUE;
    }
 
+   if (!mutable_tex_object(ctx, target)) {
+      *reason = "immutable texture";
+      return GL_INVALID_OPERATION;
+   }
+
    return GL_NO_ERROR;
 }
 



More information about the mesa-commit mailing list