mesa: Don't set shaderapi dispatch pointers for many things in ES2 or core
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 5 Sep 2012 21:14:13 +0000 (14:14 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 28 Sep 2012 15:19:54 +0000 (08:19 -0700)
v2: Allow GL_ARB_shader_objects functions in core profile because we
still expose the extension string there.  Don't allow
glBindFragDataLocation in GLES3 because it's not part of that API.
Based (mostly) on review comments from Eric Anholt.

NOTE: This is a candidate for the 9.0 branch

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/mesa/main/api_exec.c
src/mesa/main/dlist.c
src/mesa/main/shaderapi.c
src/mesa/main/shaderapi.h

index 87ec0f240c07e8d2b5849ab8f8cb7465402669f4..f9a45d436ef88f4e0c89e33eec8970aea0d2ec7d 100644 (file)
@@ -364,7 +364,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    SET_StencilMaskSeparate(exec, _mesa_StencilMaskSeparate);
    SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate);
 
-   _mesa_init_shader_dispatch(exec);
+   _mesa_init_shader_dispatch(ctx, exec);
    _mesa_init_shader_uniform_dispatch(exec);
 
    /* 2. GL_EXT_blend_color */
index d815286c9fd3e98806b90a2ff926cdaf957c2007..99519120a9f4aa8d7eb50d37f27701e7251644fb 100644 (file)
@@ -10410,7 +10410,7 @@ _mesa_create_save_table(const struct gl_context *ctx)
    SET_BlitFramebufferEXT(table, save_BlitFramebufferEXT);
 
    /* GL_ARB_shader_objects */
-   _mesa_init_shader_dispatch(table); /* Plug in glCreate/Delete/Get, etc */
+   _mesa_init_shader_dispatch(ctx, table); /* Plug in glCreate/Delete/Get, etc */
    SET_UseProgramObjectARB(table, save_UseProgramObjectARB);
    SET_Uniform1fARB(table, save_Uniform1fARB);
    SET_Uniform2fARB(table, save_Uniform2fARB);
index 2690279d5256c1b6c41b64ef72fcf982314e0384..6ee41f2b63e76e1a0f435d8d94ab3b92617d8f4e 100644 (file)
@@ -1686,25 +1686,29 @@ _mesa_CreateShaderProgramEXT(GLenum type, const GLchar *string)
  * Plug in shader-related functions into API dispatch table.
  */
 void
-_mesa_init_shader_dispatch(struct _glapi_table *exec)
+_mesa_init_shader_dispatch(const struct gl_context *ctx,
+                           struct _glapi_table *exec)
 {
 #if FEATURE_GL
    /* GL_ARB_vertex/fragment_shader */
-   SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB);
-   SET_GetHandleARB(exec, _mesa_GetHandleARB);
-   SET_DetachObjectARB(exec, _mesa_DetachObjectARB);
-   SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB);
+   if (ctx->API != API_OPENGLES2) {
+      SET_DeleteObjectARB(exec, _mesa_DeleteObjectARB);
+      SET_GetHandleARB(exec, _mesa_GetHandleARB);
+      SET_DetachObjectARB(exec, _mesa_DetachObjectARB);
+      SET_CreateShaderObjectARB(exec, _mesa_CreateShaderObjectARB);
+      SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB);
+      SET_AttachObjectARB(exec, _mesa_AttachObjectARB);
+      SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB);
+      SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB);
+      SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB);
+      SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB);
+   }
+
    SET_ShaderSourceARB(exec, _mesa_ShaderSourceARB);
    SET_CompileShaderARB(exec, _mesa_CompileShaderARB);
-   SET_CreateProgramObjectARB(exec, _mesa_CreateProgramObjectARB);
-   SET_AttachObjectARB(exec, _mesa_AttachObjectARB);
    SET_LinkProgramARB(exec, _mesa_LinkProgramARB);
    SET_UseProgramObjectARB(exec, _mesa_UseProgramObjectARB);
    SET_ValidateProgramARB(exec, _mesa_ValidateProgramARB);
-   SET_GetObjectParameterfvARB(exec, _mesa_GetObjectParameterfvARB);
-   SET_GetObjectParameterivARB(exec, _mesa_GetObjectParameterivARB);
-   SET_GetInfoLogARB(exec, _mesa_GetInfoLogARB);
-   SET_GetAttachedObjectsARB(exec, _mesa_GetAttachedObjectsARB);
    SET_GetShaderSourceARB(exec, _mesa_GetShaderSourceARB);
 
    /* OpenGL 2.0 */
@@ -1727,15 +1731,21 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec)
    SET_GetActiveAttribARB(exec, _mesa_GetActiveAttribARB);
    SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
 
-   SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB);
+   if (ctx->API != API_OPENGLES2) {
+      SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB);
 
-   SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT);
-   SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT);
-   SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT);
+      SET_UseShaderProgramEXT(exec, _mesa_UseShaderProgramEXT);
+      SET_ActiveProgramEXT(exec, _mesa_ActiveProgramEXT);
+      SET_CreateShaderProgramEXT(exec, _mesa_CreateShaderProgramEXT);
+   }
 
    /* GL_EXT_gpu_shader4 / GL 3.0 */
-   SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation);
-   SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation);
+   if (ctx->API != API_OPENGLES2) {
+      SET_BindFragDataLocationEXT(exec, _mesa_BindFragDataLocation);
+   }
+   if (ctx->API != API_OPENGLES2 || _mesa_is_gles3(ctx)) {
+      SET_GetFragDataLocationEXT(exec, _mesa_GetFragDataLocation);
+   }
 
    /* GL_ARB_ES2_compatibility */
    SET_ReleaseShaderCompiler(exec, _mesa_ReleaseShaderCompiler);
@@ -1743,8 +1753,10 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec)
    SET_ShaderBinary(exec, _mesa_ShaderBinary);
 
    /* GL_ARB_blend_func_extended */
-   SET_BindFragDataLocationIndexed(exec, _mesa_BindFragDataLocationIndexed);
-   SET_GetFragDataIndex(exec, _mesa_GetFragDataIndex);
+   if (ctx->API != API_OPENGLES2) {
+      SET_BindFragDataLocationIndexed(exec, _mesa_BindFragDataLocationIndexed);
+      SET_GetFragDataIndex(exec, _mesa_GetFragDataIndex);
+   }
 #endif /* FEATURE_GL */
 }
 
index 00c7d7f2aa1d9234dc06d9b075dd8994933ae1c2..d6382e04a767c65485e7e8c19010347c9c8830ef 100644 (file)
@@ -51,7 +51,8 @@ _mesa_active_program(struct gl_context *ctx, struct gl_shader_program *shProg,
                     const char *caller);
 
 extern void
-_mesa_init_shader_dispatch(struct _glapi_table *exec);
+_mesa_init_shader_dispatch(const struct gl_context *ctx,
+                           struct _glapi_table *exec);
 
 extern unsigned
 _mesa_count_active_attribs(struct gl_shader_program *shProg);