Mesa (staging/21.3): ir3: opt_deref in opt loop to remove unnecessary tex casts

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 2 21:21:48 UTC 2022


Module: Mesa
Branch: staging/21.3
Commit: 582227b11a548cb3b9d0db2d85b9755ba93f3f08
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=582227b11a548cb3b9d0db2d85b9755ba93f3f08

Author: Danylo Piliaiev <dpiliaiev at igalia.com>
Date:   Tue Feb  1 14:32:02 2022 +0200

ir3: opt_deref in opt loop to remove unnecessary tex casts

Otherwise we may be left with such casts:

 vec1 32 ssa_72 = deref_var &shadow_map (uniform sampler2D)
 vec1 32 ssa_73 = deref_cast (texture2D *)ssa_72 (uniform texture2D)
 vec1 32 ssa_74 = deref_cast (sampler *)ssa_72 (uniform sampler)
 vec1 32 ssa_76 = (float32)tex ssa_73 (texture_deref), ssa_74 (sampler_deref), ssa_75 (coord), ssa_64 (comparator)

And crash in ycbcr lowering since we aren't able to follow deref chain.

Fixes crash in GFXBench Aztec Ruins Vulkan tests.
See issue: https://gitlab.freedesktop.org/mesa/mesa/-/issues/5945

Cc: mesa-stable

Signed-off-by: Danylo Piliaiev <dpiliaiev at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14819>
(cherry picked from commit f917c735288835a18b8aba799b8e48acc75bdcf9)

---

 .pick_status.json           | 2 +-
 src/freedreno/ir3/ir3_nir.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/.pick_status.json b/.pick_status.json
index 53c71fe8217..cf6d49440b9 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -454,7 +454,7 @@
         "description": "ir3: opt_deref in opt loop to remove unnecessary tex casts",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "main_sha": null,
         "because_sha": null
     },
diff --git a/src/freedreno/ir3/ir3_nir.c b/src/freedreno/ir3/ir3_nir.c
index 44008cb8c95..7d2d11173ff 100644
--- a/src/freedreno/ir3/ir3_nir.c
+++ b/src/freedreno/ir3/ir3_nir.c
@@ -210,6 +210,7 @@ ir3_optimize_loop(struct ir3_compiler *compiler, nir_shader *s)
       progress |= OPT(s, nir_lower_phis_to_scalar, false);
 
       progress |= OPT(s, nir_copy_prop);
+      progress |= OPT(s, nir_opt_deref);
       progress |= OPT(s, nir_opt_dce);
       progress |= OPT(s, nir_opt_cse);
       static int gcm = -1;



More information about the mesa-commit mailing list