Repository navigation
Conversation
…f them assemble() writes the OpConstant section in one loop over gen.consts, and the %fmt_size_tab block only asked cu() for the array length and the six element sizes afterwards. Anything registered there was referenced by %fmt_size_arr and %fmt_size_init but never declared, which spirv-val rejects with "Operand '...' requires a previous definition". A buffer_load_format_* also decodes the format, and that path registers 128 on its own; a buffer_store_format_* at a run-time V# decodes nothing, so the array length was the undeclared id. Register the table's constants where assemble() already pre-registers the ones its later blocks ask for, and share the size list through Gen.fmt_size_table().
|
Tested 84de12f on Windows 11 Build 26200 / RTX 3060 Ti / driver 621.01 / Python 3.12: pass.
AI-assisted. No game files. |
|
Independent CPU comparison on Windows with uv CPython 3.12.13 and SPIRV-Tools 2026.4. For a synthetic runtime-V# d16 store, both assemblers produced a module on main This confirms the coordinator’s overlap note. The dry merge is clean (tree |
|
Withdrawing this as the duplicate of #3902. @KoertLichtendonk's overlap note sent me to compare, and throny's own status comment (#3918) had already said the same thing on the day the finding was posted: fearkov claimed it at 22:20, which is before my claim at 23:14. I missed that comment when I claimed. The finding link in this body was wrong as well — throny's finding is 7086903759. Compared both heads myself on the same two synthetic store forms this PR used (
#3902 also covers The one piece worth keeping from here is the store-side regression test. A CPU only, synthetic inputs, no game files. |
|
@LocranKing, @whattheflop: thank you, both checks still count, they just now describe #3902. @LocranKing: the run you did (39 of 39, then 40 of 40 with the new @whattheflop: your comparison is what settled it for me — #3902 and this head both validate the runtime-V# store, #3902 also carries |
Superseded by #3902, which fixes the same regression generically and was claimed before this one; closed as the duplicate. The comparison and the verification of #3902 are in the closing comment.
Claimed in the coordination issue as: the
aa2988ccformat-table regression reported by @throny (finding).What and why
aa2988ccmadebuffer_load_formatread its element size from%fmt_size_tabinstead of a select chain. The table is aPrivatearray of 128 sizes, so it needs a constant for its length and one for each size it holds — and those were asked for afterassemble()had already written theOpConstantsection (the single loop overgen.consts). Any value not already registered during translation was therefore referenced by%fmt_size_arr/%fmt_size_initand never declared, andspirv-valrejects such a module withOperand '<id>' requires a previous definition— the error class @throny measured on 4 of 3,000 corpus shaders.Which value is missing depends on the shader:
buffer_load_format_*at a run-time V# also decodes the format, and that path asks for 128 (1 << (w - 1)for an 8-bit format), so it happens to declare the array length. 400 of 400 typed-load shaders from my own work folder translate tospirv-val-valid modules ataa2988cc.buffer_store_format_*at a run-time V# reads the element size from the same table but decodes no format, so nothing else in the module asks for 128 and the length is the undeclared id. That is the case the new test pins.The fix registers the table's constants where
assemble()already pre-registers the ones its later blocks ask for (the same convention as the--wave64-emulateand barrier-round blocks, which is commented "before any constant is emitted"), so the latercu()calls reuse them.Gen.fmt_size_table()is now the one place the size list is built, used by both the registration and theOpConstantCompositeinitializer.No behaviour change to the translated code: the same ids, sizes and initializer, only declared before they are referenced.
Tested
CPU only, no GPU; no game files in the PR.
TestRuntimeFormatSizeTable.test_runtime_format_store_declares_every_table_constant(tests/semantic/test_buffer_store_format.py): abuffer_store_format_xyzwwhose V# FORMAT field is user data. Onorigin/main(aa2988cc) it fails — the module has%fmt_size_arr = OpTypeArray %uint %c80with no%c80 = OpConstant %uint 128; with this PR it passes and the same module isspirv-as/spirv-valclean (--target-env vulkan1.2, SPIRV-Tools from Vulkan SDK 1.4.363.1).python -I -m unittest discover -s tests/semantic -p test_buffer_store_format.py: 40 tests, OK (39 before this PR).-p test_buffer_load_format.py: 34 OK;-p test_buffer_format_narrow_int.py: 3 OK;-p test_buffer_tbuffer_format_d16.py: 7 OK.python -m compileall -q make_game.py tools tests: exit 0.I did not re-run the full corpus: the trigger needs
buffer_store_format_*at a run-time V#, and the fix only moves declarations, so counts are expected unchanged. I also did not reproduce one of @throny's four shaders directly — the reproduction is the hand-written store above, which fails with the same missing id.Checklist
docs/design.md, with how it was confirmed. — No new rule; this restores the module's declaration order.Depends on: nothing.