From fd021a618f3aeb2148060774b018343f059f7d1e Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Fri, 17 Jun 2022 11:59:09 -0400 Subject: [PATCH] pan/va: Replace MKVEC.v4i8 with MKVEC.v2i8 This is the instruction that the hardware actually supports. Do the rename, use the more specific accurate model in the IR, and rework the Valhall texturing code to emit MKVEC.v2i8 instead of MKVEC.v4i8. Will fix: dEQP-GLES31.functional.texture.gather.offset_dynamic.implementation_offset.* Signed-off-by: Alyssa Rosenzweig Part-of: --- src/panfrost/bifrost/bifrost_compile.c | 11 ++++++++--- src/panfrost/bifrost/valhall/ISA.xml | 8 ++++---- src/panfrost/bifrost/valhall/test/assembler-cases.txt | 8 ++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c index 15f5924cf31..6328c806507 100644 --- a/src/panfrost/bifrost/bifrost_compile.c +++ b/src/panfrost/bifrost/bifrost_compile.c @@ -3198,11 +3198,16 @@ bi_emit_valhall_offsets(bi_builder *b, nir_tex_instr *instr) /* No multisample index with 3D */ assert((nr <= 2) || (ms_idx < 0)); - dest = bi_mkvec_v4i8(b, + /* Zero extend the Z byte so we can use it with MKVEC.v2i8 */ + bi_index z = (nr > 2) ? + bi_mkvec_v2i8(b, bi_byte(bi_extract(b, idx, 2), 0), + bi_imm_u8(0), bi_zero()) : + bi_zero(); + + dest = bi_mkvec_v2i8(b, (nr > 0) ? bi_byte(bi_extract(b, idx, 0), 0) : bi_imm_u8(0), (nr > 1) ? bi_byte(bi_extract(b, idx, 1), 0) : bi_imm_u8(0), - (nr > 2) ? bi_byte(bi_extract(b, idx, 2), 0) : bi_imm_u8(0), - bi_imm_u8(0)); + z); } /* Component 2: multisample index */ diff --git a/src/panfrost/bifrost/valhall/ISA.xml b/src/panfrost/bifrost/valhall/ISA.xml index a5e35f9f572..495bac43edf 100644 --- a/src/panfrost/bifrost/valhall/ISA.xml +++ b/src/panfrost/bifrost/valhall/ISA.xml @@ -2110,15 +2110,15 @@ Cube face index - + Calculates $A | (B \ll 8) | (CD \ll 16)$ for 8-bit A and B and 16-bit CD. To implement `(uchar4) (A, B, C, D)` in full generality, use the sequence - `MKVEC.v4i8 CD, C, D, #0; MKVEC.v4i8 out, A, B, CD` + `MKVEC.v2i8 CD, C, D, #0; MKVEC.v2i8 out, A, B, CD` - `MKVEC.v4i8` also allows zero extending arbitrary 8-bit lanes. For - example, to extend `r0.b3` to `r1`, use `MKVEC.v4i8 r1, r0.b3, 0x0.b0, 0x0`. + `MKVEC.v2i8` also allows zero extending arbitrary 8-bit lanes. For + example, to extend `r0.b3` to `r1`, use `MKVEC.v2i8 r1, r0.b3, 0x0.b0, 0x0`. A B diff --git a/src/panfrost/bifrost/valhall/test/assembler-cases.txt b/src/panfrost/bifrost/valhall/test/assembler-cases.txt index 44d21a1225d..59a4d7c6167 100644 --- a/src/panfrost/bifrost/valhall/test/assembler-cases.txt +++ b/src/panfrost/bifrost/valhall/test/assembler-cases.txt @@ -152,10 +152,10 @@ c0 77 05 04 00 c2 a1 00 MKVEC.v2i16 r2, 0x0.h00, ^r55.h10 77 00 04 10 00 c2 90 00 S16_TO_S32 r2, ^r55.h10 c0 77 01 08 00 c2 a8 00 ISUB.s32 r2, 0x0, ^r55.h0 c0 77 01 0c 00 c2 a8 00 ISUB.s32 r2, 0x0, ^r55.h1 -00 c0 c0 00 c0 c7 bd 00 MKVEC.v4i8 r7, r0.b3, 0x0.b0, 0x0 -00 c0 c0 00 80 c6 bd 00 MKVEC.v4i8 r6, r0.b2, 0x0.b0, 0x0 -00 c0 c0 00 00 c4 bd 00 MKVEC.v4i8 r4, r0.b0, 0x0.b0, 0x0 -40 c0 c0 00 40 c5 bd 00 MKVEC.v4i8 r5, ^r0.b1, 0x0.b0, 0x0 +00 c0 c0 00 c0 c7 bd 00 MKVEC.v2i8 r7, r0.b3, 0x0.b0, 0x0 +00 c0 c0 00 80 c6 bd 00 MKVEC.v2i8 r6, r0.b2, 0x0.b0, 0x0 +00 c0 c0 00 00 c4 bd 00 MKVEC.v2i8 r4, r0.b0, 0x0.b0, 0x0 +40 c0 c0 00 40 c5 bd 00 MKVEC.v2i8 r5, ^r0.b1, 0x0.b0, 0x0 00 00 11 30 00 c7 90 00 U8_TO_F32 r7, r0.b3 00 00 11 20 00 c6 90 00 U8_TO_F32 r6, r0.b2 00 00 11 00 00 c4 90 00 U8_TO_F32 r4, r0.b0