Mesa (main): agx: Lower front face to back face

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jun 5 21:05:53 UTC 2021


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Sat Jun  5 15:04:35 2021 -0400

agx: Lower front face to back face

Signed-off-by: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11199>

---

 src/asahi/compiler/agx_compile.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 7a38d63cdd5..644b22ca587 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -969,6 +969,26 @@ agx_lower_sincos(nir_shader *shader)
          agx_lower_sincos_filter, agx_lower_sincos_impl, NULL);
 }
 
+static bool
+agx_lower_front_face(struct nir_builder *b,
+                     nir_instr *instr, UNUSED void *data)
+{
+   if (instr->type != nir_instr_type_intrinsic)
+      return false;
+
+   nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
+   if (intr->intrinsic != nir_intrinsic_load_front_face)
+      return false;
+
+   assert(intr->dest.is_ssa);
+   nir_ssa_def *def = &intr->dest.ssa;
+   assert(def->bit_size == 1);
+
+   b->cursor = nir_before_instr(&intr->instr);
+   nir_ssa_def_rewrite_uses(def, nir_inot(b, nir_load_back_face_agx(b, 1)));
+   return true;
+}
+
 static void
 agx_optimize_nir(nir_shader *nir)
 {
@@ -986,6 +1006,9 @@ agx_optimize_nir(nir_shader *nir)
    NIR_PASS_V(nir, nir_lower_load_const_to_scalar);
    NIR_PASS_V(nir, nir_lower_flrp, 16 | 32 | 64, false);
    NIR_PASS_V(nir, agx_lower_sincos);
+   NIR_PASS_V(nir, nir_shader_instructions_pass,
+         agx_lower_front_face,
+         nir_metadata_block_index | nir_metadata_dominance, NULL);
 
    do {
       progress = false;



More information about the mesa-commit mailing list