From: Jason Ekstrand Date: Tue, 21 Jul 2020 23:21:56 +0000 (-0500) Subject: r600/sfn: Use nir_foreach_variable_with_modes in IO vectorization X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=568022be753126d82e4e746f42481d8789f10947 r600/sfn: Use nir_foreach_variable_with_modes in IO vectorization Reviewed-by: Gert Wollny Part-of: --- diff --git a/src/gallium/drivers/r600/sfn/sfn_nir_lower_fs_out_to_vector.cpp b/src/gallium/drivers/r600/sfn/sfn_nir_lower_fs_out_to_vector.cpp index 818c1f22566..f45a490c895 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir_lower_fs_out_to_vector.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_nir_lower_fs_out_to_vector.cpp @@ -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 diff --git a/src/gallium/drivers/r600/sfn/sfn_nir_vectorize_vs_inputs.c b/src/gallium/drivers/r600/sfn/sfn_nir_vectorize_vs_inputs.c index 16e43b79c0f..053d3e79306 100644 --- a/src/gallium/drivers/r600/sfn/sfn_nir_vectorize_vs_inputs.c +++ b/src/gallium/drivers/r600/sfn/sfn_nir_vectorize_vs_inputs.c @@ -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,