From c0130045512d4e2f1ded075c75ae7c85bd23f51a Mon Sep 17 00:00:00 2001 From: Kam471 Date: Sun, 22 Nov 2026 22:29:00 +0000 Subject: [PATCH] rdna2spirv: define the format-table constants before use uses_fmt_size names %c80 as the 128-entry array length after the constant block was emitted, so the SPIR-V referenced an undefined id and spirv-as rejected it. Register the table length, member sizes and mask constants before emitting the constant instructions. --- tools/rdna2spirv.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tools/rdna2spirv.py b/tools/rdna2spirv.py index 809fc1b4b0..f567256ff1 100644 --- a/tools/rdna2spirv.py +++ b/tools/rdna2spirv.py @@ -12183,6 +12183,17 @@ def assemble(gen): if ms_cull_member is not None: gen.cu(ms_cull_member) gen.consts.setdefault(0, "%c0") + # The format tables below name their array lengths and members through gen.cu(); register those constants + # before the constant block is emitted, or the emitted SPIR-V references an id defined after its use. + if gen.uses_fmt_size: + gen.cu(128) + for c in range(128): + gen.cu(Gen.FORMATS[c][0] if c in Gen.FORMATS else 0) + if gen.uses_store_views or gen.uses_int_fetch: + fmt_uint, fmt_sint = Gen.int_format_masks() + gen.cu(16) + for w in fmt_uint + fmt_sint: + gen.cu(w) for v, name in sorted(gen.consts.items()): types.append(f"{name} = OpConstant %uint {v}") if gen.desc_fn: