teximage: ensure that Tex*SubImage* checks format
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 2 Sep 2019 22:50:01 +0000 (18:50 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Wed, 4 Sep 2019 04:35:45 +0000 (00:35 -0400)
We were previously not doing at least some of the checks. This uses the
same logic that is used in glTexImage*.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/main/teximage.c

index f90765f40fa4a6c5f8b90e8f23eff35173a00343..e55e435779f97d1584fd8de595f41a2d269e37dd 100644 (file)
@@ -2205,6 +2205,15 @@ texsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
       return GL_TRUE;
    }
 
+   if (!texture_formats_agree(texImage->InternalFormat, format)) {
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "%s(incompatible internalFormat = %s, format = %s)",
+                  callerName,
+                  _mesa_enum_to_string(texImage->InternalFormat),
+                  _mesa_enum_to_string(format));
+      return GL_TRUE;
+   }
+
    GLenum internalFormat = _mesa_is_gles(ctx) ?
       oes_float_internal_format(ctx, texImage->InternalFormat, type) :
       texImage->InternalFormat;