glsl: Stop lowering ir_quadop_vector.

Now that everybody goes through NIR, glsl_to_nir is happy to handle the
instruction and turn it into nir_op_vec4 instead of going to a temp
variable and back.

No changes on freedreno shader-db.

Reviewed-by: Rob Clark <robdclark@chromium.org>
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/16363>
This commit is contained in:
Emma Anholt
2022-04-20 16:37:46 -07:00
committed by Marge Bot
parent b4957cdfca
commit 23cde71bb9
5 changed files with 0 additions and 160 deletions

View File

@@ -127,7 +127,6 @@ bool do_vec_index_to_swizzle(exec_list *instructions);
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_quadop_vector(exec_list *instructions);
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,
gl_linked_shader *shader);

View File

@@ -1,155 +0,0 @@
/*
* Copyright © 2010 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/**
* \file lower_vector.cpp
* IR lowering pass to remove some types of ir_quadop_vector
*
* \author Ian Romanick <ian.d.romanick@intel.com>
*/
#include "ir.h"
#include "ir_rvalue_visitor.h"
namespace {
class lower_vector_visitor : public ir_rvalue_visitor {
public:
lower_vector_visitor() : progress(false)
{
/* empty */
}
void handle_rvalue(ir_rvalue **rvalue);
bool progress;
};
} /* anonymous namespace */
void
lower_vector_visitor::handle_rvalue(ir_rvalue **rvalue)
{
if (!*rvalue)
return;
ir_expression *expr = (*rvalue)->as_expression();
if ((expr == NULL) || (expr->operation != ir_quadop_vector))
return;
/* FINISHME: Is this the right thing to use for the ralloc context?
*/
void *const mem_ctx = expr;
assert(expr->type->vector_elements == expr->num_operands);
/* Generate a temporary with the same type as the ir_quadop_operation.
*/
ir_variable *const temp =
new(mem_ctx) ir_variable(expr->type, "vecop_tmp", ir_var_temporary);
this->base_ir->insert_before(temp);
/* Counter of the number of components collected so far.
*/
unsigned assigned;
/* Write-mask in the destination that receives counted by 'assigned'.
*/
unsigned write_mask;
/* Generate upto four assignments to that variable. Try to group component
* assignments together:
*
* - All constant components can be assigned at once.
* - All assigments of components from a single variable with the same
* unary operator can be assigned at once.
*/
ir_constant_data d = { { 0 } };
assigned = 0;
write_mask = 0;
for (unsigned i = 0; i < expr->type->vector_elements; i++) {
const ir_constant *const c = expr->operands[i]->as_constant();
if (c == NULL)
continue;
switch (expr->type->base_type) {
case GLSL_TYPE_UINT: d.u[assigned] = c->value.u[0]; break;
case GLSL_TYPE_INT: d.i[assigned] = c->value.i[0]; break;
case GLSL_TYPE_FLOAT: d.f[assigned] = c->value.f[0]; break;
case GLSL_TYPE_BOOL: d.b[assigned] = c->value.b[0]; break;
default: assert(!"Should not get here."); break;
}
write_mask |= (1U << i);
assigned++;
}
assert((write_mask == 0) == (assigned == 0));
/* If there were constant values, generate an assignment.
*/
if (assigned > 0) {
ir_constant *const c =
new(mem_ctx) ir_constant(glsl_type::get_instance(expr->type->base_type,
assigned, 1),
&d);
ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
ir_assignment *const assign =
new(mem_ctx) ir_assignment(lhs, c, write_mask);
this->base_ir->insert_before(assign);
}
/* FINISHME: This should try to coalesce assignments.
*/
for (unsigned i = 0; i < expr->type->vector_elements; i++) {
if (expr->operands[i]->ir_type == ir_type_constant)
continue;
ir_dereference *const lhs = new(mem_ctx) ir_dereference_variable(temp);
ir_assignment *const assign =
new(mem_ctx) ir_assignment(lhs, expr->operands[i], 1U << i);
this->base_ir->insert_before(assign);
assigned++;
}
assert(assigned == expr->type->vector_elements);
*rvalue = new(mem_ctx) ir_dereference_variable(temp);
this->progress = true;
}
bool
lower_quadop_vector(exec_list *instructions)
{
lower_vector_visitor v;
visit_list_elements(&v, instructions);
return v.progress;
}

View File

@@ -174,7 +174,6 @@ files_libglsl = files(
'lower_tess_level.cpp',
'lower_vec_index_to_cond_assign.cpp',
'lower_vec_index_to_swizzle.cpp',
'lower_vector.cpp',
'lower_vector_derefs.cpp',
'lower_vector_insert.cpp',
'lower_vertex_id.cpp',

View File

@@ -110,8 +110,6 @@ do_optimization(struct exec_list *ir, const char *optimization,
} else if (sscanf(optimization, "lower_instructions ( %d ) ",
&int_0) == 1) {
return lower_instructions(ir, int_0);
} else if (sscanf(optimization, "lower_quadop_vector") == 1) {
return lower_quadop_vector(ir);
} else {
printf("Unrecognized optimization %s\n", optimization);
exit(EXIT_FAILURE);

View File

@@ -132,7 +132,6 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
do_vec_index_to_cond_assign(ir);
lower_vector_insert(ir, true);
lower_quadop_vector(ir);
if (options->MaxIfDepth == 0) {
lower_discard(ir);
}