From 933b25b0b68c170b31efe2682c7352422092620a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Mon, 11 May 2026 11:38:13 -0400 Subject: [PATCH] nir: add an option to ignore INTERP_MODE_NONE in nir_shader_gather_info Color interpolation (INTERP_MODE_NONE) has unknown barycentrics and it could be flat shading at runtime. It's a problem when shader_info is expected to match what's actually used. Acked-by: Pierre-Eric Pelloux-Prayer Part-of: --- src/compiler/nir/nir_gather_info.c | 9 ++++++--- src/compiler/nir/nir_shader_compiler_options.h | 5 +++++ src/gallium/drivers/radeonsi/gfx/si_gfx_screen.c | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c index 5443adf8b4e..c29bf089b03 100644 --- a/src/compiler/nir/nir_gather_info.c +++ b/src/compiler/nir/nir_gather_info.c @@ -794,7 +794,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) case nir_intrinsic_load_barycentric_pixel: if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH || - nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) { + (!shader->options->ignore_none_interpolation_in_sysval_gathering && + nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE)) { BITSET_SET(shader->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL); } else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) { @@ -805,7 +806,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) case nir_intrinsic_load_barycentric_centroid: if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH || - nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) { + (!shader->options->ignore_none_interpolation_in_sysval_gathering && + nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE)) { BITSET_SET(shader->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID); } else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) { @@ -816,7 +818,8 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader) case nir_intrinsic_load_barycentric_sample: if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_SMOOTH || - nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE) { + (!shader->options->ignore_none_interpolation_in_sysval_gathering && + nir_intrinsic_interp_mode(instr) == INTERP_MODE_NONE)) { BITSET_SET(shader->info.system_values_read, SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE); } else if (nir_intrinsic_interp_mode(instr) == INTERP_MODE_NOPERSPECTIVE) { diff --git a/src/compiler/nir/nir_shader_compiler_options.h b/src/compiler/nir/nir_shader_compiler_options.h index 9d76a6f524d..fab88a77224 100644 --- a/src/compiler/nir/nir_shader_compiler_options.h +++ b/src/compiler/nir/nir_shader_compiler_options.h @@ -535,6 +535,11 @@ typedef struct nir_shader_compiler_options { */ bool unify_interfaces; + /** + * Whether nir_shader_gather_info ignores INTERP_MODE_NONE. + */ + bool ignore_none_interpolation_in_sysval_gathering; + /** * Whether nir_lower_io() will lower interpolateAt functions to * load_interpolated_input intrinsics. diff --git a/src/gallium/drivers/radeonsi/gfx/si_gfx_screen.c b/src/gallium/drivers/radeonsi/gfx/si_gfx_screen.c index cb95a474152..161e948f8f3 100644 --- a/src/gallium/drivers/radeonsi/gfx/si_gfx_screen.c +++ b/src/gallium/drivers/radeonsi/gfx/si_gfx_screen.c @@ -327,6 +327,7 @@ static void si_init_screen_nir_options(struct si_screen *sscreen) nir_shader_compiler_options *options = sscreen->nir_options; ac_nir_set_options(&sscreen->info.compiler_info, !sscreen->use_aco, options); + options->ignore_none_interpolation_in_sysval_gathering = true; options->lower_ffma16 = sscreen->info.gfx_level < GFX9; options->lower_ffma32 = !use_fma32; options->lower_ffma64 = false;