[Mesa-dev] [PATCH 2/3] mesa/es: Validate glGetProgramiv pnames in Mesa code rather than the ES wrapper
Ian Romanick
idr at freedesktop.org
Tue Aug 21 17:09:12 PDT 2012
From: Ian Romanick <ian.d.romanick at intel.com>
v2: Add proper core-profile and GLES3 filtering.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/main/APIspec.xml | 15 ---------------
src/mesa/main/shaderapi.c | 39 +++++++++++++++++++++++++++++++--------
2 files changed, 31 insertions(+), 23 deletions(-)
diff --git a/src/mesa/main/APIspec.xml b/src/mesa/main/APIspec.xml
index 8b5ad03..7efca4d 100644
--- a/src/mesa/main/APIspec.xml
+++ b/src/mesa/main/APIspec.xml
@@ -1839,21 +1839,6 @@
<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">
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 9ecd7c6..4d34507 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -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) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
return;
}
@@ -575,7 +598,7 @@ get_programiv(struct gl_context *ctx, GLuint program, GLenum pname, GLint *param
break;
}
case GL_ACTIVE_UNIFORM_BLOCKS:
- if (!ctx->Extensions.ARB_uniform_buffer_object) {
+ if (!has_ubo) {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramiv(pname)");
return;
}
--
1.7.6.5
More information about the mesa-dev
mailing list