[Mesa-dev] [PATCH 2/5] nir: Inline lower_clip_vs() into nir_lower_clip_vs().
Kenneth Graunke
kenneth at whitecape.org
Sat Nov 10 02:13:28 UTC 2018
It's now called exactly once, and there's not really any distinction.
---
src/compiler/nir/nir_lower_clip.c | 76 ++++++++++++++-----------------
1 file changed, 34 insertions(+), 42 deletions(-)
diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index 013645101f2..ced6d31c117 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -150,12 +150,23 @@ find_output(nir_shader *shader, unsigned drvloc)
* 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);
@@ -171,44 +182,6 @@ lower_clip_vs(nir_function_impl *impl, unsigned ucp_enables,
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_system_value(&b, nir_intrinsic_load_user_clip_plane, 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;
@@ -251,7 +224,26 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
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_system_value(&b, nir_intrinsic_load_user_clip_plane, 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;
}
--
2.19.1
More information about the mesa-dev
mailing list