[Mesa-dev] [PATCH 1/3] gallium: create a new variable_store class replacing variables field in glsl_to_tgsi_visitor

Vincent Lejeune vljn at ovi.com
Thu Dec 29 09:42:04 PST 2011


---
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   37 ++++++++++++++++++----------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 77aa0d1..59ecb52 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -286,6 +286,13 @@ public:
    st_src_reg return_reg;
 };
 
+class variable_store {
+public:
+   exec_list variables;
+   variable_storage *find_variable_storage(class ir_variable *var);
+   void push(class variable_storage *);
+};
+
 class glsl_to_tgsi_visitor : public ir_visitor {
 public:
    glsl_to_tgsi_visitor();
@@ -308,8 +315,6 @@ public:
    int glsl_version;
    bool native_integers;
 
-   variable_storage *find_variable_storage(ir_variable *var);
-
    int add_constant(gl_register_file file, gl_constant_value values[4],
                     int size, int datatype, GLuint *swizzle_out);
 
@@ -352,7 +357,7 @@ public:
    st_src_reg result;
 
    /** List of variable_storage */
-   exec_list variables;
+   variable_store store;
 
    /** List of immediate_storage */
    exec_list immediates;
@@ -994,7 +999,7 @@ glsl_to_tgsi_visitor::get_temp(const glsl_type *type)
 }
 
 variable_storage *
-glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
+variable_store::find_variable_storage(ir_variable *var)
 {
    
    variable_storage *entry;
@@ -1010,6 +1015,12 @@ glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var)
 }
 
 void
+variable_store::push(variable_storage *storage)
+{
+   variables.push_tail(storage);
+}
+
+void
 glsl_to_tgsi_visitor::visit(ir_variable *ir)
 {
    if (strcmp(ir->name, "gl_FragCoord") == 0) {
@@ -1041,7 +1052,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
       if (i == ir->num_state_slots) {
          /* We'll set the index later. */
          storage = new(mem_ctx) variable_storage(ir, PROGRAM_STATE_VAR, -1);
-         this->variables.push_tail(storage);
+         store.push(storage);
 
          dst = undef_dst;
       } else {
@@ -1053,7 +1064,7 @@ glsl_to_tgsi_visitor::visit(ir_variable *ir)
 
          storage = new(mem_ctx) variable_storage(ir, PROGRAM_TEMPORARY,
         					 this->next_temp);
-         this->variables.push_tail(storage);
+         store.push(storage);
          this->next_temp += type_size(ir->type);
 
          dst = st_dst_reg(st_src_reg(PROGRAM_TEMPORARY, storage->index,
@@ -1893,7 +1904,7 @@ glsl_to_tgsi_visitor::visit(ir_swizzle *ir)
 void
 glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
 {
-   variable_storage *entry = find_variable_storage(ir->var);
+   variable_storage *entry = store.find_variable_storage(ir->var);
    ir_variable *var = ir->var;
 
    if (!entry) {
@@ -1901,7 +1912,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
       case ir_var_uniform:
          entry = new(mem_ctx) variable_storage(var, PROGRAM_UNIFORM,
         				       var->location);
-         this->variables.push_tail(entry);
+         store.push(entry);
          break;
       case ir_var_in:
       case ir_var_inout:
@@ -1932,7 +1943,7 @@ glsl_to_tgsi_visitor::visit(ir_dereference_variable *ir)
       case ir_var_temporary:
          entry = new(mem_ctx) variable_storage(var, PROGRAM_TEMPORARY,
         				       this->next_temp);
-         this->variables.push_tail(entry);
+         store.push(entry);
 
          next_temp += type_size(var->type);
          break;
@@ -2411,12 +2422,12 @@ glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig)
       ir_variable *param = (ir_variable *)iter.get();
       variable_storage *storage;
 
-      storage = find_variable_storage(param);
+      storage = store.find_variable_storage(param);
       assert(!storage);
 
       storage = new(mem_ctx) variable_storage(param, PROGRAM_TEMPORARY,
         				      this->next_temp);
-      this->variables.push_tail(storage);
+      store.push(storage);
 
       this->next_temp += type_size(param->type);
    }
@@ -2447,7 +2458,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
 
       if (param->mode == ir_var_in ||
           param->mode == ir_var_inout) {
-         variable_storage *storage = find_variable_storage(param);
+         variable_storage *storage = store.find_variable_storage(param);
          assert(storage);
 
          param_rval->accept(this);
@@ -2483,7 +2494,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
 
       if (param->mode == ir_var_out ||
           param->mode == ir_var_inout) {
-         variable_storage *storage = find_variable_storage(param);
+         variable_storage *storage = store.find_variable_storage(param);
          assert(storage);
 
          st_src_reg r;
-- 
1.7.7



More information about the mesa-dev mailing list