mesa/es: Validate glGetProgramiv pnames in Mesa code rather than the ES wrapper
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 25 Jul 2012 03:13:39 +0000 (20:13 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 24 Aug 2012 16:06:31 +0000 (09:06 -0700)
v2: Add proper core-profile and GLES3 filtering.

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

index 8b5ad0330ef7cbe0fcfa75c29501e90e33ac59c1..7efca4d1b3e4d124ad8226f3d481c3a76cca98ba 100644 (file)
                <param name="pname" type="GLenum"/>
                <vector name="params" type="GLtype *" size="dynamic"/>
        </proto>
-
-       <desc name="pname">
-               <value name="GL_DELETE_STATUS"/>
-               <value name="GL_LINK_STATUS"/>
-               <value name="GL_VALIDATE_STATUS"/>
-               <value name="GL_INFO_LOG_LENGTH"/>
-               <value name="GL_ATTACHED_SHADERS"/>
-               <value name="GL_ACTIVE_ATTRIBUTES"/>
-               <value name="GL_ACTIVE_ATTRIBUTE_MAX_LENGTH"/>
-               <value name="GL_ACTIVE_UNIFORMS"/>
-               <value name="GL_ACTIVE_UNIFORM_MAX_LENGTH"/>
-               <value name="GL_PROGRAM_BINARY_LENGTH_OES" category="OES_get_program_binary"/>
-
-               <desc name="params" convert="false"/>
-       </desc>
 </template>
 
 <template name="GetVertexAttrib" direction="get">
index 612c1fc64c20e013d2dfa6cd2494414697fb5a80..0049e87e1d29bb313e9b19249ce9198acdc3836a 100644 (file)
@@ -473,6 +473,29 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
    struct gl_shader_program *shProg
       = _mesa_lookup_shader_program(ctx, program);
 
+#if FEATURE_EXT_transform_feedback
+   /* Is transform feedback available in this context?
+    */
+   const bool has_xfb =
+      (ctx->API == API_OPENGL && ctx->Extensions.EXT_transform_feedback)
+      || ctx->API == API_OPENGL_CORE
+      || _mesa_is_gles3(ctx);
+#endif
+
+#if FEATURE_ARB_geometry_shader4
+   /* Are geometry shaders available in this context?
+    */
+   const bool has_gs =
+      _mesa_is_desktop_gl(ctx) && ctx->Extensions.ARB_geometry_shader4;
+#endif
+
+   /* Are uniform buffer objects available in this context?
+    */
+   const bool has_ubo =
+      (ctx->API == API_OPENGL && ctx->Extensions.ARB_uniform_buffer_object)
+      || ctx->API == API_OPENGL_CORE
+      || _mesa_is_gles3(ctx);
+
    if (!shProg) {
       _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramiv(program)");
       return;
@@ -521,34 +544,34 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
    }
 #if FEATURE_EXT_transform_feedback
    case GL_TRANSFORM_FEEDBACK_VARYINGS:
-      if (!ctx->Extensions.EXT_transform_feedback)
+      if (!has_xfb)
          break;
       *params = shProg->TransformFeedback.NumVarying;
       return;
    case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
-      if (!ctx->Extensions.EXT_transform_feedback)
+      if (!has_xfb)
          break;
       *params = longest_feedback_varying_name(shProg) + 1;
       return;
    case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
-      if (!ctx->Extensions.EXT_transform_feedback)
+      if (!has_xfb)
          break;
       *params = shProg->TransformFeedback.BufferMode;
       return;
 #endif
 #if FEATURE_ARB_geometry_shader4
    case GL_GEOMETRY_VERTICES_OUT_ARB:
-      if (!ctx->Extensions.ARB_geometry_shader4)
+      if (!has_gs)
          break;
       *params = shProg->Geom.VerticesOut;
       return;
    case GL_GEOMETRY_INPUT_TYPE_ARB:
-      if (!ctx->Extensions.ARB_geometry_shader4)
+      if (!has_gs)
          break;
       *params = shProg->Geom.InputType;
       return;
    case GL_GEOMETRY_OUTPUT_TYPE_ARB:
-      if (!ctx->Extensions.ARB_geometry_shader4)
+      if (!has_gs)
          break;
       *params = shProg->Geom.OutputType;
       return;
@@ -557,7 +580,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       unsigned i;
       GLint max_len = 0;
 
-      if (!ctx->Extensions.ARB_uniform_buffer_object)
+      if (!has_ubo)
          break;
 
       for (i = 0; i < shProg->NumUniformBlocks; i++) {
@@ -573,7 +596,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
       return;
    }
    case GL_ACTIVE_UNIFORM_BLOCKS:
-      if (!ctx->Extensions.ARB_uniform_buffer_object)
+      if (!has_ubo)
          break;
 
       *params = shProg->NumUniformBlocks;