From e8ff9eb9cba900eed05b58092c2983a142588578 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Thu, 31 Jul 2025 14:49:30 -0400 Subject: [PATCH] nir/opt_varyings: link interpolation qualifiers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Marek Olšák Part-of: --- src/compiler/nir/nir_opt_varyings.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/compiler/nir/nir_opt_varyings.c b/src/compiler/nir/nir_opt_varyings.c index 3b9ef2e749f..820808238b4 100644 --- a/src/compiler/nir/nir_opt_varyings.c +++ b/src/compiler/nir/nir_opt_varyings.c @@ -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; + } }