<div dir="ltr">CC: 10.4, 10.5<br><br><div><div class="gmail_quote">---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Laura Ekstrand</b> <span dir="ltr"><<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>></span><br>Date: Wed, Feb 25, 2015 at 6:04 PM<br>Subject: [PATCH] main: Fix target checking for CopyTexSubImage*D.<br>To: <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>Cc: Laura Ekstrand <<a href="mailto:laura@jlekstrand.net">laura@jlekstrand.net</a>><br><br><br>This fixes a dEQP test failure. In the test,<br>
glCopyTexSubImage2D was called with target = 0 and failed to throw<br>
INVALID ENUM. This failure was caused by _mesa_get_current_tex_object(ctx,<br>
target) being called before the target checking. To remedy this, target<br>
checking was separated from the main error-checking function and<br>
called prior to _mesa_get_current_tex_object.<br>
<br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=89312" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=89312</a><br>
---<br>
src/mesa/main/teximage.c | 62 +++++++++++++++++++++++++++++++++++++++++-------<br>
1 file changed, 54 insertions(+), 8 deletions(-)<br>
<br>
diff --git a/src/mesa/main/teximage.c b/src/mesa/main/teximage.c<br>
index 87231df..475dc54 100644<br>
--- a/src/mesa/main/teximage.c<br>
+++ b/src/mesa/main/teximage.c<br>
@@ -2815,14 +2815,6 @@ copytexsubimage_error_check(struct gl_context *ctx, GLuint dimensions,<br>
}<br>
}<br>
<br>
- /* check target (proxies not allowed) */<br>
- if (!legal_texsubimage_target(ctx, dimensions, target, dsa)) {<br>
- _mesa_error(ctx, GL_INVALID_ENUM, "glCopyTex%sSubImage%uD(target=%s)",<br>
- suffix, dimensions,<br>
- _mesa_lookup_enum_by_nr(target));<br>
- return GL_TRUE;<br>
- }<br>
-<br>
/* Check level */<br>
if (level < 0 || level >= _mesa_max_texture_levels(ctx, target)) {<br>
_mesa_error(ctx, GL_INVALID_VALUE,<br>
@@ -4090,6 +4082,16 @@ _mesa_CopyTexSubImage1D( GLenum target, GLint level,<br>
struct gl_texture_object* texObj;<br>
GET_CURRENT_CONTEXT(ctx);<br>
<br>
+ /* Check target (proxies not allowed). Target must be checked prior to<br>
+ * calling _mesa_get_current_tex_object.<br>
+ */<br>
+ if (!legal_texsubimage_target(ctx, 1, target, false)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTexSubImage1D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(target));<br>
+ return;<br>
+ }<br>
+<br>
texObj = _mesa_get_current_tex_object(ctx, target);<br>
if (!texObj)<br>
return;<br>
@@ -4108,6 +4110,16 @@ _mesa_CopyTexSubImage2D( GLenum target, GLint level,<br>
struct gl_texture_object* texObj;<br>
GET_CURRENT_CONTEXT(ctx);<br>
<br>
+ /* Check target (proxies not allowed). Target must be checked prior to<br>
+ * calling _mesa_get_current_tex_object.<br>
+ */<br>
+ if (!legal_texsubimage_target(ctx, 2, target, false)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTexSubImage2D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(target));<br>
+ return;<br>
+ }<br>
+<br>
texObj = _mesa_get_current_tex_object(ctx, target);<br>
if (!texObj)<br>
return;<br>
@@ -4127,6 +4139,16 @@ _mesa_CopyTexSubImage3D( GLenum target, GLint level,<br>
struct gl_texture_object* texObj;<br>
GET_CURRENT_CONTEXT(ctx);<br>
<br>
+ /* Check target (proxies not allowed). Target must be checked prior to<br>
+ * calling _mesa_get_current_tex_object.<br>
+ */<br>
+ if (!legal_texsubimage_target(ctx, 3, target, false)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTexSubImage3D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(target));<br>
+ return;<br>
+ }<br>
+<br>
texObj = _mesa_get_current_tex_object(ctx, target);<br>
if (!texObj)<br>
return;<br>
@@ -4147,6 +4169,14 @@ _mesa_CopyTextureSubImage1D(GLuint texture, GLint level,<br>
if (!texObj)<br>
return;<br>
<br>
+ /* Check target (proxies not allowed). */<br>
+ if (!legal_texsubimage_target(ctx, 1, texObj->Target, true)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTextureSubImage1D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(texObj->Target));<br>
+ return;<br>
+ }<br>
+<br>
_mesa_copy_texture_sub_image(ctx, 1, texObj, texObj->Target, level,<br>
xoffset, 0, 0, x, y, width, 1, true);<br>
}<br>
@@ -4163,6 +4193,14 @@ _mesa_CopyTextureSubImage2D(GLuint texture, GLint level,<br>
if (!texObj)<br>
return;<br>
<br>
+ /* Check target (proxies not allowed). */<br>
+ if (!legal_texsubimage_target(ctx, 2, texObj->Target, true)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTextureSubImage2D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(texObj->Target));<br>
+ return;<br>
+ }<br>
+<br>
_mesa_copy_texture_sub_image(ctx, 2, texObj, texObj->Target, level,<br>
xoffset, yoffset, 0,<br>
x, y, width, height, true);<br>
@@ -4182,6 +4220,14 @@ _mesa_CopyTextureSubImage3D(GLuint texture, GLint level,<br>
if (!texObj)<br>
return;<br>
<br>
+ /* Check target (proxies not allowed). */<br>
+ if (!legal_texsubimage_target(ctx, 3, texObj->Target, true)) {<br>
+ _mesa_error(ctx, GL_INVALID_ENUM,<br>
+ "glCopyTextureSubImage3D(invalid target %s)",<br>
+ _mesa_lookup_enum_by_nr(texObj->Target));<br>
+ return;<br>
+ }<br>
+<br>
_mesa_copy_texture_sub_image(ctx, 3, texObj, texObj->Target, level,<br>
xoffset, yoffset, zoffset,<br>
x, y, width, height, true);<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.1.0<br>
<br>
</font></span></div><br></div></div>