[Mesa-dev] [PATCH 4/5] mesa: Add a flag for shader programs to allow SSO linkage in GLES2.

Eric Anholt eric at anholt.net
Thu Oct 6 09:36:50 PDT 2011


On converting fixed function programs to generate GLSL, the linker
became cranky that we were trying to make something that wasn't a
linked vertex+fragment program.  Given that the Mesa GLES2 drivers
also support desktop GL with EXT_sso, just telling the linker to shut
up seems like the easiest solution.
---
 src/glsl/linker.cpp    |    3 ++-
 src/mesa/main/mtypes.h |   11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/glsl/linker.cpp b/src/glsl/linker.cpp
index 9463f53..1610e73 100644
--- a/src/glsl/linker.cpp
+++ b/src/glsl/linker.cpp
@@ -1802,7 +1802,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog)
     * present in a linked program.  By checking for use of shading language
     * version 1.00, we also catch the GL_ARB_ES2_compatibility case.
     */
-   if (ctx->API == API_OPENGLES2 || prog->Version == 100) {
+   if (!prog->InternalSeparateShader &&
+       (ctx->API == API_OPENGLES2 || prog->Version == 100)) {
       if (prog->_LinkedShaders[MESA_SHADER_VERTEX] == NULL) {
 	 linker_error(prog, "program lacks a vertex shader\n");
       } else if (prog->_LinkedShaders[MESA_SHADER_FRAGMENT] == NULL) {
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 4fe442f..4224da5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2148,6 +2148,17 @@ struct gl_shader_program
    GLint RefCount;  /**< Reference count */
    GLboolean DeletePending;
 
+   /**
+    * Flags that the linker should not reject the program if it lacks
+    * a vertex or fragment shader.  GLES2 doesn't allow separate
+    * shader objects, and would reject them.  However, we internally
+    * build separate shader objects for fixed function programs, which
+    * we use for drivers/common/meta.c and for handling
+    * _mesa_update_state with no program bound (for example in
+    * glClear()).
+    */
+   GLboolean InternalSeparateShader;
+
    GLuint NumShaders;          /**< number of attached shaders */
    struct gl_shader **Shaders; /**< List of attached the shaders */
 
-- 
1.7.6.3



More information about the mesa-dev mailing list