From e1e476e618c3a7de591273666da1d4ae69f524c5 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sun, 12 Apr 2026 14:53:30 +0200 Subject: [PATCH] radv: remove point size in lowered io MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We only need to deal with the fixed function last vertex stage case, for prior stages nir_opt_varyings is enough. Reviewed-by: Marek Olšák Reviewed-by: Samuel Pitoiset Part-of: --- src/amd/vulkan/radv_pipeline_graphics.c | 52 ++++++++++++++++--------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/amd/vulkan/radv_pipeline_graphics.c b/src/amd/vulkan/radv_pipeline_graphics.c index 6c60b705f3e..2dd78c9944d 100644 --- a/src/amd/vulkan/radv_pipeline_graphics.c +++ b/src/amd/vulkan/radv_pipeline_graphics.c @@ -2876,28 +2876,44 @@ radv_graphics_shaders_compile(struct radv_device *device, struct vk_pipeline_cac nir_shader_get_entrypoint(stages[MESA_SHADER_FRAGMENT].nir)); } - /* Remove all varyings when the fragment shader is a noop. */ - if (noop_fs) { - radv_foreach_stage (i, active_nir_stages) { - if (!radv_is_last_vgt_stage(&stages[i])) - continue; + radv_foreach_stage (i, active_nir_stages) { + if (!radv_is_last_vgt_stage(&stages[i])) + continue; - bool progress = false; + uint64_t remove_as_varying = 0; + uint64_t remove_as_sysval = 0; - /* Remove all output varyings. */ - NIR_PASS(progress, stages[i].nir, nir_remove_outputs, MESA_SHADER_FRAGMENT, ~0ull, 0); + /* Remove all varyings when the fragment shader is a noop. */ + if (noop_fs) + remove_as_varying |= ~0ull; - if (progress) { - /* Remove dead code resulting from removed output varyings. */ - do { - progress = false; - NIR_PASS(progress, stages[i].nir, nir_opt_dce); - NIR_PASS(progress, stages[i].nir, nir_opt_dead_cf); - } while (progress); - } - - break; + /* Remove PSIZ from shaders when it's not needed. + * This is typically produced by translation layers like Zink or d3d9 DXVK. + */ + if (gfx_state->enable_remove_point_size && (i != MESA_SHADER_TESS_EVAL || !stages[i].nir->info.tess.point_mode) && + (i != MESA_SHADER_GEOMETRY || stages[i].nir->info.gs.output_primitive != MESA_PRIM_POINTS) && + (i != MESA_SHADER_MESH || stages[i].nir->info.mesh.primitive_type != MESA_PRIM_POINTS)) { + remove_as_varying |= VARYING_BIT_PSIZ; + remove_as_sysval |= VARYING_BIT_PSIZ; } + + if (!remove_as_varying && !remove_as_sysval) + continue; + + bool progress = false; + + NIR_PASS(progress, stages[i].nir, nir_remove_outputs, MESA_SHADER_FRAGMENT, remove_as_varying, remove_as_sysval); + + if (progress) { + /* Remove dead code resulting from removed outputs. */ + do { + progress = false; + NIR_PASS(progress, stages[i].nir, nir_opt_dce); + NIR_PASS(progress, stages[i].nir, nir_opt_dead_cf); + } while (progress); + } + + break; } /* Optimize varyings on lowered shader I/O (more efficient than optimizing I/O derefs). */