From f5e6b891fa428e8cc827f8874dd815ffe3ad6b51 Mon Sep 17 00:00:00 2001 From: Mary Guillemard Date: Thu, 30 Jan 2025 11:56:15 +0000 Subject: [PATCH] pan/bi: Properly encode LEA_BUF_IMM We were hardcoding table 61 and index 0 for IDVS based usage and this could have been misused. Signed-off-by: Mary Guillemard Fixes: f45654af5953 ("pan/va: Add packing routines") Reviewed-by: Lars-Ivar Hesselberg Simonsen Reviewed-by: Boris Brezillon Reviewed-by: Erik Faye-Lund Part-of: (cherry picked from commit fbd5d58e3672944ba76911875f03bda69b93d5da) --- .pick_status.json | 2 +- src/panfrost/compiler/bifrost_compile.c | 8 +++++++- src/panfrost/compiler/valhall/test/test-packing.cpp | 2 +- src/panfrost/compiler/valhall/va_pack.c | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index a469fa4c564..f366bce5cfb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -164,7 +164,7 @@ "description": "pan/bi: Properly encode LEA_BUF_IMM", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "f45654af5953d86b4b82760b51a502fb25244073", "notes": null diff --git a/src/panfrost/compiler/bifrost_compile.c b/src/panfrost/compiler/bifrost_compile.c index 4bf803f7d20..ba3a4727bc7 100644 --- a/src/panfrost/compiler/bifrost_compile.c +++ b/src/panfrost/compiler/bifrost_compile.c @@ -1182,7 +1182,13 @@ bi_emit_store_vary(bi_builder *b, nir_intrinsic_instr *instr) if (index_offset != 0) index = bi_iadd_imm_i32(b, index, index_offset); - bi_index address = bi_lea_buf_imm(b, index); + + /* On Valhall, with IDVS varying are stored in a hardware-controlled + * buffer through table 61 at index 0 */ + bi_index address = bi_temp(b->shader); + bi_instr *I = bi_lea_buf_imm_to(b, address, index); + I->table = va_res_fold_table_idx(61); + I->index = 0; bi_emit_split_i32(b, a, address, 2); bi_store(b, nr * src_bit_sz, data, a[0], a[1], diff --git a/src/panfrost/compiler/valhall/test/test-packing.cpp b/src/panfrost/compiler/valhall/test/test-packing.cpp index b7428497897..0a7bb8783c0 100644 --- a/src/panfrost/compiler/valhall/test/test-packing.cpp +++ b/src/panfrost/compiler/valhall/test/test-packing.cpp @@ -306,7 +306,7 @@ TEST_F(ValhallPacking, LdVarBufImmF16) TEST_F(ValhallPacking, LeaBufImm) { CASE(bi_lea_buf_imm_to(b, bi_register(4), bi_discard(bi_register(59))), - 0x005e840400000d7b); + 0x005e84040000007b); } TEST_F(ValhallPacking, StoreSegment) diff --git a/src/panfrost/compiler/valhall/va_pack.c b/src/panfrost/compiler/valhall/va_pack.c index 3e03a62e688..8fcacdab554 100644 --- a/src/panfrost/compiler/valhall/va_pack.c +++ b/src/panfrost/compiler/valhall/va_pack.c @@ -472,8 +472,8 @@ va_pack_alu(const bi_instr *I) break; case BI_OPCODE_LEA_BUF_IMM: - /* Buffer table index */ - hex |= 0xD << 8; + hex |= ((uint64_t)I->table) << 8; + hex |= ((uint64_t)I->index) << 12; break; case BI_OPCODE_LEA_ATTR_IMM: