Mesa (main): agx: Translate LOD modes more generically

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Feb 6 15:10:33 UTC 2022


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Tue Jan 18 09:48:13 2022 -0500

agx: Translate LOD modes more generically

Now includes support for auto_load_bias mode.

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

---

 src/asahi/compiler/agx_compile.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 383c0c02286..9b0789fb8e1 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -784,6 +784,17 @@ agx_tex_dim(enum glsl_sampler_dim dim, bool array)
    }
 }
 
+static enum agx_lod_mode
+agx_lod_mode_for_nir(nir_texop op)
+{
+   switch (op) {
+   case nir_texop_tex: return AGX_LOD_MODE_AUTO_LOD;
+   case nir_texop_txb: return AGX_LOD_MODE_AUTO_LOD_BIAS;
+   case nir_texop_txl: return AGX_LOD_MODE_LOD_MIN;
+   default: unreachable("Unhandled texture op");
+   }
+}
+
 static void
 agx_emit_tex(agx_builder *b, nir_tex_instr *instr)
 {
@@ -795,9 +806,6 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr)
       unreachable("Unhandled texture op");
    }
 
-   enum agx_lod_mode lod_mode = (instr->op == nir_texop_tex) ?
-      AGX_LOD_MODE_AUTO_LOD : AGX_LOD_MODE_LOD_MIN;
-
    agx_index coords = agx_null(),
              texture = agx_immediate(instr->texture_index),
              sampler = agx_immediate(instr->sampler_index),
@@ -830,7 +838,7 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr)
    agx_texture_sample_to(b, agx_dest_index(&instr->dest),
          coords, lod, texture, sampler, offset,
          agx_tex_dim(instr->sampler_dim, instr->is_array),
-         lod_mode,
+         agx_lod_mode_for_nir(instr->op),
          0xF, /* TODO: wrmask */
          0);
 



More information about the mesa-commit mailing list