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 <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41226>
This commit is contained in:
Marek Olšák 2026-05-11 11:38:13 -04:00 committed by Marge Bot
parent feeaae1c28
commit 933b25b0b6
3 changed files with 12 additions and 3 deletions

View file

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

View file

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

View file

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