On 09/17/2015 11:09 PM, Kenneth Graunke wrote:
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) {

Alternatively you could set

glProgramParameteri(prog, GL_PROGRAM_SEPARABLE, GL_TRUE);

before linking, this should achieve same goal with smaller change.


                  GLuint prog = glCreateProgram();

                  for (unsigned i = 0; i < num_shaders; i++) {



// Tapani
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to