nir/opt_varyings: add nir_io_always_interpolate_convergent_fs_inputs

for Asahi

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32174>
This commit is contained in:
Marek Olšák 2024-11-01 23:06:03 -04:00 committed by Marge Bot
parent 95bc42af74
commit 8518e1cfd7
3 changed files with 19 additions and 2 deletions

View file

@ -334,4 +334,5 @@ static const nir_shader_compiler_options agx_nir_options = {
.compact_arrays = true,
.discard_is_demote = true,
.scalarize_ddx = true,
.io_options = nir_io_always_interpolate_convergent_fs_inputs,
};

View file

@ -3830,6 +3830,12 @@ typedef enum {
*/
nir_io_vectorizer_ignores_types = BITFIELD_BIT(6),
/**
* Whether nir_opt_varyings should never promote convergent FS inputs
* to flat.
*/
nir_io_always_interpolate_convergent_fs_inputs = BITFIELD_BIT(7),
/* Options affecting the GLSL compiler or Gallium are below. */
/**

View file

@ -598,6 +598,7 @@ struct linkage_info {
bool can_move_uniforms;
bool can_move_ubos;
bool can_mix_convergent_flat_with_interpolated;
bool always_interpolate_convergent_fs_inputs;
gl_shader_stage producer_stage;
gl_shader_stage consumer_stage;
@ -4021,7 +4022,8 @@ fs_assign_slot_groups(struct linkage_info *linkage,
* the unused components of interpolated (if any), and then make
* the remaining convergent inputs flat.
*/
if (unused_flat_slots) {
if (!linkage->always_interpolate_convergent_fs_inputs &&
unused_flat_slots) {
fs_assign_slots(linkage, assigned_mask, assigned_fs_vec4_type,
convergent_mask, FS_VEC4_TYPE_FLAT,
slot_size, unused_flat_slots, true, assign_colors,
@ -4040,7 +4042,11 @@ fs_assign_slot_groups(struct linkage_info *linkage,
color_channel_rotate, progress);
}
fs_assign_slots(linkage, assigned_mask, assigned_fs_vec4_type,
convergent_mask, FS_VEC4_TYPE_FLAT,
convergent_mask,
linkage->always_interpolate_convergent_fs_inputs ?
(slot_size == 2 ? FS_VEC4_TYPE_INTERP_FP32 :
FS_VEC4_TYPE_INTERP_FP16) :
FS_VEC4_TYPE_FLAT,
slot_size, NUM_SCALAR_SLOTS, true, assign_colors,
color_channel_rotate, progress);
}
@ -4260,6 +4266,10 @@ init_linkage(nir_shader *producer, nir_shader *consumer, bool spirv,
consumer->info.stage == MESA_SHADER_FRAGMENT &&
consumer->options->io_options &
nir_io_mix_convergent_flat_with_interpolated,
.always_interpolate_convergent_fs_inputs =
consumer->info.stage == MESA_SHADER_FRAGMENT &&
consumer->options->io_options &
nir_io_always_interpolate_convergent_fs_inputs,
.producer_stage = producer->info.stage,
.consumer_stage = consumer->info.stage,
.producer_builder =