summaryrefslogtreecommitdiff
path: root/src/asahi
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>2022-01-18 14:14:55 -0500
committerMarge Bot <emma+marge@anholt.net>2022-02-06 15:02:39 +0000
commit367d93bcd433ceeece038f9353e4da1df3c9e231 (patch)
tree3ffcd7d1886de08553f71ff77f61b4028dd9b5d0 /src/asahi
parentb459473bb973d4593f0533a975984aa288e8e275 (diff)
agx: Handle texture array indices
These need to be converted to integers. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14899>
Diffstat (limited to 'src/asahi')
-rw-r--r--src/asahi/compiler/agx_compile.c21
1 files changed, 21 insertions, 0 deletions
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: