[Mesa-dev] [PATCH] shader-db: simplify and improve SSO handling

Timothy Arceri tarceri at itsqueeze.com
Wed Jul 18 11:22:41 UTC 2018


This does two things:

1. Allows cross shader optimisations to be preformed on SSO
   programs that contain more than one stage (seems like I
   don't have any of these in my shader-db collection).

2. Allows us to write compilation errors to stderr. With this
   change I discovered a Deus Ex: MD shader was failing to
   compile (I've reported it to Feral).
---
 run.c | 23 ++++-------------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/run.c b/run.c
index fdb610d..aa64d2c 100644
--- a/run.c
+++ b/run.c
@@ -809,27 +809,12 @@ main(int argc, char **argv)
             if (num_shaders == 1 && type != TYPE_VP && type != TYPE_FP)
                 use_separate_shader_objects = true;
 
-            if (use_separate_shader_objects) {
-                for (unsigned i = 0; i < num_shaders; i++) {
-                    const char *const_text;
-                    unsigned size = shader[i].length + 1;
-                    /* Using alloca crashes in the GLSL compiler.  */
-                    char *text = malloc(size);
-                    memset(text, 0, size);
-
-                    /* Make it zero-terminated. */
-                    memcpy(text, shader[i].text, shader[i].length);
-                    text[shader[i].length] = 0;
-
-                    const_text = text;
-                    GLuint prog = glCreateShaderProgramv(shader[i].type, 1,
-                                                         &const_text);
-                    glDeleteProgram(prog);
-                    free(text);
-                }
-            } else if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
+            if (type == TYPE_CORE || type == TYPE_COMPAT || type == TYPE_ES) {
                 GLuint prog = glCreateProgram();
 
+                if (use_separate_shader_objects)
+                   glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);
+
                 for (unsigned i = 0; i < num_shaders; i++) {
                     GLuint s = glCreateShader(shader[i].type);
                     glShaderSource(s, 1, &shader[i].text, &shader[i].length);
-- 
2.17.1



More information about the mesa-dev mailing list