nir/opt_varyings: link interpolation qualifiers

Some hardware (AGX, Imagination, Arm) really want to know the interpolation
qualifiers when compiling the vertex shader. Even though we need to handle this
dynamic for separate shaders, we can improve performance by linking.
nir_opt_varyings already has all the information to do this, so just do so.

Note this has to be done in common code for Gallium, which links varyings within
the GLSL linker but then presents the linked programs as separate shader
objects. This models that nicely, allowing Gallium drivers to optimize without
weird sidebands.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36501>
This commit is contained in:
Alyssa Rosenzweig 2025-07-31 14:49:30 -04:00 committed by Marge Bot
parent 66740d9c91
commit e8ff9eb9cb

View file

@ -5565,4 +5565,16 @@ nir_opt_varyings_bulk(nir_shader **shaders, uint32_t num_shaders, bool spirv,
if (nir->xfb_info)
nir_gather_xfb_info_from_intrinsics(nir);
}
/* Now that we've picked slots, link interpolation qualifiers. */
nir_shader *fs = shaders[num_shaders - 1];
if (fs->info.stage == MESA_SHADER_FRAGMENT) {
nir_shader *producer = shaders[num_shaders - 2];
producer->info.known_interpolation_qualifiers =
fs->info.known_interpolation_qualifiers;
producer->info.linear_varyings = fs->info.linear_varyings;
producer->info.perspective_varyings = fs->info.perspective_varyings;
}
}