mesa: add packed_varyings list to gl_shader
authorTapani Pälli <tapani.palli@intel.com>
Fri, 4 Sep 2015 08:22:15 +0000 (11:22 +0300)
committerTapani Pälli <tapani.palli@intel.com>
Fri, 25 Sep 2015 05:05:59 +0000 (08:05 +0300)
This is required to store information about packed varyings, currently
these variables get lost and cannot be retrieved later in sensible way
for program interface queries. List will be utilized by next patch.

Signed-off-by: Tapani Pälli <tapani.palli@intel.com>
Reviewed-by: Marta Lofstedt <marta.lofstedt@intel.com>
src/glsl/lower_packed_varyings.cpp
src/mesa/main/mtypes.h

index cfe414ae0882570ab3f92bb0a071ab7b25de4ce7..5d66ca931cf353a0c9438f843c50068fb0b352e3 100644 (file)
@@ -170,7 +170,7 @@ public:
                                  exec_list *out_instructions,
                                  exec_list *out_variables);
 
-   void run(exec_list *instructions);
+   void run(struct gl_shader *shader);
 
 private:
    void bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs);
@@ -252,9 +252,9 @@ lower_packed_varyings_visitor::lower_packed_varyings_visitor(
 }
 
 void
-lower_packed_varyings_visitor::run(exec_list *instructions)
+lower_packed_varyings_visitor::run(struct gl_shader *shader)
 {
-   foreach_in_list(ir_instruction, node, instructions) {
+   foreach_in_list(ir_instruction, node, shader->ir) {
       ir_variable *var = node->as_variable();
       if (var == NULL)
          continue;
@@ -272,6 +272,14 @@ lower_packed_varyings_visitor::run(exec_list *instructions)
       assert(var->data.interpolation == INTERP_QUALIFIER_FLAT ||
              !var->type->contains_integer());
 
+      /* Clone the variable for program resource list before
+       * it gets modified and lost.
+       */
+      if (!shader->packed_varyings)
+         shader->packed_varyings = new (shader) exec_list;
+
+      shader->packed_varyings->push_tail(var->clone(shader, NULL));
+
       /* Change the old varying into an ordinary global. */
       assert(var->data.mode != ir_var_temporary);
       var->data.mode = ir_var_auto;
@@ -711,7 +719,7 @@ lower_packed_varyings(void *mem_ctx, unsigned locations_used,
                                          gs_input_vertices,
                                          &new_instructions,
                                          &new_variables);
-   visitor.run(instructions);
+   visitor.run(shader);
    if (mode == ir_var_shader_out) {
       if (shader->Stage == MESA_SHADER_GEOMETRY) {
          /* For geometry shaders, outputs need to be lowered before each call
index d308b98617524e553a95138b977ef0dc59e44a0a..22b1d14636f99c412c3884281d9806dcc8bb0400 100644 (file)
@@ -2292,6 +2292,7 @@ struct gl_shader
    struct gl_uniform_block *UniformBlocks;
 
    struct exec_list *ir;
+   struct exec_list *packed_varyings;
    struct glsl_symbol_table *symbols;
 
    bool uses_builtin_functions;