glsl: Delete dont_lower_swz path of lower_quadop_vector.
This was last used with Mesa classic, in _mesa_ir_link_shader(). Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15623>
This commit is contained in:
@@ -133,7 +133,7 @@ bool lower_instructions(exec_list *instructions, unsigned what_to_lower);
|
|||||||
bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
|
bool lower_variable_index_to_cond_assign(gl_shader_stage stage,
|
||||||
exec_list *instructions, bool lower_input, bool lower_output,
|
exec_list *instructions, bool lower_input, bool lower_output,
|
||||||
bool lower_temp, bool lower_uniform);
|
bool lower_temp, bool lower_uniform);
|
||||||
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
|
bool lower_quadop_vector(exec_list *instructions);
|
||||||
bool lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage, unsigned max_uniform_components);
|
bool lower_const_arrays_to_uniforms(exec_list *instructions, unsigned stage, unsigned max_uniform_components);
|
||||||
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
||||||
gl_linked_shader *shader);
|
gl_linked_shader *shader);
|
||||||
|
@@ -35,87 +35,18 @@ namespace {
|
|||||||
|
|
||||||
class lower_vector_visitor : public ir_rvalue_visitor {
|
class lower_vector_visitor : public ir_rvalue_visitor {
|
||||||
public:
|
public:
|
||||||
lower_vector_visitor() : dont_lower_swz(false), progress(false)
|
lower_vector_visitor() : progress(false)
|
||||||
{
|
{
|
||||||
/* empty */
|
/* empty */
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_rvalue(ir_rvalue **rvalue);
|
void handle_rvalue(ir_rvalue **rvalue);
|
||||||
|
|
||||||
/**
|
|
||||||
* Should SWZ-like expressions be lowered?
|
|
||||||
*/
|
|
||||||
bool dont_lower_swz;
|
|
||||||
|
|
||||||
bool progress;
|
bool progress;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* anonymous namespace */
|
} /* anonymous namespace */
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine if an IR expression tree looks like an extended swizzle
|
|
||||||
*
|
|
||||||
* Extended swizzles consist of access of a single vector source (with possible
|
|
||||||
* per component negation) and the constants -1, 0, or 1.
|
|
||||||
*/
|
|
||||||
static bool
|
|
||||||
is_extended_swizzle(ir_expression *ir)
|
|
||||||
{
|
|
||||||
/* Track any variables that are accessed by this expression.
|
|
||||||
*/
|
|
||||||
ir_variable *var = NULL;
|
|
||||||
|
|
||||||
assert(ir->operation == ir_quadop_vector);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < ir->type->vector_elements; i++) {
|
|
||||||
ir_rvalue *op = ir->operands[i];
|
|
||||||
|
|
||||||
while (op != NULL) {
|
|
||||||
switch (op->ir_type) {
|
|
||||||
case ir_type_constant: {
|
|
||||||
const ir_constant *const c = op->as_constant();
|
|
||||||
|
|
||||||
if (!c->is_one() && !c->is_zero() && !c->is_negative_one())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
op = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ir_type_dereference_variable: {
|
|
||||||
ir_dereference_variable *const d = (ir_dereference_variable *) op;
|
|
||||||
|
|
||||||
if ((var != NULL) && (var != d->var))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
var = d->var;
|
|
||||||
op = NULL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ir_type_expression: {
|
|
||||||
ir_expression *const ex = (ir_expression *) op;
|
|
||||||
|
|
||||||
if (ex->operation != ir_unop_neg)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
op = ex->operands[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case ir_type_swizzle:
|
|
||||||
op = ((ir_swizzle *) op)->val;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
|
lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
|
||||||
{
|
{
|
||||||
@@ -126,9 +57,6 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||||||
if ((expr == NULL) || (expr->operation != ir_quadop_vector))
|
if ((expr == NULL) || (expr->operation != ir_quadop_vector))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this->dont_lower_swz && is_extended_swizzle(expr))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* FINISHME: Is this the right thing to use for the ralloc context?
|
/* FINISHME: Is this the right thing to use for the ralloc context?
|
||||||
*/
|
*/
|
||||||
void *const mem_ctx = expr;
|
void *const mem_ctx = expr;
|
||||||
@@ -217,11 +145,10 @@ lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
lower_quadop_vector(exec_list *instructions, bool dont_lower_swz)
|
lower_quadop_vector(exec_list *instructions)
|
||||||
{
|
{
|
||||||
lower_vector_visitor v;
|
lower_vector_visitor v;
|
||||||
|
|
||||||
v.dont_lower_swz = dont_lower_swz;
|
|
||||||
visit_list_elements(&v, instructions);
|
visit_list_elements(&v, instructions);
|
||||||
|
|
||||||
return v.progress;
|
return v.progress;
|
||||||
|
@@ -120,9 +120,8 @@ do_optimization(struct exec_list *ir, const char *optimization,
|
|||||||
return lower_variable_index_to_cond_assign(MESA_SHADER_VERTEX, ir,
|
return lower_variable_index_to_cond_assign(MESA_SHADER_VERTEX, ir,
|
||||||
int_0 != 0, int_1 != 0,
|
int_0 != 0, int_1 != 0,
|
||||||
int_2 != 0, int_3 != 0);
|
int_2 != 0, int_3 != 0);
|
||||||
} else if (sscanf(optimization, "lower_quadop_vector ( %d ) ",
|
} else if (sscanf(optimization, "lower_quadop_vector") == 1) {
|
||||||
&int_0) == 1) {
|
return lower_quadop_vector(ir);
|
||||||
return lower_quadop_vector(ir, int_0 != 0);
|
|
||||||
} else {
|
} else {
|
||||||
printf("Unrecognized optimization %s\n", optimization);
|
printf("Unrecognized optimization %s\n", optimization);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@@ -161,7 +161,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
|
|
||||||
do_vec_index_to_cond_assign(ir);
|
do_vec_index_to_cond_assign(ir);
|
||||||
lower_vector_insert(ir, true);
|
lower_vector_insert(ir, true);
|
||||||
lower_quadop_vector(ir, false);
|
lower_quadop_vector(ir);
|
||||||
if (options->MaxIfDepth == 0) {
|
if (options->MaxIfDepth == 0) {
|
||||||
lower_discard(ir);
|
lower_discard(ir);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user