From 367d93bcd433ceeece038f9353e4da1df3c9e231 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Tue, 18 Jan 2022 14:14:55 -0500 Subject: agx: Handle texture array indices These need to be converted to integers. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/asahi') 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: -- cgit v1.2.3