Module: Mesa Branch: staging/22.1 Commit: 5a9ef84f103a0ace6eacb010547a781cefdc713a URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5a9ef84f103a0ace6eacb010547a781cefdc713a
Author: Jason Ekstrand <[email protected]> Date: Wed Jul 20 13:45:45 2022 -0500 vulkan/nir: Don't remove dead XFB outputs Fixes: 21b405fbbc53 ("vulkan: Add a vk_shader_module_to_nir() helper") Reviewed-By: Mike Blumenkrantz <[email protected]> Reviewed-by: Lionel Landwerlin <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17644> (cherry picked from commit bd93d6f69373cbc9dc5d32fbde1dd4a119a307c9) --- .pick_status.json | 2 +- src/vulkan/runtime/vk_nir.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f7a6e00f750..0717b7e4f8e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -2731,7 +2731,7 @@ "description": "vulkan/nir: Don't remove dead XFB outputs", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "21b405fbbc539666f83bd881011c9d7333d6b060" }, diff --git a/src/vulkan/runtime/vk_nir.c b/src/vulkan/runtime/vk_nir.c index e8c05697585..327efdfe42c 100644 --- a/src/vulkan/runtime/vk_nir.c +++ b/src/vulkan/runtime/vk_nir.c @@ -64,6 +64,16 @@ spirv_nir_debug(void *private_data, } } +static bool +is_not_xfb_output(nir_variable *var, void *data) +{ + if (var->data.mode != nir_var_shader_out) + return true; + + return !var->data.explicit_xfb_buffer && + !var->data.explicit_xfb_stride; +} + nir_shader * vk_spirv_to_nir(struct vk_device *device, uint32_t *spirv_data, size_t spirv_size_B, @@ -129,10 +139,13 @@ vk_spirv_to_nir(struct vk_device *device, NIR_PASS_V(nir, nir_split_var_copies); NIR_PASS_V(nir, nir_split_per_member_structs); + nir_remove_dead_variables_options dead_vars_opts = { + .can_remove_var = is_not_xfb_output, + }; NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_shader_in | nir_var_shader_out | nir_var_system_value | nir_var_shader_call_data | nir_var_ray_hit_attrib, - NULL); + &dead_vars_opts); NIR_PASS_V(nir, nir_propagate_invariant, false);
