[Mesa-dev] [RFC 1/3] glsl IR: add not_interstage attribute to ir_variable

Gregory Hainaut gregory.hainaut at gmail.com
Sat Oct 3 02:31:18 PDT 2015


The negative form was used to keep interstage as the default value

Note: I put the ir_set_not_interstage_io function in opt_dead_code
because it will be used to disable deadcode optimization. Feel free
to point me a better place if it exists.

Signed-off-by: Gregory Hainaut <gregory.hainaut at gmail.com>
---
 src/glsl/ir.h              |  6 ++++++
 src/glsl/ir_optimization.h |  2 ++
 src/glsl/opt_dead_code.cpp | 19 +++++++++++++++++++
 3 files changed, 27 insertions(+)

diff --git a/src/glsl/ir.h b/src/glsl/ir.h
index f9ddf74..b4c4ace 100644
--- a/src/glsl/ir.h
+++ b/src/glsl/ir.h
@@ -649,6 +649,12 @@ public:
       unsigned assigned:1;
 
       /**
+       * When separate shader programs are enabled, only interstage
+       * variables can be safely removed of the shader interface.
+       */
+      unsigned not_interstage:1;
+
+      /**
        * Enum indicating how the variable was declared.  See
        * ir_var_declaration_type.
        *
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 265b223..bdd6ccc 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -72,6 +72,8 @@ enum lower_packing_builtins_op {
    LOWER_PACK_USE_BFE                   = 0x2000,
 };
 
+void ir_set_not_interstage_io(exec_list *instructions, ir_variable_mode mode);
+
 bool do_common_optimization(exec_list *ir, bool linked,
 			    bool uniform_locations_assigned,
                             const struct gl_shader_compiler_options *options,
diff --git a/src/glsl/opt_dead_code.cpp b/src/glsl/opt_dead_code.cpp
index e4bf874..d70c855 100644
--- a/src/glsl/opt_dead_code.cpp
+++ b/src/glsl/opt_dead_code.cpp
@@ -35,6 +35,25 @@
 
 static bool debug = false;
 
+void
+ir_set_not_interstage_io(exec_list *instructions, ir_variable_mode mode)
+{
+   ir_variable_refcount_visitor v;
+
+   assert(mode == ir_var_shader_in || mode == ir_var_shader_out);
+
+   v.run(instructions);
+
+   struct hash_entry *e;
+   hash_table_foreach(v.ht, e) {
+      ir_variable_refcount_entry *entry = (ir_variable_refcount_entry *)e->data;
+
+      if (entry->var->data.mode == mode)
+         entry->var->data.not_interstage = 1;
+   }
+}
+
+
 /**
  * Do a dead code pass over instructions and everything that instructions
  * references.
-- 
2.1.4



More information about the mesa-dev mailing list