Mesa (staging/22.0): zink: fix xfb analysis variable finding for arrays

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Apr 14 17:32:39 UTC 2022


Module: Mesa
Branch: staging/22.0
Commit: 02b2fbcedff217cc2973ec3fa56f0ddd35cdf575
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=02b2fbcedff217cc2973ec3fa56f0ddd35cdf575

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Wed Feb 16 17:44:13 2022 -0500

zink: fix xfb analysis variable finding for arrays

this fixes clipdistance exports

cc: mesa-stable

Reviewed-by: Dave Airlie <airlied at redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15224>
(cherry picked from commit 3f7da0c58447979976eb2928625b1f93154f6c57)

Conflicts:
	src/gallium/drivers/zink/zink_compiler.c

Changes for stable:
 - Add `have_psiz` as an argument to `find_var_with_locations_frac`

---

 .pick_status.json                        |  2 +-
 src/gallium/drivers/zink/zink_compiler.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index 09fffa9c660..509e8a3c795 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -12196,7 +12196,7 @@
         "description": "zink: fix xfb analysis variable finding for arrays",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 5,
+        "resolution": 1,
         "because_sha": null
     },
     {
diff --git a/src/gallium/drivers/zink/zink_compiler.c b/src/gallium/drivers/zink/zink_compiler.c
index 099434a698d..89b319a6ab6 100644
--- a/src/gallium/drivers/zink/zink_compiler.c
+++ b/src/gallium/drivers/zink/zink_compiler.c
@@ -558,13 +558,15 @@ check_psiz(struct nir_shader *s)
 }
 
 static nir_variable *
-find_var_with_location_frac(nir_shader *nir, unsigned location, unsigned location_frac)
+find_var_with_location_frac(nir_shader *nir, unsigned location, unsigned location_frac, bool have_psiz)
 {
    nir_foreach_shader_out_variable(var, nir) {
       if (var->data.location == location &&
           (var->data.location_frac == location_frac ||
-           glsl_get_vector_elements(var->type) >= location_frac + 1))
-         return var;
+           (glsl_type_is_array(var->type) ? glsl_array_size(var->type) : glsl_get_vector_elements(var->type)) >= location_frac + 1)) {
+         if (location != VARYING_SLOT_PSIZ || !have_psiz || var->data.explicit_location)
+            return var;
+      }
    }
    return NULL;
 }
@@ -610,7 +612,7 @@ update_so_info(struct zink_shader *zs, const struct pipe_stream_output_info *so_
       if (zs->nir->info.stage != MESA_SHADER_GEOMETRY || util_bitcount(zs->nir->info.gs.active_stream_mask) == 1) {
          nir_variable *var = NULL;
          while (!var)
-            var = find_var_with_location_frac(zs->nir, slot--, output->start_component);
+            var = find_var_with_location_frac(zs->nir, slot--, output->start_component, have_psiz);
          slot++;
          if (is_inlined(inlined[slot], output))
             continue;
@@ -644,7 +646,7 @@ update_so_info(struct zink_shader *zs, const struct pipe_stream_output_info *so_
       if (zs->nir->info.stage != MESA_SHADER_GEOMETRY || util_bitcount(zs->nir->info.gs.active_stream_mask) == 1) {
          nir_variable *var = NULL;
          while (!var)
-            var = find_var_with_location_frac(zs->nir, slot--, output->start_component);
+            var = find_var_with_location_frac(zs->nir, slot--, output->start_component, have_psiz);
          slot++;
          /* if this was flagged as a packed output before, and if all the components are
           * being output with the same stream on the same buffer, this entire variable



More information about the mesa-commit mailing list