From 98ce4a98ae734ac613cb078121520c48a5a94e10 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Mon, 15 Apr 2024 12:27:19 -0400 Subject: [PATCH] nir/remove_unused_io_vars: check all components to determine variable liveness this otherwise only checked the first component cc: mesa-stable Reviewed-by: Connor Abbott Part-of: --- src/compiler/nir/nir_linking_helpers.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index 4becf8a207f..d5f335b6a0e 100644 --- a/src/compiler/nir/nir_linking_helpers.c +++ b/src/compiler/nir/nir_linking_helpers.c @@ -120,11 +120,6 @@ tcs_add_output_reads(nir_shader *shader, uint64_t *read, uint64_t *patches_read) * progress = nir_remove_unused_io_vars(producer, nir_var_shader_out, * read, patches_read) || * progress; - * - * The "used" should be an array of 4 uint64_ts (probably of VARYING_BIT_*) - * representing each .location_frac used. Note that for vector variables, - * only the first channel (.location_frac) is examined for deciding if the - * variable is used! */ bool nir_remove_unused_io_vars(nir_shader *shader, @@ -153,7 +148,9 @@ nir_remove_unused_io_vars(nir_shader *shader, if (var->data.explicit_xfb_buffer) continue; - uint64_t other_stage = used[var->data.location_frac]; + uint64_t other_stage = 0; + for (unsigned i = 0; i < get_num_components(var); i++) + other_stage |= used[var->data.location_frac + i]; if (!(other_stage & get_variable_io_mask(var, shader->info.stage))) { /* This one is invalid, make it a global variable instead */