mesa: add missing texture integer test in glTexSubImage()
authorBrian Paul <brianp@vmware.com>
Wed, 15 Feb 2012 22:29:29 +0000 (15:29 -0700)
committerBrian Paul <brianp@vmware.com>
Thu, 16 Feb 2012 16:37:11 +0000 (09:37 -0700)
If the texture format is integer, the incoming user data must also be
integer (and similarly for non-integer textures).

NOTE: This is a candidate for the stable branches.

Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/teximage.c

index e4eb7f67d1f600a7bcfc06421efe436f7805f5ba..6acff240e456d8a61255717c8a6a31a7f9b4a8fe 100644 (file)
@@ -1852,6 +1852,17 @@ subtexture_error_check2( struct gl_context *ctx, GLuint dimensions,
       }         
    }
 
+   if (ctx->VersionMajor >= 3 || ctx->Extensions.EXT_texture_integer) {
+      /* both source and dest must be integer-valued, or neither */
+      if (_mesa_is_format_integer_color(destTex->TexFormat) !=
+          _mesa_is_integer_format(format)) {
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "glTexSubImage%dD(integer/non-integer format mismatch)",
+                     dimensions);
+         return GL_TRUE;
+      }
+   }
+
    return GL_FALSE;
 }