From d29dd3333b299c9b127d1f1cc113aedced488f46 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Tue, 28 Feb 2023 14:59:09 -0500 Subject: [PATCH] nir: assign IO bases in nir_lower_io_passes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Qiang Yu Reviewed-by: Timur Kristóf Part-of: --- src/compiler/nir/nir_lower_io.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index fd405ae..8e118b0 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -3122,6 +3122,10 @@ type_size_vec4(const struct glsl_type *type, bool bindless) return glsl_count_attribute_slots(type, false); } +/** + * This runs all compiler passes needed to lower IO, lower indirect IO access, + * set transform feedback info in IO intrinsics, and clean up the IR. + */ void nir_lower_io_passes(nir_shader *nir) { @@ -3156,6 +3160,20 @@ nir_lower_io_passes(nir_shader *nir) NIR_PASS_V(nir, nir_lower_io, nir_var_shader_out | nir_var_shader_in, type_size_vec4, nir_lower_io_lower_64bit_to_32); + /* If IO is lowered before var->data.driver_location is assigned, driver + * locations are all 0, which means IO bases are all 0. It's not necessary + * to set driver_location before lowering IO because the only thing that + * identifies outputs is their semantic, and IO bases can always be + * computed from the semantics. + * + * This assigns IO bases from scratch, using IO semantics to tell which + * intrinsics refer to the same IO. If the bases already exist, they + * will be reassigned, sorted by the semantic, and all holes removed. + * This kind of canonicalizes all bases. + */ + NIR_PASS_V(nir, nir_recompute_io_bases, + nir_var_shader_in | nir_var_shader_out); + /* nir_io_add_const_offset_to_base needs actual constants. */ NIR_PASS_V(nir, nir_opt_constant_folding); NIR_PASS_V(nir, nir_io_add_const_offset_to_base, nir_var_shader_in | -- 2.7.4