Mesa (master): glsl/linker: Pass absolute location to add_shader_variable( )

Kristian Høgsberg krh at kemper.freedesktop.org
Tue Apr 12 21:48:31 UTC 2016


Module: Mesa
Branch: master
Commit: 09f01215933f8f7f8d3d4cda9ff94605164df9a9
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=09f01215933f8f7f8d3d4cda9ff94605164df9a9

Author: Kristian Høgsberg Kristensen <kristian.h.kristensen at intel.com>
Date:   Mon Apr 11 13:03:12 2016 -0700

glsl/linker: Pass absolute location to add_shader_variable()

This lets us pass in the absolution location of a variable instead of
computing it in add_shader_variable() based on variable location and
bias. This is in preparation for recursing into struct variables.

Signed-off-by: Kristian Høgsberg Kristensen <kristian.h.kristensen at intel.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

---

 src/compiler/glsl/linker.cpp | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 63b3fdf..1ea5c1f 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -3519,7 +3519,7 @@ build_stageref(struct gl_shader_program *shProg, const char *name,
 static gl_shader_variable *
 create_shader_variable(struct gl_shader_program *shProg,
                        const ir_variable *in, bool use_implicit_location,
-                       int location_bias)
+                       int location)
 {
    gl_shader_variable *out = ralloc(shProg, struct gl_shader_variable);
    if (!out)
@@ -3557,7 +3557,7 @@ create_shader_variable(struct gl_shader_program *shProg,
        !(in->data.explicit_location || use_implicit_location)) {
       out->location = -1;
    } else {
-      out->location = in->data.location - location_bias;
+      out->location = location;
    }
 
    out->type = in->type;
@@ -3571,10 +3571,10 @@ create_shader_variable(struct gl_shader_program *shProg,
 static bool
 add_shader_variable(struct gl_shader_program *shProg, unsigned stage_mask,
                     GLenum programInterface, ir_variable *var,
-                    bool use_implicit_location, int location_bias)
+                    bool use_implicit_location, int location)
 {
    gl_shader_variable *sha_v =
-      create_shader_variable(shProg, var, use_implicit_location, location_bias);
+      create_shader_variable(shProg, var, use_implicit_location, location);
    if (!sha_v)
       return false;
 
@@ -3630,7 +3630,8 @@ add_interface_variables(struct gl_shader_program *shProg,
          (stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out);
 
       if (!add_shader_variable(shProg, 1 << stage, programInterface,
-                               var, vs_input_or_fs_output, loc_bias))
+                               var, vs_input_or_fs_output,
+                               var->data.location - loc_bias))
          return false;
    }
    return true;
@@ -3663,7 +3664,8 @@ add_packed_varyings(struct gl_shader_program *shProg, int stage, GLenum type)
             const int stage_mask =
                build_stageref(shProg, var->name, var->data.mode);
             if (!add_shader_variable(shProg, stage_mask,
-                                     iface, var, false, VARYING_SLOT_VAR0))
+                                     iface, var, false,
+                                     var->data.location - VARYING_SLOT_VAR0))
                return false;
          }
       }
@@ -3686,7 +3688,8 @@ add_fragdata_arrays(struct gl_shader_program *shProg)
 
          if (!add_shader_variable(shProg,
                                   1 << MESA_SHADER_FRAGMENT,
-                                  GL_PROGRAM_OUTPUT, var, true, FRAG_RESULT_DATA0))
+                                  GL_PROGRAM_OUTPUT, var, true,
+                                  var->data.location - FRAG_RESULT_DATA0))
             return false;
       }
    }




More information about the mesa-commit mailing list