Mesa (master): mesa: additional teximage error checks for GL_EXT_texture_integer

Brian Paul brianp at kemper.freedesktop.org
Tue Oct 26 01:22:47 UTC 2010


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

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Oct 25 19:08:55 2010 -0600

mesa: additional teximage error checks for GL_EXT_texture_integer

---

 src/mesa/main/teximage.c |   42 ++++++++++++++++++++++++++++++++++++++----
 1 files changed, 38 insertions(+), 4 deletions(-)

diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index b31c579..b65a2de 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -1402,11 +1402,15 @@ texture_error_check( struct gl_context *ctx, GLenum target,
 
    /* Check incoming image format and type */
    if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
-      /* Yes, generate GL_INVALID_OPERATION, not GL_INVALID_ENUM, if there
-       * is a type/format mismatch.  See 1.2 spec page 94, sec 3.6.4.
+      /* Normally, GL_INVALID_OPERATION is generated by a format/type
+       * mismatch (see the 1.2 spec page 94, sec 3.6.4.).  But with the
+       * GL_EXT_texture_integer extension, some combinations should generate
+       * GL_INVALID_ENUM instead (grr!).
        */
       if (!isProxy) {
-         _mesa_error(ctx, GL_INVALID_OPERATION,
+         GLenum error = _mesa_is_integer_format(format)
+            ? GL_INVALID_ENUM : GL_INVALID_OPERATION;
+         _mesa_error(ctx, error,
                      "glTexImage%dD(incompatible format 0x%x, type 0x%x)",
                      dimensions, format, type);
       }
@@ -1492,6 +1496,18 @@ texture_error_check( struct gl_context *ctx, GLenum target,
       }
    }
 
+   /* additional checks for integer textures */
+   if (ctx->Extensions.EXT_texture_integer &&
+       (_mesa_is_integer_format(format) !=
+        _mesa_is_integer_format(internalFormat))) {
+      if (!isProxy) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glTexImage%dD(integer/non-integer format mismatch)",
+                     dimensions);
+      }
+      return GL_TRUE;
+   }
+
    /* if we get here, the parameters are OK */
    return GL_FALSE;
 }
@@ -1598,7 +1614,12 @@ subtexture_error_check( struct gl_context *ctx, GLuint dimensions,
    }
 
    if (!_mesa_is_legal_format_and_type(ctx, format, type)) {
-      _mesa_error(ctx, GL_INVALID_ENUM,
+      /* As with the glTexImage2D check above, the error code here
+       * depends on texture integer.
+       */
+      GLenum error = _mesa_is_integer_format(format)
+         ? GL_INVALID_OPERATION : GL_INVALID_ENUM;
+      _mesa_error(ctx, error,
                   "glTexSubImage%dD(incompatible format 0x%x, type 0x%x)",
                   dimensions, format, type);
       return GL_TRUE;
@@ -2083,6 +2104,19 @@ copytexsubimage_error_check2( struct gl_context *ctx, GLuint dimensions,
       }
    }
 
+   /* If copying into an integer texture, the source buffer must also be
+    * integer-valued.
+    */
+   if (_mesa_is_format_integer(teximage->TexFormat)) {
+      struct gl_renderbuffer *rb = ctx->ReadBuffer->_ColorReadBuffer;
+      if (!_mesa_is_format_integer(rb->Format)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glCopyTexSubImage%dD(source buffer is not integer format)",
+                  dimensions);
+         return GL_TRUE;
+      }
+   }
+
    /* if we get here, the parameters are OK */
    return GL_FALSE;
 }




More information about the mesa-commit mailing list