glsl: Delete lower_extracts code
The single caller of this function (in st_glsl_to_ir.cpp) always passes false, so this is dead code. v2: Delete convert_vec_index_to_cond_assign method because all the callers are deleted too. Reviewed-by: Matt Turner <mattst88@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16440>
This commit is contained in:
@@ -116,7 +116,7 @@ bool do_minmax_prune(exec_list *instructions);
|
|||||||
bool do_structure_splitting(exec_list *instructions);
|
bool do_structure_splitting(exec_list *instructions);
|
||||||
bool optimize_swizzles(exec_list *instructions);
|
bool optimize_swizzles(exec_list *instructions);
|
||||||
bool do_tree_grafting(exec_list *instructions);
|
bool do_tree_grafting(exec_list *instructions);
|
||||||
bool do_vec_index_to_cond_assign(exec_list *instructions, bool lower_extracts);
|
bool do_vec_index_to_cond_assign(exec_list *instructions);
|
||||||
bool do_vec_index_to_swizzle(exec_list *instructions);
|
bool do_vec_index_to_swizzle(exec_list *instructions);
|
||||||
bool lower_discard(exec_list *instructions);
|
bool lower_discard(exec_list *instructions);
|
||||||
void lower_discard_flow(exec_list *instructions);
|
void lower_discard_flow(exec_list *instructions);
|
||||||
|
@@ -53,17 +53,12 @@ namespace {
|
|||||||
|
|
||||||
class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor {
|
class ir_vec_index_to_cond_assign_visitor : public ir_hierarchical_visitor {
|
||||||
public:
|
public:
|
||||||
ir_vec_index_to_cond_assign_visitor(bool _lower_extracts)
|
ir_vec_index_to_cond_assign_visitor()
|
||||||
: lower_extracts(_lower_extracts), progress(false)
|
: progress(false)
|
||||||
{
|
{
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
ir_rvalue *convert_vec_index_to_cond_assign(void *mem_ctx,
|
|
||||||
ir_rvalue *orig_vector,
|
|
||||||
ir_rvalue *orig_index,
|
|
||||||
const glsl_type *type);
|
|
||||||
|
|
||||||
ir_rvalue *convert_vector_extract_to_cond_assign(ir_rvalue *ir);
|
ir_rvalue *convert_vector_extract_to_cond_assign(ir_rvalue *ir);
|
||||||
|
|
||||||
virtual ir_visitor_status visit_enter(ir_expression *);
|
virtual ir_visitor_status visit_enter(ir_expression *);
|
||||||
@@ -73,97 +68,11 @@ public:
|
|||||||
virtual ir_visitor_status visit_enter(ir_call *);
|
virtual ir_visitor_status visit_enter(ir_call *);
|
||||||
virtual ir_visitor_status visit_enter(ir_if *);
|
virtual ir_visitor_status visit_enter(ir_if *);
|
||||||
|
|
||||||
bool lower_extracts;
|
|
||||||
bool progress;
|
bool progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* anonymous namespace */
|
} /* anonymous namespace */
|
||||||
|
|
||||||
ir_rvalue *
|
|
||||||
ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(void *mem_ctx,
|
|
||||||
ir_rvalue *orig_vector,
|
|
||||||
ir_rvalue *orig_index,
|
|
||||||
const glsl_type *type)
|
|
||||||
{
|
|
||||||
exec_list list;
|
|
||||||
ir_factory body(&list, base_ir);
|
|
||||||
|
|
||||||
/* Store the index to a temporary to avoid reusing its tree. */
|
|
||||||
assert(orig_index->type == glsl_type::int_type ||
|
|
||||||
orig_index->type == glsl_type::uint_type);
|
|
||||||
ir_variable *const index =
|
|
||||||
body.make_temp(orig_index->type, "vec_index_tmp_i");
|
|
||||||
|
|
||||||
body.emit(assign(index, orig_index));
|
|
||||||
|
|
||||||
/* Store the value inside a temp, thus avoiding matrixes duplication */
|
|
||||||
ir_variable *const value =
|
|
||||||
body.make_temp(orig_vector->type, "vec_value_tmp");
|
|
||||||
|
|
||||||
body.emit(assign(value, orig_vector));
|
|
||||||
|
|
||||||
|
|
||||||
/* Temporary where we store whichever value we swizzle out. */
|
|
||||||
ir_variable *const var = body.make_temp(type, "vec_index_tmp_v");
|
|
||||||
|
|
||||||
/* Generate a single comparison condition "mask" for all of the components
|
|
||||||
* in the vector. This will be of the form vec3(i > 0, i > 1, i < 2).
|
|
||||||
*/
|
|
||||||
ir_rvalue *const broadcast_index = orig_vector->type->vector_elements > 2
|
|
||||||
? swizzle(index, SWIZZLE_XXXX, orig_vector->type->vector_elements - 1)
|
|
||||||
: operand(index).val;
|
|
||||||
|
|
||||||
ir_constant_data test_indices_data;
|
|
||||||
memset(&test_indices_data, 0, sizeof(test_indices_data));
|
|
||||||
test_indices_data.i[0] = 0;
|
|
||||||
test_indices_data.i[1] = 1;
|
|
||||||
test_indices_data.i[2] = 2;
|
|
||||||
|
|
||||||
ir_constant *const test_indices =
|
|
||||||
new(mem_ctx) ir_constant(broadcast_index->type, &test_indices_data);
|
|
||||||
|
|
||||||
ir_rvalue *const condition_val = greater(broadcast_index, test_indices);
|
|
||||||
|
|
||||||
ir_variable *const cond = body.make_temp(condition_val->type,
|
|
||||||
"dereference_condition");
|
|
||||||
|
|
||||||
body.emit(assign(cond, condition_val));
|
|
||||||
|
|
||||||
|
|
||||||
/* Generate a series of conditional selections to pick the right element. */
|
|
||||||
assert(orig_vector->type->vector_elements <= 4 &&
|
|
||||||
orig_vector->type->vector_elements >= 2);
|
|
||||||
|
|
||||||
ir_rvalue *rhs = csel(swizzle(cond, 0, 1),
|
|
||||||
swizzle(value, 1, 1),
|
|
||||||
swizzle(value, 0, 1));
|
|
||||||
|
|
||||||
if (orig_vector->type->vector_elements > 2) {
|
|
||||||
ir_rvalue *tmp;
|
|
||||||
|
|
||||||
if (orig_vector->type->vector_elements > 3) {
|
|
||||||
tmp = csel(swizzle(cond, 2, 1),
|
|
||||||
swizzle(value, 3, 1),
|
|
||||||
swizzle(value, 2, 1));
|
|
||||||
|
|
||||||
} else {
|
|
||||||
tmp = swizzle(value, 2, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
rhs = csel(swizzle(cond, 1, 1), tmp, rhs);
|
|
||||||
}
|
|
||||||
|
|
||||||
body.emit(assign(var, rhs));
|
|
||||||
|
|
||||||
/* Put all of the new instructions in the IR stream before the old
|
|
||||||
* instruction.
|
|
||||||
*/
|
|
||||||
base_ir->insert_before(&list);
|
|
||||||
|
|
||||||
this->progress = true;
|
|
||||||
return deref(var).val;
|
|
||||||
}
|
|
||||||
|
|
||||||
ir_rvalue *
|
ir_rvalue *
|
||||||
ir_vec_index_to_cond_assign_visitor::convert_vector_extract_to_cond_assign(ir_rvalue *ir)
|
ir_vec_index_to_cond_assign_visitor::convert_vector_extract_to_cond_assign(ir_rvalue *ir)
|
||||||
{
|
{
|
||||||
@@ -192,26 +101,13 @@ ir_vec_index_to_cond_assign_visitor::convert_vector_extract_to_cond_assign(ir_rv
|
|||||||
new(base_ir) ir_expression(expr->operation, vec_input->type,
|
new(base_ir) ir_expression(expr->operation, vec_input->type,
|
||||||
vec_input, expr->operands[1]);
|
vec_input, expr->operands[1]);
|
||||||
|
|
||||||
if (lower_extracts) {
|
this->progress = true;
|
||||||
return convert_vec_index_to_cond_assign(ralloc_parent(ir),
|
return new(base_ir) ir_expression(ir_binop_vector_extract, ir->type,
|
||||||
vec_interpolate,
|
vec_interpolate,
|
||||||
interpolant->operands[1],
|
interpolant->operands[1]);
|
||||||
ir->type);
|
|
||||||
} else {
|
|
||||||
this->progress = true;
|
|
||||||
return new(base_ir) ir_expression(ir_binop_vector_extract, ir->type,
|
|
||||||
vec_interpolate,
|
|
||||||
interpolant->operands[1]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!lower_extracts || expr->operation != ir_binop_vector_extract)
|
return ir;
|
||||||
return ir;
|
|
||||||
|
|
||||||
return convert_vec_index_to_cond_assign(ralloc_parent(ir),
|
|
||||||
expr->operands[0],
|
|
||||||
expr->operands[1],
|
|
||||||
ir->type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ir_visitor_status
|
ir_visitor_status
|
||||||
@@ -275,9 +171,9 @@ ir_vec_index_to_cond_assign_visitor::visit_enter(ir_if *ir)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
do_vec_index_to_cond_assign(exec_list *instructions, bool lower_extracts)
|
do_vec_index_to_cond_assign(exec_list *instructions)
|
||||||
{
|
{
|
||||||
ir_vec_index_to_cond_assign_visitor v(lower_extracts);
|
ir_vec_index_to_cond_assign_visitor v;
|
||||||
|
|
||||||
visit_list_elements(&v, instructions);
|
visit_list_elements(&v, instructions);
|
||||||
|
|
||||||
|
@@ -102,7 +102,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
|
|||||||
} else if (strcmp(optimization, "do_tree_grafting") == 0) {
|
} else if (strcmp(optimization, "do_tree_grafting") == 0) {
|
||||||
return do_tree_grafting(ir);
|
return do_tree_grafting(ir);
|
||||||
} else if (strcmp(optimization, "do_vec_index_to_cond_assign") == 0) {
|
} else if (strcmp(optimization, "do_vec_index_to_cond_assign") == 0) {
|
||||||
return do_vec_index_to_cond_assign(ir, true);
|
return do_vec_index_to_cond_assign(ir);
|
||||||
} else if (strcmp(optimization, "do_vec_index_to_swizzle") == 0) {
|
} else if (strcmp(optimization, "do_vec_index_to_swizzle") == 0) {
|
||||||
return do_vec_index_to_swizzle(ir);
|
return do_vec_index_to_swizzle(ir);
|
||||||
} else if (strcmp(optimization, "lower_discard") == 0) {
|
} else if (strcmp(optimization, "lower_discard") == 0) {
|
||||||
|
@@ -130,7 +130,7 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
IMUL_HIGH_TO_MUL
|
IMUL_HIGH_TO_MUL
|
||||||
: 0));
|
: 0));
|
||||||
|
|
||||||
do_vec_index_to_cond_assign(ir, false);
|
do_vec_index_to_cond_assign(ir);
|
||||||
lower_vector_insert(ir, true);
|
lower_vector_insert(ir, true);
|
||||||
if (options->MaxIfDepth == 0) {
|
if (options->MaxIfDepth == 0) {
|
||||||
lower_discard(ir);
|
lower_discard(ir);
|
||||||
|
Reference in New Issue
Block a user