[Mesa-dev] [PATCH 8/9] glsl: Pass ctx->Const.NativeIntegers to do_algebraic.

Kenneth Graunke kenneth at whitecape.org
Sun Apr 6 23:49:54 PDT 2014


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 at whitecape.org>
---
 src/glsl/glsl_parser_extras.cpp | 2 +-
 src/glsl/ir_optimization.h      | 2 +-
 src/glsl/opt_algebraic.cpp      | 8 +++++---
 src/glsl/test_optpass.cpp       | 2 +-
 4 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 532b6a5..a42f3d2 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -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;
diff --git a/src/glsl/ir_optimization.h b/src/glsl/ir_optimization.h
index 9f31826..665124a 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -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);
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 2db877d..9d55392 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -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);
 
diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
index 6cb902a..79fb17a 100644
--- a/src/glsl/test_optpass.cpp
+++ b/src/glsl/test_optpass.cpp
@@ -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) {
-- 
1.9.0



More information about the mesa-dev mailing list