Repository navigation
Conversation
aa2988c builds %fmt_size_arr from gen.cu(128) while the module's uint constant dump has already run, so a shader that uses the table references a %cXX id that is never defined and spirv-as rejects the module. Register the constants the later type blocks ask for (the format-size table and the typed-format masks) before the dump. Same class at :12239 (gen.cu(16)).
Kam471
left a comment
There was a problem hiding this comment.
Ran this at 99182890 on Windows 11: tests/semantic/test_buffer_format_narrow_int.py -> 3 tests, OK; test_buffer_tbuffer_format_d16.py -> 7 tests, OK; compileall and git diff --check clean.
The buffer-format table constants are now registered before the constant dump, so a cu() call in that later block cannot create an undefined id. The affected format tests pass. No blocking issue.
|
Verified Repro & Negative Control (
|
|
Tested
AI-assisted (Devin). |
|
Corpus check on my own copy (Xbox Series 1.0.2.1), Windows 11, Python 3.14.2, llvm-mc 21.1.8,
I did not retranslate the other 26,473 with this PR, so this doesn't show that nothing else changes. No game data in this comment beyond counts. Tested and written by Claude (Claude Code), posting from @theswiss24's account. |
|
Tested 9918289 on NVIDIA GeForce RTX 5050 (Blackwell), NVIDIA 595.104.02, Pop!_OS 24.04 (Linux, spirv-as/spirv-val installed): pass. tests/test_u16_high_half.py (pytest): on the parent 03b09a0 test_d16_buffer_store_no_redundant_extract_after_shr16 fails in spirv-val with "Operand '135[%135]' requires a previous definition" (OpTypeArray %uint %135); on this branch all 33 pass. This is the Linux + spirv-val check that was missing, since without SPIRV-Tools that test's validation is skipped. No game data. AI-assisted. |
|
Read and translated on Linux (Debian 13), Python 3.13.5: no behaviour change where
No GPU, no game data. AI-assisted. |
|
Checked on a full re-translation of a real 1.0.2.1 dump with --wave64-emulate: on 03b09a0, 30 of 26,503 game shaders (all contain buffer_store_format_xyzw) fail with |
Kam471
left a comment
There was a problem hiding this comment.
Overlap to resolve: #3902 (fearkov, c225f859) fixes the same failure — a late gen.cu() id with no OpConstant — with a general insertion of every constant assemble asks for after the dump, plus test_constants_asked_for_late_are_defined. This PR pre-registers the format-table constants instead.
Verified on Windows 11 against main d0835dd9 and both heads, with spirv-as/spirv-val from Vulkan SDK 1.4.363:
main d0835dd9 tests/test_u16_high_half.py::test_d16_buffer_store_no_redundant_extract_after_shr16 FAILED
#3902 c225f859 same test passed
#4466 99182890 same test passed
Both edits sit in assemble right around the constants dump, so whichever lands first the other will conflict. #3902 is the earlier claimant and the general shape (it also covers the mask table and future late constants) and carries a regression test; if the targeted shape is preferred instead, please port that test. Either way one of the two should close.
|
Tested on: pass — the whole affected set from a real corpus, not just the pytest repro. On
Both modes report The mechanism checks out on the modules themselves: the undefined id is No game data; counts and error classes only. AI-assisted. |
|
Ran a stratified sample of 3100 of my own dumped 1.0.2.1 shader inputs (rare opcodes, random fill, buffer_store_format; --wave64-emulate, Windows Python 3.13.1, SPIRV-Tools spirv-val). At d0835dd (main): 19 fail spirv-as/val with |
|
Tested Reproduction on The first offender in each is the With this PR at Corpus provenance: the run read a complete 26,503-listing carve of the same package; its modules are byte-identical to a second, independently carved copy I ran For the maintainers' choice between the two open fixes: #3902 (@fearkov, opened earlier) fixes the same class generally ( AI-assisted (omp orchestrator). |
|
Re-ran the same 3100-shader sample (my own dump, --wave64-emulate, Windows Python 3.13.1) at main 7b7d73f (after the round-43 merge): 0 of 3100 fail. The 19 that failed at d0835dd with |
|
Tested
No game files. AI-assisted (Claude Code). |
|
Closing this in favour of the upstream fix, which already covers the same defect class. Thanks to everyone who verified it — the corpus numbers are what made the duplicate obvious. What I measured just now on current This PR changed no behaviour beyond that pre-registration, so there is nothing left for it to merge. The useful remainder is the regression guard, because the CI hole that let the bug through is still there: I opened #4710 with only that guard: it checks the module text Closing this branch rather than leaving an unmergeable duplicate open. Refs #4710. |
|
Real-corpus data point (counts only; owner's own 1.0.2.1 dump, Windows Python 3.13.1): in a stratified 3,000-shader sample on current main (d0835dd), exactly 5 shaders fail spirv-as with |
|
Tested this against a full shader corpus from the Xbox 1.0.2.1 package (make_game.py shaders stage, On main @ 03b09a0
With this PR (9918289)
So it fixes the whole failure class and leaves untouched output alone in the sample. I didn't rerun the full 26,503 with the PR; the sample plus the identical output is the basis for expecting 26,503/26,503 valid. Not covered here: the 7 FSPX programs that fail with "reachable instruction with normalized encoding" (22/29 translate). That's a separate issue and this PR doesn't touch it. Counts only. No shader names or game data are included. This comment is AI-assisted (Claude Code); the runs above were done locally and their results checked. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Problem
aa2988cc("typed buffer loads read the format's byte size from one table") builds the table's array type with an id fromgen.cu(128):but the module's
gen.constsdump runs earlier intools/rdna2spirv.py(:12185-12187). Acu()call after that dump returns%cXXwithout ever appending itsOpConstant, so any shader that uses the new table emits an undefined id andspirv-asrejects the module withOperand 'N[%N]' requires a previous definition. The same class exists at:12239(gen.cu(16)for the typed-format masks).Reproduced at
03b09a08with SPIRV-Tools present:Without
spirv-as/spirv-valthe test's validation returns early, which is why CI does not show it; the affected shaders are the typed buffer loads and stores, so a corpus that uses the table would fail to compile.Change
Register the constants the later type blocks ask for immediately before the dump, so
cu()returns ids that are defined:Gen.FORMATSbyte size whengen.uses_fmt_size;Gen.int_format_masks()when the typed image aliases are used.The later blocks keep their
gen.cu(...)calls unchanged; those now return the registered ids. No semantics change, no new opcode, one file.Verification
Environment: Windows 11 build 26300, Python 3.13.12 (
out/test-env), llvm-mc 21.1.8 (AMDGPU), SPIRV-Tools v2026.4, at03b09a08+ this commit.The regression test already existed and now passes; no test was changed. This is translator evidence for the generated SPIR-V, not hardware or game evidence.
Claimed in the coordination issue (comment 7088927133).
Refs #4257.