vulkan: Call lower_clip_cull_distance_arrays in vk_spirv_to_nir
authorJason Ekstrand <jason.ekstrand@collabora.com>
Wed, 20 Jul 2022 00:19:42 +0000 (19:19 -0500)
committerMarge Bot <emma+marge@anholt.net>
Thu, 21 Jul 2022 21:18:48 +0000 (21:18 +0000)
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17644>

src/broadcom/vulkan/v3dv_pipeline.c
src/freedreno/vulkan/tu_shader.c
src/intel/compiler/brw_nir.c
src/vulkan/runtime/vk_nir.c

index 0900ea8..0021bac 100644 (file)
@@ -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);
 
index 79e4ebb..eb5a91c 100644 (file)
@@ -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);
index 4f36363..659d10c 100644 (file)
@@ -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);
index 3ad3ec9..2d8a691 100644 (file)
@@ -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;