* VS lowering
*/
-static void
-lower_clip_vs(nir_function_impl *impl, unsigned ucp_enables,
- nir_ssa_def *cv, nir_variable **out)
+/* ucp_enables is bitmask of enabled ucps. Actual ucp values are
+ * passed in to shader via user_clip_plane system-values
+ */
+bool
+nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
{
+ nir_function_impl *impl = nir_shader_get_entrypoint(shader);
nir_ssa_def *clipdist[MAX_CLIP_PLANES];
nir_builder b;
+ int clipvertex = -1;
+ int position = -1;
+ int maxloc = -1;
+ nir_ssa_def *cv;
+ nir_variable *out[2] = { NULL };
+
+ if (!ucp_enables)
+ return false;
nir_builder_init(&b, impl);
assert(impl->end_block->predecessors->entries == 1);
b.cursor = nir_after_cf_list(&impl->body);
- for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
- if (ucp_enables & (1 << plane)) {
- nir_ssa_def *ucp = nir_load_user_clip_plane(&b, plane);
-
- /* calculate clipdist[plane] - dot(ucp, cv): */
- clipdist[plane] = nir_fdot4(&b, ucp, cv);
- }
- else {
- /* 0.0 == don't-clip == disabled: */
- clipdist[plane] = nir_imm_float(&b, 0.0);
- }
- }
-
- if (ucp_enables & 0x0f)
- store_clipdist_output(&b, out[0], &clipdist[0]);
- if (ucp_enables & 0xf0)
- store_clipdist_output(&b, out[1], &clipdist[4]);
-
- nir_metadata_preserve(impl, nir_metadata_dominance);
-}
-
-/* ucp_enables is bitmask of enabled ucps. Actual ucp values are
- * passed in to shader via user_clip_plane system-values
- */
-bool
-nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
-{
- nir_function_impl *impl = nir_shader_get_entrypoint(shader);
- int clipvertex = -1;
- int position = -1;
- int maxloc = -1;
- nir_ssa_def *cv;
- nir_variable *out[2] = { NULL };
-
- if (!ucp_enables)
- return false;
-
/* find clipvertex/position outputs: */
nir_foreach_variable(var, &shader->outputs) {
int loc = var->data.driver_location;
out[1] =
create_clipdist_var(shader, ++maxloc, true, VARYING_SLOT_CLIP_DIST1);
- lower_clip_vs(impl, ucp_enables, cv, out);
+ for (int plane = 0; plane < MAX_CLIP_PLANES; plane++) {
+ if (ucp_enables & (1 << plane)) {
+ nir_ssa_def *ucp = nir_load_user_clip_plane(&b, plane);
+
+ /* calculate clipdist[plane] - dot(ucp, cv): */
+ clipdist[plane] = nir_fdot4(&b, ucp, cv);
+ } else {
+ /* 0.0 == don't-clip == disabled: */
+ clipdist[plane] = nir_imm_float(&b, 0.0);
+ }
+ }
+
+ if (ucp_enables & 0x0f)
+ store_clipdist_output(&b, out[0], &clipdist[0]);
+ if (ucp_enables & 0xf0)
+ store_clipdist_output(&b, out[1], &clipdist[4]);
+
+ nir_metadata_preserve(impl, nir_metadata_dominance);
return true;
}