mesa: Filter glGetProgramiv pnames based on available extensions
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 03:06:25 +0000 (20:06 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 24 Aug 2012 16:06:31 +0000 (09:06 -0700)
Previously you could always glGetProgramiv one of the transform feedback
or geometry shader enums even if the extension wasn't supported.

In addtion, this reverts part of bda6ad27.  I think the hunks involving
GL_PROGRAM_BINARY_LENGTH_OES were spurious.  Mesa has no support for any
other part of GL_OES_get_program_binary.

v2: Remove redundant return in get_programiv based on review feedback
from Matt Turner.

v3: Correctly handle UBO related enums.

v4: Emit the bad enum in the _mesa_error call based on review feedback
from Brian Paul.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/mesa/main/shaderapi.c

index caeb9657e4ca50f78917a8b3ddde6bd44df24f6e..612c1fc64c20e013d2dfa6cd2494414697fb5a80 100644 (file)
@@ -481,28 +481,28 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
    switch (pname) {
    case GL_DELETE_STATUS:
       *params = shProg->DeletePending;
-      break; 
+      return;
    case GL_LINK_STATUS:
       *params = shProg->LinkStatus;
-      break;
+      return;
    case GL_VALIDATE_STATUS:
       *params = shProg->Validated;
-      break;
+      return;
    case GL_INFO_LOG_LENGTH:
       *params = shProg->InfoLog ? strlen(shProg->InfoLog) + 1 : 0;
-      break;
+      return;
    case GL_ATTACHED_SHADERS:
       *params = shProg->NumShaders;
-      break;
+      return;
    case GL_ACTIVE_ATTRIBUTES:
       *params = _mesa_count_active_attribs(shProg);
-      break;
+      return;
    case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH:
       *params = _mesa_longest_attribute_name_length(shProg);
-      break;
+      return;
    case GL_ACTIVE_UNIFORMS:
       *params = shProg->NumUserUniformStorage;
-      break;
+      return;
    case GL_ACTIVE_UNIFORM_MAX_LENGTH: {
       unsigned i;
       GLint max_len = 0;
@@ -517,41 +517,48 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       }
 
       *params = max_len;
-      break;
+      return;
    }
-   case GL_PROGRAM_BINARY_LENGTH_OES:
-      *params = 0;
-      break;
 #if FEATURE_EXT_transform_feedback
    case GL_TRANSFORM_FEEDBACK_VARYINGS:
+      if (!ctx->Extensions.EXT_transform_feedback)
+         break;
       *params = shProg->TransformFeedback.NumVarying;
-      break;
+      return;
    case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
+      if (!ctx->Extensions.EXT_transform_feedback)
+         break;
       *params = longest_feedback_varying_name(shProg) + 1;
-      break;
+      return;
    case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
+      if (!ctx->Extensions.EXT_transform_feedback)
+         break;
       *params = shProg->TransformFeedback.BufferMode;
-      break;
+      return;
 #endif
 #if FEATURE_ARB_geometry_shader4
    case GL_GEOMETRY_VERTICES_OUT_ARB:
+      if (!ctx->Extensions.ARB_geometry_shader4)
+         break;
       *params = shProg->Geom.VerticesOut;
-      break;
+      return;
    case GL_GEOMETRY_INPUT_TYPE_ARB:
+      if (!ctx->Extensions.ARB_geometry_shader4)
+         break;
       *params = shProg->Geom.InputType;
-      break;
+      return;
    case GL_GEOMETRY_OUTPUT_TYPE_ARB:
+      if (!ctx->Extensions.ARB_geometry_shader4)
+         break;
       *params = shProg->Geom.OutputType;
-      break;
+      return;
 #endif
    case GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH: {
       unsigned i;
       GLint max_len = 0;
 
-      if (!ctx->Extensions.ARB_uniform_buffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
-         return;
-      }
+      if (!ctx->Extensions.ARB_uniform_buffer_object)
+         break;
 
       for (i = 0; i < shProg->NumUniformBlocks; i++) {
         /* Add one for the terminating NUL character.
@@ -563,20 +570,20 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       }
 
       *params = max_len;
-      break;
+      return;
    }
    case GL_ACTIVE_UNIFORM_BLOCKS:
-      if (!ctx->Extensions.ARB_uniform_buffer_object) {
-         _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
-         return;
-      }
+      if (!ctx->Extensions.ARB_uniform_buffer_object)
+         break;
 
       *params = shProg->NumUniformBlocks;
-      break;
-   default:
-      _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
       return;
+   default:
+      break;
    }
+
+   _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname=%s)",
+               _mesa_lookup_enum_by_nr(pname));
 }