Mesa (master): nir: Save nir_variable pointers in nir_lower_clip_vs rather than locs.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 19 22:36:27 UTC 2018


Module: Mesa
Branch: master
Commit: d0f746b6458e375a7f58f4f46a36f16dbb7089e1
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=d0f746b6458e375a7f58f4f46a36f16dbb7089e1

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sun May 21 19:13:21 2017 -0700

nir: Save nir_variable pointers in nir_lower_clip_vs rather than locs.

I'll want the variables in the next patch.

Reviewed-by: Eric Anholt <eric at anholt.net>

---

 src/compiler/nir/nir_lower_clip.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff --git a/src/compiler/nir/nir_lower_clip.c b/src/compiler/nir/nir_lower_clip.c
index 10da3fcedf..496c39e1b6 100644
--- a/src/compiler/nir/nir_lower_clip.c
+++ b/src/compiler/nir/nir_lower_clip.c
@@ -159,9 +159,9 @@ 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_variable *position = NULL;
+   nir_variable *clipvertex = NULL;
    nir_ssa_def *cv;
    nir_variable *out[2] = { NULL };
 
@@ -184,20 +184,12 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
 
    /* find clipvertex/position outputs: */
    nir_foreach_variable(var, &shader->outputs) {
-      int loc = var->data.driver_location;
-
-      /* keep track of last used driver-location.. we'll be
-       * appending CLIP_DIST0/CLIP_DIST1 after last existing
-       * output:
-       */
-      maxloc = MAX2(maxloc, loc);
-
       switch (var->data.location) {
       case VARYING_SLOT_POS:
-         position = loc;
+         position = var;
          break;
       case VARYING_SLOT_CLIP_VERTEX:
-         clipvertex = loc;
+         clipvertex = var;
          break;
       case VARYING_SLOT_CLIP_DIST0:
       case VARYING_SLOT_CLIP_DIST1:
@@ -209,10 +201,10 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
       }
    }
 
-   if (clipvertex != -1)
-      cv = find_output(shader, clipvertex);
-   else if (position != -1)
-      cv = find_output(shader, position);
+   if (clipvertex)
+      cv = find_output(shader, clipvertex->data.driver_location);
+   else if (position)
+      cv = find_output(shader, position->data.driver_location);
    else
       return false;
 




More information about the mesa-commit mailing list