glsl: Pass in options to do_algebraic().
authorMatt Turner <mattst88@gmail.com>
Sat, 1 Mar 2014 01:49:20 +0000 (17:49 -0800)
committerMatt Turner <mattst88@gmail.com>
Thu, 19 Jun 2014 23:11:51 +0000 (16:11 -0700)
Will be used in the next commit.

Reviewed-by: Eric Anholt <eric@anholt.net>
src/glsl/glsl_parser_extras.cpp
src/glsl/ir_optimization.h
src/glsl/opt_algebraic.cpp
src/glsl/test_optpass.cpp

index 80f53e3d796092494d58b835e54b9a7d04a974e6..13a1bca33b034571839ade5ad855747e5dbdf573 100644 (file)
@@ -1570,7 +1570,7 @@ do_common_optimization(exec_list *ir, bool linked,
    progress = do_constant_folding(ir) || progress;
    progress = do_cse(ir) || progress;
    progress = do_rebalance_tree(ir) || progress;
-   progress = do_algebraic(ir, native_integers) || progress;
+   progress = do_algebraic(ir, native_integers, options) || progress;
    progress = do_lower_jumps(ir) || progress;
    progress = do_vec_index_to_swizzle(ir) || progress;
    progress = lower_vector_insert(ir, false) || progress;
index e99bebbb859a737c5ef3d18cf00687d4f85b1273..b83c2259234877fd6bf1635a4d777b6c56175436 100644 (file)
@@ -72,7 +72,8 @@ bool do_common_optimization(exec_list *ir, bool linked,
                             bool native_integers);
 
 bool do_rebalance_tree(exec_list *instructions);
-bool do_algebraic(exec_list *instructions, bool native_integers);
+bool do_algebraic(exec_list *instructions, bool native_integers,
+                  const struct gl_shader_compiler_options *options);
 bool do_constant_folding(exec_list *instructions);
 bool do_constant_variable(exec_list *instructions);
 bool do_constant_variable_unlinked(exec_list *instructions);
index 9d5539252074901b56e5d4238b4b32d44af452ae..d57c3e8bde415ed294fa47857f5155c2a8a7159e 100644 (file)
@@ -45,7 +45,9 @@ namespace {
 
 class ir_algebraic_visitor : public ir_rvalue_visitor {
 public:
-   ir_algebraic_visitor(bool native_integers)
+   ir_algebraic_visitor(bool native_integers,
+                        const struct gl_shader_compiler_options *options)
+      : options(options)
    {
       this->progress = false;
       this->mem_ctx = NULL;
@@ -69,6 +71,7 @@ public:
    ir_rvalue *swizzle_if_required(ir_expression *expr,
                                  ir_rvalue *operand);
 
+   const struct gl_shader_compiler_options *options;
    void *mem_ctx;
 
    bool native_integers;
@@ -380,6 +383,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
             }
          }
       }
+
       break;
 
    case ir_binop_sub:
@@ -647,9 +651,10 @@ ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue)
 }
 
 bool
-do_algebraic(exec_list *instructions, bool native_integers)
+do_algebraic(exec_list *instructions, bool native_integers,
+             const struct gl_shader_compiler_options *options)
 {
-   ir_algebraic_visitor v(native_integers);
+   ir_algebraic_visitor v(native_integers, options);
 
    visit_list_elements(&v, instructions);
 
index db5cb266207a6af2786900db900be05f31b1f675..e4878bf15c709bb54507691168246433d55f6301 100644 (file)
@@ -65,7 +65,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
    if (sscanf(optimization, "do_common_optimization ( %d ) ", &int_0) == 1) {
       return do_common_optimization(ir, int_0 != 0, false, options, true);
    } else if (strcmp(optimization, "do_algebraic") == 0) {
-      return do_algebraic(ir, true);
+      return do_algebraic(ir, true, options);
    } else if (strcmp(optimization, "do_constant_folding") == 0) {
       return do_constant_folding(ir);
    } else if (strcmp(optimization, "do_constant_variable") == 0) {