Mesa (master): main: Fix target checking for CopyTexSubImage*D.
Laura Ekstrand
ldeks at kemper.freedesktop.org
Thu Feb 26 21:32:49 UTC 2015
Module: Mesa
Branch: master
Commit: ca65764d6042d2ea220a1e3952490f79c226f3e0
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=ca65764d6042d2ea220a1e3952490f79c226f3e0
Author: Laura Ekstrand <laura at jlekstrand.net>
Date: Wed Feb 25 15:45:47 2015 -0800
main: Fix target checking for CopyTexSubImage*D.
This fixes a dEQP test failure. In the test,
glCopyTexSubImage2D was called with target = 0 and failed to throw
INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx,
target) being called before the target checking. To remedy this, target
checking was separated from the main error-checking function and
called prior to _mesa_get_current_tex_object.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89312
Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>
---
src/mesa/main/teximage.c | 62 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 54 insertions(+), 8 deletions(-)
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c
index 81a3f15..9b11fc0 100644
--- a/src/mesa/main/teximage.c
+++ b/src/mesa/main/teximage.c
@@ -2837,14 +2837,6 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,
}
}
- /* check target (proxies not allowed) */
- if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {
- _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTex%sSubImage%uD(target=%s)",
- suffix, dimensions,
- _mesa_lookup_enum_by_nr(target));
- return GL_TRUE;
- }
-
/* Check level */
if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {
_mesa_error(ctx, GL_INVALID_VALUE,
@@ -4110,6 +4102,16 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 1, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage1D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4128,6 +4130,16 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 2, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage2D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4147,6 +4159,16 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,
struct gl_texture_object* texObj;
GET_CURRENT_CONTEXT(ctx);
+ /* Check target (proxies not allowed). Target must be checked prior to
+ * calling _mesa_get_current_tex_object.
+ */
+ if (!legal_texsubimage_target(ctx, 3, target, false)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTexSubImage3D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(target));
+ return;
+ }
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
return;
@@ -4167,6 +4189,14 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage1D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level,
xoffset, 0, 0, x, y, width, 1, true);
}
@@ -4183,6 +4213,14 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage2D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level,
xoffset, yoffset, 0,
x, y, width, height, true);
@@ -4202,6 +4240,14 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,
if (!texObj)
return;
+ /* Check target (proxies not allowed). */
+ if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) {
+ _mesa_error(ctx, GL_INVALID_ENUM,
+ "glCopyTextureSubImage3D(invalid target %s)",
+ _mesa_lookup_enum_by_nr(texObj->Target));
+ return;
+ }
+
_mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level,
xoffset, yoffset, zoffset,
x, y, width, height, true);
More information about the mesa-commit
mailing list