[Mesa-dev] [PATCH 2/5] mesa: Fix error checking for getters consisting of only API versions.

Eric Anholt eric at anholt.net
Wed Apr 10 12:01:11 PDT 2013


In almost all of our cases, getters that are turned on for only some API
variants will have an extension listed as one of the things that can
enable it, and thus api_check gets set.  For extra_gl30_es3 (used for
NUM_EXTENSIONS, MAJOR_VERSION, MINOR_VERSION) on a GL 2.1 context, though,
we would check twice, not find either one, but never actually throw the
error.
---
 src/mesa/main/get.c |   56 ++++++++++++++++++++++-----------------------------
 1 file changed, 24 insertions(+), 32 deletions(-)

diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 8214f33..c9bef8e 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -908,50 +908,43 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
    for (e = d->extra; *e != EXTRA_END; e++)
       switch (*e) {
       case EXTRA_VERSION_30:
-	 if (version >= 30) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (version >= 30)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_VERSION_31:
-	 if (version >= 31) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (version >= 31)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_VERSION_32:
-	 if (version >= 32) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (version >= 32)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_NEW_FRAG_CLAMP:
          if (ctx->NewState & (_NEW_BUFFERS | _NEW_FRAG_CLAMP))
             _mesa_update_state(ctx);
          break;
       case EXTRA_API_ES2:
-	 if (ctx->API == API_OPENGLES2) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (ctx->API == API_OPENGLES2)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_API_ES3:
-	 if (_mesa_is_gles3(ctx)) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (_mesa_is_gles3(ctx))
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_API_GL:
-	 if (_mesa_is_desktop_gl(ctx)) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (_mesa_is_desktop_gl(ctx))
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_API_GL_CORE:
-	 if (ctx->API == API_OPENGL_CORE) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (ctx->API == API_OPENGL_CORE)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_NEW_BUFFERS:
 	 if (ctx->NewState & _NEW_BUFFERS)
@@ -982,10 +975,9 @@ check_extra(struct gl_context *ctx, const char *func, const struct value_desc *d
 	 }
 	 break;
       case EXTRA_GLSL_130:
-	 if (ctx->Const.GLSLVersion >= 130) {
-	    api_check = GL_TRUE;
-	    api_found = GL_TRUE;
-	 }
+         api_check = GL_TRUE;
+         if (ctx->Const.GLSLVersion >= 130)
+            api_found = GL_TRUE;
 	 break;
       case EXTRA_END:
 	 break;
-- 
1.7.10.4



More information about the mesa-dev mailing list