From dfb6ec7f93e91b88494921eb07c8b7c2012c517c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Sat, 22 Nov 2025 15:41:14 -0500 Subject: [PATCH] radeonsi: fix color interpolation when finalize_nir is called twice Calling finalize_nir twice causes si_nir_lower_color_inputs_to_sysvals to be called twice. The pass always sets color interpolation to FLAT at the beginning, and then lowers color input loads and sets the correct interpolation mode. However, when the pass is called for the second time, it just sets color interpolation to flat and does nothing, which overrides the original interpolation mode. This fixes color interpolation for those cases. This only happens with ATI_fragment_shader AFAIK. Fixes: deda05e2b71136c9620983c05628ac7defd5de3e - nir: move nir_lower_color_inputs into radeonsi Acked-by: Pierre-Eric Pelloux-Prayer (cherry picked from commit e5b1c568b91045c7a73e0193844a133b871b6448) Part-of: --- .pick_status.json | 2 +- .../si_nir_lower_color_inputs_to_sysvals.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 287dbfeca27..d1b36f064f9 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2004,7 +2004,7 @@ "description": "radeonsi: fix color interpolation when finalize_nir is called twice", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "deda05e2b71136c9620983c05628ac7defd5de3e", "notes": null diff --git a/src/gallium/drivers/radeonsi/si_nir_lower_color_inputs_to_sysvals.c b/src/gallium/drivers/radeonsi/si_nir_lower_color_inputs_to_sysvals.c index f2a21f68f67..a437489e1a8 100644 --- a/src/gallium/drivers/radeonsi/si_nir_lower_color_inputs_to_sysvals.c +++ b/src/gallium/drivers/radeonsi/si_nir_lower_color_inputs_to_sysvals.c @@ -12,11 +12,9 @@ bool si_nir_lower_color_inputs_to_sysvals(nir_shader *nir) /* 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; + bool color0_interp_mode_set = false; + bool color1_interp_mode_set = false; nir_builder b = nir_builder_create(impl); @@ -61,17 +59,21 @@ bool si_nir_lower_color_inputs_to_sysvals(nir_shader *nir) if (sem.location == VARYING_SLOT_COL0) { load = nir_load_color0(&b); - if (interp != INTERP_MODE_FLAT) + /* If both flat and non-flat are used, set non-flat. */ + if (!color0_interp_mode_set || interp != INTERP_MODE_FLAT) nir->info.fs.color0_interp = interp; nir->info.fs.color0_sample = sample; nir->info.fs.color0_centroid = centroid; + color0_interp_mode_set = true; } else { assert(sem.location == VARYING_SLOT_COL1); load = nir_load_color1(&b); - if (interp != INTERP_MODE_FLAT) + /* If both flat and non-flat are used, set non-flat. */ + if (!color1_interp_mode_set || interp != INTERP_MODE_FLAT) nir->info.fs.color1_interp = interp; nir->info.fs.color1_sample = sample; nir->info.fs.color1_centroid = centroid; + color1_interp_mode_set = true; } if (intrin->num_components != 4) {