From 87ab28743603f034710ccc99e5b32e3b04c4a442 Mon Sep 17 00:00:00 2001 From: Jason Ekstrand Date: Tue, 19 Jul 2022 19:19:42 -0500 Subject: [PATCH] vulkan: Call lower_clip_cull_distance_arrays in vk_spirv_to_nir Reviewed-by: Iago Toral Quiroga Reviewed-By: Mike Blumenkrantz Reviewed-by: Lionel Landwerlin Part-of: --- src/broadcom/vulkan/v3dv_pipeline.c | 1 - src/freedreno/vulkan/tu_shader.c | 2 -- src/intel/compiler/brw_nir.c | 2 -- src/vulkan/runtime/vk_nir.c | 6 ++++++ 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 0900ea80177..0021bac3448 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -385,7 +385,6 @@ preprocess_nir(nir_shader *nir) nir_shader_get_entrypoint(nir), true, false); NIR_PASS(_, nir, nir_lower_system_values); - NIR_PASS(_, nir, nir_lower_clip_cull_distance_arrays); NIR_PASS(_, nir, nir_lower_alu_to_scalar, NULL, NULL); diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c index 79e4ebb675a..eb5a91cd2fc 100644 --- a/src/freedreno/vulkan/tu_shader.c +++ b/src/freedreno/vulkan/tu_shader.c @@ -128,8 +128,6 @@ tu_spirv_to_nir(struct tu_device *dev, NIR_PASS_V(nir, nir_lower_system_values); - NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays); - NIR_PASS_V(nir, nir_lower_frexp); ir3_optimize_loop(dev->compiler, nir); diff --git a/src/intel/compiler/brw_nir.c b/src/intel/compiler/brw_nir.c index 4f363637e6e..659d10c4f00 100644 --- a/src/intel/compiler/brw_nir.c +++ b/src/intel/compiler/brw_nir.c @@ -894,8 +894,6 @@ brw_preprocess_nir(const struct brw_compiler *compiler, nir_shader *nir, }; OPT(nir_lower_subgroups, &subgroups_options); - OPT(nir_lower_clip_cull_distance_arrays); - nir_variable_mode indirect_mask = brw_nir_no_indirect_mask(compiler, nir->info.stage); OPT(nir_lower_indirect_derefs, indirect_mask, UINT32_MAX); diff --git a/src/vulkan/runtime/vk_nir.c b/src/vulkan/runtime/vk_nir.c index 3ad3ec9fe83..2d8a691f2b7 100644 --- a/src/vulkan/runtime/vk_nir.c +++ b/src/vulkan/runtime/vk_nir.c @@ -132,6 +132,12 @@ vk_spirv_to_nir(struct vk_device *device, nir_var_shader_call_data | nir_var_ray_hit_attrib, NULL); + /* This needs to happen after remove_dead_vars because GLSLang likes to + * insert dead clip/cull vars and we don't want to clip/cull based on + * uninitialized garbage. + */ + NIR_PASS_V(nir, nir_lower_clip_cull_distance_arrays); + NIR_PASS_V(nir, nir_propagate_invariant, false); return nir;