nir: fix gathering color interp modes in nir_lower_color_inputs

Fixes: 709ebd82 ("amd: expose nir_io_mix_convergent_flat_with_interpolated")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/12800

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34942>
(cherry picked from commit a1ee6d6730)
This commit is contained in:
Marek Olšák 2025-05-12 22:26:07 -04:00 committed by Eric Engestrom
parent ee0984f840
commit aaf531dcd0
2 changed files with 13 additions and 3 deletions

View file

@ -494,7 +494,7 @@
"description": "nir: fix gathering color interp modes in nir_lower_color_inputs",
"nominated": true,
"nomination_type": 2,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "709ebd8293a678db614c5b48dac2fc1da0b2306d",
"notes": null

View file

@ -3146,6 +3146,14 @@ nir_lower_color_inputs(nir_shader *nir)
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
bool progress = false;
/* Both flat and non-flat can occur with nir_io_mix_convergent_flat_with_interpolated,
* but we want to save only the non-flat interp mode in that case.
*
* Start with flat and set to non-flat only if it's present.
*/
nir->info.fs.color0_interp = INTERP_MODE_FLAT;
nir->info.fs.color1_interp = INTERP_MODE_FLAT;
nir_builder b = nir_builder_create(impl);
nir_foreach_block(block, impl) {
@ -3189,13 +3197,15 @@ nir_lower_color_inputs(nir_shader *nir)
if (sem.location == VARYING_SLOT_COL0) {
load = nir_load_color0(&b);
nir->info.fs.color0_interp = interp;
if (interp != INTERP_MODE_FLAT)
nir->info.fs.color0_interp = interp;
nir->info.fs.color0_sample = sample;
nir->info.fs.color0_centroid = centroid;
} else {
assert(sem.location == VARYING_SLOT_COL1);
load = nir_load_color1(&b);
nir->info.fs.color1_interp = interp;
if (interp != INTERP_MODE_FLAT)
nir->info.fs.color1_interp = interp;
nir->info.fs.color1_sample = sample;
nir->info.fs.color1_centroid = centroid;
}