diff options
author | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-06-16 19:57:18 +0200 |
---|---|---|
committer | Nicolai Hähnle <nicolai.haehnle@amd.com> | 2017-07-13 13:27:37 +0200 |
commit | b577f1e639b88b04c25fc8bd0ea37e228bd51b41 (patch) | |
tree | b98fba8b15436b8e43bd245d19a48bf328addebf /src/compiler | |
parent | a389038e3e5878ff17c08668d5bc4ddb6579579a (diff) |
glsl: use bitfield for options to lower_variable_index_to_cond_assign
This makes for a nicer interface than a list of booleans.
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/glsl/ir_optimization.h | 11 | ||||
-rw-r--r-- | src/compiler/glsl/lower_variable_index_to_cond_assign.cpp | 24 | ||||
-rw-r--r-- | src/compiler/glsl/test_optpass.cpp | 13 |
3 files changed, 26 insertions, 22 deletions
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h index 82cdac9b3c..b0b33f1af1 100644 --- a/src/compiler/glsl/ir_optimization.h +++ b/src/compiler/glsl/ir_optimization.h @@ -134,9 +134,16 @@ bool lower_discard(exec_list *instructions); void lower_discard_flow(exec_list *instructions); bool lower_instructions(exec_list *instructions, unsigned what_to_lower); bool lower_noise(exec_list *instructions); + +enum lower_variable_index_bits { + lower_variable_index_input = (1 << 0), + lower_variable_index_output = (1 << 1), + lower_variable_index_temp = (1 << 2), + lower_variable_index_uniform = (1 << 3), +}; + bool lower_variable_index_to_cond_assign(gl_shader_stage stage, - exec_list *instructions, bool lower_input, bool lower_output, - bool lower_temp, bool lower_uniform); + exec_list *instructions, unsigned lower_bits); bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz); bool lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage); bool lower_clip_cull_distance(struct gl_shader_program *prog, diff --git a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp index fcb12d1b77..1820f239ea 100644 --- a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp +++ b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp @@ -336,17 +336,14 @@ struct switch_generator class variable_index_to_cond_assign_visitor : public ir_rvalue_visitor { public: variable_index_to_cond_assign_visitor(gl_shader_stage stage, - bool lower_input, - bool lower_output, - bool lower_temp, - bool lower_uniform) + unsigned lower_bits) { this->progress = false; this->stage = stage; - this->lower_inputs = lower_input; - this->lower_outputs = lower_output; - this->lower_temps = lower_temp; - this->lower_uniforms = lower_uniform; + this->lower_inputs = !!(lower_bits & lower_variable_index_input); + this->lower_outputs = !!(lower_bits & lower_variable_index_output); + this->lower_temps = !!(lower_bits & lower_variable_index_temp); + this->lower_uniforms = !!(lower_bits & lower_variable_index_uniform); } bool progress; @@ -578,16 +575,9 @@ public: bool lower_variable_index_to_cond_assign(gl_shader_stage stage, exec_list *instructions, - bool lower_input, - bool lower_output, - bool lower_temp, - bool lower_uniform) + unsigned lower_bits) { - variable_index_to_cond_assign_visitor v(stage, - lower_input, - lower_output, - lower_temp, - lower_uniform); + variable_index_to_cond_assign_visitor v(stage, lower_bits); /* Continue lowering until no progress is made. If there are multiple * levels of indirection (e.g., non-constant indexing of array elements and diff --git a/src/compiler/glsl/test_optpass.cpp b/src/compiler/glsl/test_optpass.cpp index c6e97888f6..3d9eafac84 100644 --- a/src/compiler/glsl/test_optpass.cpp +++ b/src/compiler/glsl/test_optpass.cpp @@ -124,9 +124,16 @@ do_optimization(struct exec_list *ir, const char *optimization, } else if (sscanf(optimization, "lower_variable_index_to_cond_assign " "( %d , %d , %d , %d ) ", &int_0, &int_1, &int_2, &int_3) == 4) { - return lower_variable_index_to_cond_assign(MESA_SHADER_VERTEX, ir, - int_0 != 0, int_1 != 0, - int_2 != 0, int_3 != 0); + unsigned bits = 0; + if (int_0) + bits |= lower_variable_index_input; + if (int_1) + bits |= lower_variable_index_output; + if (int_2) + bits |= lower_variable_index_temp; + if (int_3) + bits |= lower_variable_index_uniform; + return lower_variable_index_to_cond_assign(MESA_SHADER_VERTEX, ir, bits); } else if (sscanf(optimization, "lower_quadop_vector ( %d ) ", &int_0) == 1) { return lower_quadop_vector(ir, int_0 != 0); |