summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/compiler/glsl/ir_optimization.h6
-rw-r--r--src/compiler/glsl/lower_variable_index_to_cond_assign.cpp26
-rw-r--r--src/compiler/glsl/lower_vec_index_to_cond_assign.cpp4
3 files changed, 20 insertions, 16 deletions
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 573ddb4a8d7..0fbbf34595f 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -170,9 +170,9 @@ bool lower_blend_equation_advanced(gl_linked_shader *shader);
bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state);
void propagate_invariance(exec_list *instructions);
-ir_rvalue *
-compare_index_block(exec_list *instructions, ir_variable *index,
- unsigned base, unsigned components, void *mem_ctx);
+ir_variable *compare_index_block(exec_list *instructions, ir_variable *index,
+ unsigned base, unsigned components,
+ void *mem_ctx);
bool lower_64bit_integer_instructions(exec_list *instructions,
unsigned what_to_lower);
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 fcb12d1b77d..dd49272abb8 100644
--- a/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_variable_index_to_cond_assign.cpp
@@ -66,10 +66,10 @@
* \param mem_ctx ralloc memory context to be used for all allocations.
*
* \returns
- * An \c ir_rvalue that \b must be cloned for each use in conditional
- * assignments, etc.
+ * An \c ir_variable containing the per-component comparison results. This
+ * must be dereferenced per use.
*/
-ir_rvalue *
+ir_variable *
compare_index_block(exec_list *instructions, ir_variable *index,
unsigned base, unsigned components, void *mem_ctx)
{
@@ -113,7 +113,7 @@ compare_index_block(exec_list *instructions, ir_variable *index,
new(mem_ctx) ir_dereference_variable(condition);
instructions->push_tail(new(mem_ctx) ir_assignment(cond_deref, condition_val, 0));
- return cond_deref;
+ return condition;
}
static inline bool
@@ -275,17 +275,21 @@ struct switch_generator
for (unsigned i = first; i < end; i += 4) {
const unsigned comps = MIN2(condition_components, end - i);
- ir_rvalue *const cond_deref =
- compare_index_block(list, index, i, comps, this->mem_ctx);
+ ir_variable *const cond =
+ compare_index_block(list, index, i, comps, this->mem_ctx);
if (comps == 1) {
- this->generator.generate(i, cond_deref->clone(this->mem_ctx, NULL),
- list);
+ ir_rvalue *const cond_deref =
+ new(mem_ctx) ir_dereference_variable(cond);
+
+ this->generator.generate(i, cond_deref, list);
} else {
for (unsigned j = 0; j < comps; j++) {
- ir_rvalue *const cond_swiz =
- new(this->mem_ctx) ir_swizzle(cond_deref->clone(this->mem_ctx, NULL),
- j, 0, 0, 0, 1);
+ ir_rvalue *const cond_deref =
+ new(mem_ctx) ir_dereference_variable(cond);
+ ir_rvalue *const cond_swiz =
+ new(this->mem_ctx) ir_swizzle(cond_deref,
+ j, 0, 0, 0, 1);
this->generator.generate(i + j, cond_swiz, list);
}
diff --git a/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp b/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp
index 597d852c76e..f60ff7b77fc 100644
--- a/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp
+++ b/src/compiler/glsl/lower_vec_index_to_cond_assign.cpp
@@ -115,7 +115,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_
/* Generate a single comparison condition "mask" for all of the components
* in the vector.
*/
- ir_rvalue *const cond_deref =
+ ir_variable *const cond =
compare_index_block(&list, index, 0,
orig_vector->type->vector_elements,
mem_ctx);
@@ -123,7 +123,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_
/* Generate a conditional move of each vector element to the temp. */
for (i = 0; i < orig_vector->type->vector_elements; i++) {
ir_rvalue *condition_swizzle =
- new(base_ir) ir_swizzle(cond_deref->clone(mem_ctx, NULL),
+ new(base_ir) ir_swizzle(new(mem_ctx) ir_dereference_variable(cond),
i, 0, 0, 0, 1);
/* Just clone the rest of the deref chain when trying to get at the