From bb4bdba17e807860ef096df9acffea4e57da76ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timur=20Krist=C3=B3f?= Date: Sat, 10 Sep 2022 02:00:33 +0200 Subject: [PATCH] radv: Remove dead shader temps after linking. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent nir_lower_scratch accidentally turning these dead variables into scratch. This can especially happen to arrayed outputs of eg. tess control or mesh shaders, which become large shader temps. Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- src/amd/vulkan/radv_pipeline.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c index 1b7bc7f4ef3..cdabd89eb66 100644 --- a/src/amd/vulkan/radv_pipeline.c +++ b/src/amd/vulkan/radv_pipeline.c @@ -2399,6 +2399,14 @@ radv_pipeline_link_shaders(const struct radv_device *device, progress = nir_remove_unused_varyings(producer, consumer); nir_compact_varyings(producer, consumer, true); + + /* nir_compact_varyings changes deleted varyings into shader_temp. + * We need to remove these otherwise we risk them being lowered to scratch. + * This can especially happen to arrayed outputs. + */ + NIR_PASS(_, producer, nir_remove_dead_variables, nir_var_shader_temp, NULL); + NIR_PASS(_, consumer, nir_remove_dead_variables, nir_var_shader_temp, NULL); + nir_validate_shader(producer, "after nir_compact_varyings"); nir_validate_shader(consumer, "after nir_compact_varyings");