r600/sfn: Use nir_foreach_variable_with_modes in IO vectorization
Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
This commit is contained in:
parent
cc51cec9c0
commit
568022be75
|
@ -84,7 +84,7 @@ protected:
|
|||
InstrSet m_block_io;
|
||||
int m_next_index;
|
||||
private:
|
||||
virtual exec_list *get_io_list(nir_shader *shader) const = 0;
|
||||
virtual nir_variable_mode get_io_mode(nir_shader *shader) const = 0;
|
||||
virtual bool instr_can_rewrite_type(nir_intrinsic_instr *intr) const = 0;
|
||||
virtual bool var_can_rewrite_slot(nir_variable *var) const = 0;
|
||||
virtual void create_new_io(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var,
|
||||
|
@ -98,7 +98,7 @@ public:
|
|||
NirLowerFSOutToVector();
|
||||
|
||||
private:
|
||||
exec_list *get_io_list(nir_shader *shader) const override;
|
||||
nir_variable_mode get_io_mode(nir_shader *shader) const override;
|
||||
bool var_can_rewrite_slot(nir_variable *var) const override;
|
||||
void create_new_io(nir_builder *b, nir_intrinsic_instr *intr, nir_variable *var,
|
||||
nir_ssa_def **srcs, unsigned first_comp, unsigned num_comps) override;
|
||||
|
@ -150,17 +150,20 @@ bool NirLowerIOToVector::run(nir_function_impl *impl)
|
|||
|
||||
void NirLowerIOToVector::create_new_io_vars(nir_shader *shader)
|
||||
{
|
||||
struct exec_list *io_list = get_io_list(shader);
|
||||
if (exec_list_is_empty(io_list))
|
||||
return;
|
||||
nir_variable_mode mode = get_io_mode(shader);
|
||||
|
||||
nir_foreach_variable(var, io_list) {
|
||||
bool can_rewrite_vars = false;
|
||||
nir_foreach_variable_with_modes(var, shader, mode) {
|
||||
if (var_can_rewrite(var)) {
|
||||
can_rewrite_vars = true;
|
||||
unsigned loc = var->data.location - m_base_slot;
|
||||
m_vars[loc][var->data.location_frac] = var;
|
||||
}
|
||||
}
|
||||
|
||||
if (!can_rewrite_vars)
|
||||
return;
|
||||
|
||||
/* We don't handle combining vars of different type e.g. different array
|
||||
* lengths.
|
||||
*/
|
||||
|
@ -385,9 +388,9 @@ bool NirLowerIOToVector::vec_instr_stack_pop(nir_builder *b, InstrSubSet &ir_set
|
|||
return true;
|
||||
}
|
||||
|
||||
exec_list *NirLowerFSOutToVector::get_io_list(nir_shader *shader) const
|
||||
nir_variable_mode NirLowerFSOutToVector::get_io_mode(nir_shader *shader) const
|
||||
{
|
||||
return &shader->outputs;
|
||||
return nir_var_shader_out;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -376,19 +376,21 @@ r600_variables_can_merge(const nir_variable *lhs, const nir_variable *rhs)
|
|||
}
|
||||
|
||||
static void
|
||||
r600_create_new_io_vars(nir_shader *shader, struct exec_list *io_list,
|
||||
r600_create_new_io_vars(nir_shader *shader, nir_variable_mode mode,
|
||||
nir_variable *vars[16][4])
|
||||
{
|
||||
if (exec_list_is_empty(io_list))
|
||||
return;
|
||||
|
||||
nir_foreach_variable(var, io_list) {
|
||||
bool can_rewrite_vars = false;
|
||||
nir_foreach_variable_with_modes(var, shader, mode) {
|
||||
if (r600_variable_can_rewrite(var)) {
|
||||
can_rewrite_vars = true;
|
||||
unsigned loc = r600_correct_location(var);
|
||||
vars[loc][var->data.location_frac] = var;
|
||||
}
|
||||
}
|
||||
|
||||
if (!can_rewrite_vars)
|
||||
return;
|
||||
|
||||
/* We don't handle combining vars of different type e.g. different array
|
||||
* lengths.
|
||||
*/
|
||||
|
@ -432,7 +434,7 @@ r600_vectorize_io_impl(nir_function_impl *impl)
|
|||
nir_shader *shader = impl->function->shader;
|
||||
nir_variable *updated_vars[16][4] = {0};
|
||||
|
||||
r600_create_new_io_vars(shader, &shader->inputs, updated_vars);
|
||||
r600_create_new_io_vars(shader, nir_var_shader_in, updated_vars);
|
||||
|
||||
struct set *instr_set = r600_vec_instr_set_create();
|
||||
bool progress = r600_vectorize_block(&b, nir_start_block(impl), instr_set,
|
||||
|
|
Loading…
Reference in New Issue