nir: fix clip/cull_distance_array_size in nir_lower_clip_cull_distance_arrays
authorMarek Olšák <marek.olsak@amd.com>
Fri, 13 Mar 2020 21:54:35 +0000 (17:54 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 19 Mar 2020 05:47:28 +0000 (01:47 -0400)
This fixes a GPU hang on radeonsi.

It only works if optimizations have already been run.

Cc: 19.3 20.0 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4194>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4194>

src/compiler/nir/nir_lower_clip_cull_distance_arrays.c

index 70578d6f3fd3631b64143c2ea57cb67f767a675b..7587bb26e094c52371fe0071b1700b6876ada511 100644 (file)
@@ -72,8 +72,17 @@ combine_clip_cull(nir_shader *nir,
          cull = var;
    }
 
-   if (!cull && !clip)
+   if (!cull && !clip) {
+      /* If this is run after optimizations and the variables have been
+       * eliminated, we should update the shader info, because no other
+       * place does that.
+       */
+      if (store_info) {
+         nir->info.clip_distance_array_size = 0;
+         nir->info.cull_distance_array_size = 0;
+      }
       return false;
+   }
 
    if (!cull && clip) {
       /* The GLSL IR lowering pass must have converted these to vectors */