Mesa (main): agx: Handle texture array indices

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


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

Author: Alyssa Rosenzweig <alyssa at rosenzweig.io>
Date:   Tue Jan 18 14:14:55 2022 -0500

agx: Handle texture array indices

These need to be converted to integers.

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 | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c
index 15ab0857251..ad0b030758c 100644
--- a/src/asahi/compiler/agx_compile.c
+++ b/src/asahi/compiler/agx_compile.c
@@ -819,6 +819,27 @@ agx_emit_tex(agx_builder *b, nir_tex_instr *instr)
       switch (instr->src[i].src_type) {
       case nir_tex_src_coord:
          coords = index;
+
+         /* Array textures are indexed by a floating-point in NIR, but by an
+          * integer in AGX. Convert the array index from float-to-int for array
+          * textures. The array index is the last source in NIR.
+          */
+         if (instr->is_array) {
+            unsigned nr = nir_src_num_components(instr->src[i].src);
+            agx_index channels[4] = {};
+
+            for (unsigned i = 0; i < nr; ++i)
+               channels[i] = agx_p_extract(b, index, i);
+
+            channels[nr - 1] = agx_convert(b,
+                  agx_immediate(AGX_CONVERT_F_TO_S32),
+                  channels[nr - 1], AGX_ROUND_RTZ);
+
+            coords = agx_p_combine(b, channels[0], channels[1], channels[2], channels[3]);
+         } else {
+            coords = index;
+         }
+
          break;
 
       case nir_tex_src_lod:



More information about the mesa-commit mailing list