[Mesa-dev] [PATCH 15/19] mesa: Don't set shaderapi dispatch pointers for many things in ES2 or core

Ian Romanick idr at freedesktop.org
Wed Sep 5 15:09:10 PDT 2012


From: Ian Romanick <ian.d.romanick at intel.com>

NOTE: This is a candidate for the 9.0 branch

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/api_exec.c  |  2 +-
 src/mesa/main/dlist.c     |  2 +-
 src/mesa/main/shaderapi.c | 50 +++++++++++++++++++++++++++++------------------
 src/mesa/main/shaderapi.h |  3 ++-
 4 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/src/mesa/main/api_exec.c b/src/mesa/main/api_exec.c
index 05c1a11..1761609 100644
--- a/src/mesa/main/api_exec.c
+++ b/src/mesa/main/api_exec.c
@@ -383,7 +383,7 @@ _mesa_create_exec_table(struct gl_context *ctx)
    SET_StencilOpSeparate(exec, _mesa_StencilOpSeparate);
 
 #if FEATURE_ARB_shader_objects
-   _mesa_init_shader_dispatch(exec);
+   _mesa_init_shader_dispatch(ctx, exec);
    _mesa_init_shader_uniform_dispatch(exec);
 #endif
 
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 4e0de7c..2ebb439 100644
--- a/src/mesa/main/dlist.c
+++ b/src/mesa/main/dlist.c
@@ -10480,7 +10480,7 @@ _mesa_create_save_table(const struct gl_context *ctx)
 #endif
 
    /* 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);
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 583778b..70782f1 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -1718,25 +1718,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_OPENGL) {
+      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 */
@@ -1760,17 +1764,23 @@ _mesa_init_shader_dispatch(struct _glapi_table *exec)
    SET_GetAttribLocationARB(exec, _mesa_GetAttribLocationARB);
 #endif
 
+   if (ctx->API != API_OPENGLES2) {
 #if FEATURE_ARB_geometry_shader4
-   SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB);
+      SET_ProgramParameteriARB(exec, _mesa_ProgramParameteriARB);
 #endif
 
-   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 || _mesa_is_gles3(ctx)) {
+      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);
@@ -1778,8 +1788,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 */
 }
 
diff --git a/src/mesa/main/shaderapi.h b/src/mesa/main/shaderapi.h
index 00c7d7f..d6382e0 100644
--- a/src/mesa/main/shaderapi.h
+++ b/src/mesa/main/shaderapi.h
@@ -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);
-- 
1.7.11.4



More information about the mesa-dev mailing list