[Mesa-dev] [PATCH 3/3] mesa: Fix glFramebufferTexture* error codes

Chad Versace chad at kiwitree.net
Thu Aug 11 17:11:30 UTC 2016


If check_textarget() determined that textarget was incorrect, it emitted
GL_INVALID_OPERATION.  This is the correct behavior when textarget is
a valid GLenum but an invalid parameter to the current variant of
glFramebufferTexture*().

However, when textarget is not a GLenum at all, then the GL spec
requires that GL_INVALID_ENUM be emitted.

Fixes test dEQP-GLES3.functional.negative_api.buffer.framebuffer_texture2d.

Cc: Haixia Shi <hshi at chromium.org>
Change-Id: I86c492f228720ec8cf9939e741cfc99a5d9fa1bc
---
 src/mesa/main/fbobject.c | 32 +++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 11 deletions(-)

diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index 2c01526..3360940 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -3029,20 +3029,30 @@ check_textarget(struct gl_context *ctx, int dims, GLenum target,
       err = true;
    }
 
-   if (err) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "%s(invalid textarget %s)",
-                  caller, _mesa_enum_to_string(textarget));
-      return false;
+   if (!err) {
+      /* Make sure textarget is consistent with the texture's type */
+      if (target == GL_TEXTURE_CUBE_MAP) {
+         err = !_mesa_is_cube_face(textarget);
+      } else {
+         err = (target != textarget);
+      }
    }
 
-   /* Make sure textarget is consistent with the texture's type */
-   err = (target == GL_TEXTURE_CUBE_MAP) ?
-          !_mesa_is_cube_face(textarget): (target != textarget);
-
    if (err) {
-      _mesa_error(ctx, GL_INVALID_OPERATION,
-                  "%s(mismatched texture target)", caller);
+      const char *enum_str;
+
+      if (_mesa_enum_to_string2(textarget, &enum_str)) {
+         /* The textarget is a valid GLenum, but is an invalid parameter to
+          * this variant of glFramebufferTexture*().
+          */
+         _mesa_error(ctx, GL_INVALID_OPERATION,
+                     "%s(mismatched texture target %s)", caller, enum_str);
+      } else {
+         /* The textarget is not a GLenum value. */
+         _mesa_error(ctx, GL_INVALID_ENUM,
+                     "%s(invalid textarget %s)", caller, enum_str);
+      }
+
       return false;
    }
 
-- 
2.9.2



More information about the mesa-dev mailing list