nir: Take a mode in remove_unused_io_vars
[mesa.git] / src / broadcom / compiler / vir.c
index 940d3402ec73ff44714ea4bf00a9798c7848d7ad..4482f7825a6d31d1336a83962fcd3c233a5bc2dd 100644 (file)
@@ -809,7 +809,7 @@ v3d_nir_lower_vs_early(struct v3d_compile *c)
                 used_outputs[comp] |= 1ull << slot;
         }
         NIR_PASS_V(c->s, nir_remove_unused_io_vars,
-                   &c->s->outputs, used_outputs, NULL); /* demotes to globals */
+                   nir_var_shader_out, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
         NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in, NULL);
@@ -840,7 +840,7 @@ v3d_nir_lower_gs_early(struct v3d_compile *c)
                 used_outputs[comp] |= 1ull << slot;
         }
         NIR_PASS_V(c->s, nir_remove_unused_io_vars,
-                   &c->s->outputs, used_outputs, NULL); /* demotes to globals */
+                   nir_var_shader_out, used_outputs, NULL); /* demotes to globals */
         NIR_PASS_V(c->s, nir_lower_global_vars_to_local);
         v3d_optimize_nir(c->s);
         NIR_PASS_V(c->s, nir_remove_dead_variables, nir_var_shader_in, NULL);
@@ -954,9 +954,15 @@ v3d_nir_lower_fs_late(struct v3d_compile *c)
                            false, NULL);
         }
 
+        /* In OpenGL the fragment shader can't read gl_ClipDistance[], but
+         * Vulkan allows it, in which case the SPIR-V compiler will declare
+         * VARING_SLOT_CLIP_DIST0 as compact array variable. Pass true as
+         * the last parameter to always operate with a compact array in both
+         * OpenGL and Vulkan so we do't have to care about the API we
+         * are using.
+         */
         if (c->key->ucp_enables)
-                NIR_PASS_V(c->s, nir_lower_clip_fs, c->key->ucp_enables,
-                           false);
+                NIR_PASS_V(c->s, nir_lower_clip_fs, c->key->ucp_enables, true);
 
         /* Note: FS input scalarizing must happen after
          * nir_lower_two_sided_color, which only handles a vec4 at a time.