[Mesa-dev] [PATCH 4/6] glsl: Pass in options to do_algebraic().
Matt Turner
mattst88 at gmail.com
Mon Mar 10 15:54:51 PDT 2014
Will be used in the next commit.
---
src/glsl/glsl_parser_extras.cpp | 2 +-
src/glsl/ir_optimization.h | 3 ++-
src/glsl/opt_algebraic.cpp | 10 +++++++---
src/glsl/test_optpass.cpp | 2 +-
4 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index e0cbbb1..87bdae4 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1539,7 +1539,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) || progress;
+ progress = do_algebraic(ir, options) || 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 4cad49b..b8e89c5 100644
--- a/src/glsl/ir_optimization.h
+++ b/src/glsl/ir_optimization.h
@@ -69,7 +69,8 @@ bool do_common_optimization(exec_list *ir, bool linked,
unsigned max_unroll_iterations,
const struct gl_shader_compiler_options *options);
-bool do_algebraic(exec_list *instructions);
+bool do_algebraic(exec_list *instructions,
+ const struct gl_shader_compiler_options *options);
bool do_rebalance_tree(exec_list *instructions);
bool do_constant_folding(exec_list *instructions);
bool do_constant_variable(exec_list *instructions);
diff --git a/src/glsl/opt_algebraic.cpp b/src/glsl/opt_algebraic.cpp
index 8494bd9..eb5544a 100644
--- a/src/glsl/opt_algebraic.cpp
+++ b/src/glsl/opt_algebraic.cpp
@@ -45,7 +45,8 @@ namespace {
class ir_algebraic_visitor : public ir_rvalue_visitor {
public:
- ir_algebraic_visitor()
+ ir_algebraic_visitor(const struct gl_shader_compiler_options *options)
+ : options(options)
{
this->progress = false;
this->mem_ctx = NULL;
@@ -68,6 +69,7 @@ public:
ir_rvalue *swizzle_if_required(ir_expression *expr,
ir_rvalue *operand);
+ const struct gl_shader_compiler_options *options;
void *mem_ctx;
bool progress;
@@ -378,6 +380,7 @@ ir_algebraic_visitor::handle_expression(ir_expression *ir)
}
}
}
+
break;
case ir_binop_sub:
@@ -623,9 +626,10 @@ ir_algebraic_visitor::handle_rvalue(ir_rvalue **rvalue)
}
bool
-do_algebraic(exec_list *instructions)
+do_algebraic(exec_list *instructions,
+ const struct gl_shader_compiler_options *options)
{
- ir_algebraic_visitor v;
+ ir_algebraic_visitor v(options);
visit_list_elements(&v, instructions);
diff --git a/src/glsl/test_optpass.cpp b/src/glsl/test_optpass.cpp
index f1b9579..0f96d4f 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);
} else if (strcmp(optimization, "do_algebraic") == 0) {
- return do_algebraic(ir);
+ return do_algebraic(ir, options);
} else if (strcmp(optimization, "do_constant_folding") == 0) {
return do_constant_folding(ir);
} else if (strcmp(optimization, "do_constant_variable") == 0) {
--
1.8.3.2
More information about the mesa-dev
mailing list