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 <cwabbott0@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28751>
(cherry picked from commit 98ce4a98ae)
This commit is contained in:
Mike Blumenkrantz 2024-04-15 12:27:19 -04:00 committed by Eric Engestrom
parent b0c7292db5
commit 5e2893babe
2 changed files with 4 additions and 7 deletions

View file

@ -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

View file

@ -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 */