/* Generates the lowering code for user-clip-planes, generating CLIPDIST
* from UCP[n] + CLIPVERTEX or POSITION. Additionally, an optional pass
- * for fragment shaders to insert conditional kill's based on the inter-
+ * for fragment shaders to insert conditional kills based on the inter-
* polated CLIPDIST
*
* NOTE: should be run after nir_lower_outputs_to_temporaries() (or at
* should be only a single predecessor block to end_block, which
* makes the perfect place to insert the clipdist calculations.
*
- * NOTE: in case of early return's, these would have to be lowered
+ * NOTE: in case of early returns, these would have to be lowered
* to jumps to end_block predecessor in a previous pass. Not sure
* if there is a good way to sanity check this, but for now the
* users of this pass don't support sub-routines.
nir_metadata_preserve(impl, nir_metadata_dominance);
}
-/* ucp_enables is bitmask of enabled ucp's. Actual ucp values are
+/* ucp_enables is bitmask of enabled ucps. Actual ucp values are
* passed in to shader via user_clip_plane system-values
*/
-void
+bool
nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
{
int clipvertex = -1;
nir_variable *out[2] = { NULL };
if (!ucp_enables)
- return;
+ return false;
/* find clipvertex/position outputs: */
nir_foreach_variable(var, &shader->outputs) {
* there should be no user-clip-planes to deal
* with.
*/
- return;
+ return false;
}
}
else if (position != -1)
cv = find_output(shader, position);
else
- return;
+ return false;
/* insert CLIPDIST outputs: */
if (ucp_enables & 0x0f)
if (!strcmp(function->name, "main"))
lower_clip_vs(function->impl, ucp_enables, cv, out);
}
+
+ return true;
}
/*
nir_intrinsic_discard_if);
discard->src[0] = nir_src_for_ssa(cond);
nir_builder_instr_insert(&b, &discard->instr);
+
+ b.shader->info.fs.uses_discard = true;
}
}
+
+ nir_metadata_preserve(impl, nir_metadata_dominance);
}
/* insert conditional kill based on interpolated CLIPDIST
*/
-void
+bool
nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables)
{
nir_variable *in[2];
int maxloc = -1;
if (!ucp_enables)
- return;
+ return false;
nir_foreach_variable(var, &shader->inputs) {
int loc = var->data.driver_location;
if (!strcmp(function->name, "main"))
lower_clip_fs(function->impl, ucp_enables, in);
}
+
+ return true;
}