[Mesa-dev] [PATCH shader-db] run: Add separate shader objects support.

Kenneth Graunke kenneth at whitecape.org
Thu Sep 17 13:09:11 PDT 2015


With this patch, if a .shader_test file contains

    [require]
    ...
    GL_ARB_separate_shader_objects

then the shader will be compiled using glCreateShaderProgramv, and thus
be a proper separate shader object.  Drivers may choose to lay out the
inputs/outputs of SSO programs slightly differently, resulting in
different code.
---
 run.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/run.c b/run.c
index de85665..34bd87e 100644
--- a/run.c
+++ b/run.c
@@ -71,6 +71,7 @@ static struct shader *
 get_shaders(const struct context_info *core, const struct context_info *compat,
             const char *text, size_t text_size,
             enum shader_type *type, unsigned *num_shaders,
+            bool *use_separate_shader_objects,
             const char *shader_name)
 {
     static const char *req = "[require]";
@@ -132,6 +133,10 @@ get_shaders(const struct context_info *core, const struct context_info *compat,
                     shader_name, (int)(newline - extension_text), extension_text);
             return NULL;
         }
+        if (memcmp(extension_text, "GL_ARB_separate_shader_objects",
+                   newline - extension_text) == 0) {
+            *use_separate_shader_objects = true;
+        }
     }
 
     /* Find the shaders. */
@@ -572,9 +577,11 @@ main(int argc, char **argv)
 
             enum shader_type type;
             unsigned num_shaders;
+            bool use_separate_shader_objects;
             struct shader *shader = get_shaders(&core, &compat,
                                                 text, shader_test[i].filesize,
                                                 &type, &num_shaders,
+                                                &use_separate_shader_objects,
                                                 current_shader_name);
             if (unlikely(shader == NULL)) {
                 continue;
@@ -590,7 +597,12 @@ main(int argc, char **argv)
             }
             ctx_is_core = type == TYPE_CORE;
 
-            if (type == TYPE_CORE || type == TYPE_COMPAT) {
+            if (use_separate_shader_objects) {
+                for (unsigned i = 0; i < num_shaders; i++) {
+                    GLuint prog = glCreateShaderProgramv(shader[i].type, 1,
+                                                         &shader[i].text);
+                }
+            } else if (type == TYPE_CORE || type == TYPE_COMPAT) {
                 GLuint prog = glCreateProgram();
 
                 for (unsigned i = 0; i < num_shaders; i++) {
-- 
2.5.1



More information about the mesa-dev mailing list