From aaf531dcd0428f6ea8da6348c0af4b5d880ce689 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 12 May 2025 22:26:07 -0400 Subject: [PATCH] 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 Part-of: (cherry picked from commit a1ee6d6730ed72f063b56bd98fc658971f4df1e3) --- .pick_status.json | 2 +- src/compiler/nir/nir_lower_io.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 5b9d61943a8..52e5113037e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -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 diff --git a/src/compiler/nir/nir_lower_io.c b/src/compiler/nir/nir_lower_io.c index 950b1216c3d..71063467ce0 100644 --- a/src/compiler/nir/nir_lower_io.c +++ b/src/compiler/nir/nir_lower_io.c @@ -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; }