glsl: Return ir_variable from compare_index_block

This is basically a wash now, but it simplifies later patches that
convert to using ir_builder.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Thomas Helland <thomashelland90@gmail.com>
This commit is contained in:
Ian Romanick 2017-09-14 18:20:14 -07:00
parent 4d009455f3
commit 1f4fcdb2ca
3 changed files with 20 additions and 16 deletions

View File

@ -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);

View File

@ -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);
}

View File

@ -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