glsl: Pass ctx->Const.NativeIntegers to do_algebraic.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 7 Apr 2014 06:28:02 +0000 (23:28 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Tue, 8 Apr 2014 07:02:06 +0000 (00:02 -0700)
The next patch will introduce an optimization that only works when
integers are not represented as floating point values.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/glsl_parser_extras.cpp
src/glsl/ir_optimization.h
src/glsl/opt_algebraic.cpp
src/glsl/test_optpass.cpp

index 532b6a5e7c05eca2865cdbac8e203e8cecd31ca4..a42f3d23df0e01940c56a4f986aa8cdcab82325f 100644 (file)
@@ -1530,7 +1530,7 @@ do_common_optimization(exec_list *ir, bool linked,
       progress = do_constant_variable_unlinked(ir) || progress;
    progress = do_constant_folding(ir) || progress;
    progress = do_cse(ir) || progress;
-   progress = do_algebraic(ir) || progress;
+   progress = do_algebraic(ir, native_integers) || progress;
    progress = do_lower_jumps(ir) || progress;
    progress = do_vec_index_to_swizzle(ir) || progress;
    progress = lower_vector_insert(ir, false) || progress;
index 9f31826d901c38fbdfd5f8093fd291babfe08894..665124a7d307199286cfaa18eb9d652f4fcfc089 100644 (file)
@@ -70,7 +70,7 @@ bool do_common_optimization(exec_list *ir, bool linked,
                             const struct gl_shader_compiler_options *options,
                             bool native_integers);
 
-bool do_algebraic(exec_list *instructions);
+bool do_algebraic(exec_list *instructions, bool native_integers);
 bool do_constant_folding(exec_list *instructions);
 bool do_constant_variable(exec_list *instructions);
 bool do_constant_variable_unlinked(exec_list *instructions);
index 2db877d5b8bd2d5ce2d6ac2ef9ebf5ecb58a3f39..9d5539252074901b56e5d4238b4b32d44af452ae 100644 (file)
@@ -45,10 +45,11 @@ namespace {
 
 class ir_algebraic_visitor : public ir_rvalue_visitor {
 public:
-   ir_algebraic_visitor()
+   ir_algebraic_visitor(bool native_integers)
    {
       this->progress = false;
       this->mem_ctx = NULL;
+      this->native_integers = native_integers;
    }
 
    virtual ~ir_algebraic_visitor()
@@ -70,6 +71,7 @@ public:
 
    void *mem_ctx;
 
+   bool native_integers;
    bool progress;
 };
 
@@ -645,9 +647,9 @@ ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue)
 }
 
 bool
-do_algebraic(exec_list *instructions)
+do_algebraic(exec_list *instructions, bool native_integers)
 {
-   ir_algebraic_visitor v;
+   ir_algebraic_visitor v(native_integers);
 
    visit_list_elements(&v, instructions);
 
index 6cb902aa2e1cd7bfd4769095e87fa98fdf6d111c..79fb17a9e4c1af54aa774ed1ed5eaa8b74218b66 100644 (file)
@@ -66,7 +66,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
               &int_0, &int_1) == 2) {
       return do_common_optimization(ir, int_0 != 0, false, int_1, options, true);
    } else if (strcmp(optimization, "do_algebraic") == 0) {
-      return do_algebraic(ir);
+      return do_algebraic(ir, true);
    } else if (strcmp(optimization, "do_constant_folding") == 0) {
       return do_constant_folding(ir);
    } else if (strcmp(optimization, "do_constant_variable") == 0) {