From 5e2893babe565b917c1ccef582366b6ad68d7adb 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: (cherry picked from commit 98ce4a98ae734ac613cb078121520c48a5a94e10) --- .pick_status.json | 2 +- src/compiler/nir/nir_linking_helpers.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 47e6f4d7abb..5167944856e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2534,7 +2534,7 @@ "description": "nir/remove_unused_io_vars: check all components to determine variable liveness", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/compiler/nir/nir_linking_helpers.c b/src/compiler/nir/nir_linking_helpers.c index f3be6b1c6f6..44d632f0a56 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 */