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");