Repository navigation
rdna2spirv: out-of-range typed buffer loads keep DST_SEL constant 1 (SHADER-429) - #2486
LloydNicholson wants to merge 1 commit into
Conversation
|
Independent comparison of 660342f and #2467 at e701a6f on Windows 11 build 26300, RTX 5070 driver 621.24.
The GPU results support the removal of the redundant output gate on the current format table. This PR also adds the SHADER-429 contract row. Synthetic inputs only. AI-assisted review. |
|
Tested commit Environment:
Test verification:
AI-assisted. |
|
Independent native check on RDNA2, against this PR's translator ( Hardware: Radeon iGPU, gfx1036 (Ryzen 7 9800X3D), AMD driver 32.0.13036.4, Windows 10 22H2, through Cases (480 in total): one lane, with the V# built in SGPRs (NUM_RECORDS = 16 bytes, OOB_SELECT raw), over every combination of:
The destination VGPRs start as 0xdeadbeef, so a register the load doesn't write shows up. The translator side runs the same body through
The 3 remaining misses are not from this PR. They show up the same way on the base. A d16 load of a 32_FLOAT channel holding 0xFE00CDAB (about -4.3e37) gives 0xfbff (-65504) on the hardware, but 0xfc00 (-inf) from the translator. A separate 4-value probe shows that d16 narrowing of f32 channels rounds toward zero on gfx1036. I'll post that as a finding in the coordination issue; it is outside this PR. No game files. AI-assisted (Claude Code). |
|
Tested 660342f on Windows 11 (26200) on both GPUs of a two-GPU PC: pass. I ran this PR's
No game files. AI-assisted check (Claude Code), Vonsek3. |
|
Tested 660342f on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:
AI-assisted (Claude Code). |
…SHADER-429) An out-of-range buffer_load_format_* (d16 included) skips the load, so its raw channels read 0, but DST_SEL still applies: a channel selected as constant 1 reads integer 1, 1.0f or f16 1.0, as @timelery measured on gfx1036 in wave32 and wave64. Gen.buffer_load_format zeroed the swizzled result instead, dropping the 1. The raw words are already 0 when the load is skipped and every format decodes them to 0, so the final select is removed; MTBUF's identity selectors have no constant 1 and still read 0 out of range or with an INVALID V# format. tests/semantic/test_buffer_load_sub.py adds integer, float and d16 out-of-range cases (all three fail without the change) and the in-range d16 one; docs/design.md has the contract row. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
660342f to
e043ced
Compare
Claimed in the coordination issue as SHADER-429: #2300 (comment)
What and why
The problem. @timelery measured this on RDNA2 (gfx1036, wave32 and wave64), in the finding:
buffer_load_format_*, d16 included) is out of range, the raw data channels read 0, butDST_SELstill applies.Gen.buffer_load_formatinstead ended each channel withOpSelect in_bounds result 0(tools/rdna2spirv.py:1990on 4947579; the change is e043ced onmain77444fa), which turned that 1 into 0.The fix (
tools/rdna2spirv.py): the final select is removed.OpPhitakes 0 from the skipped branch, and every supported format decodes all-zero words to 0. The swizzled result is therefore 0 for the data channels and 1 for a constant-1 channel.tbuffer_load_format_*), whose selectors come from the instruction as X000…XYZW, have no constant 1 and still read 0 out of range or with an INVALID V# format (the existingtest_tbuffer_8_uint_oob_and_invalid_vsharp_format); and the MUBUF in-range DST_SEL=1 rule from SHADER-86.Docs: a contract row in
docs/design.mdgives the rule and how it was confirmed.Tested
AI-assisted (Claude Code). Nobara Linux, RX 9060 XT (RDNA4, GFX1200), RADV Mesa 27.0.0-devel, llvm-mc 22.1.8, SPIRV-Tools 2026.1, on
main77444fa (rebased from 4947579).tests/semantic/test_buffer_load_sub.py: four new cases.[0, 0, 1, 1];[1.0f, 0, 0, 0];d16_xywith (1, X) reads0x00003C00.main'srdna2spirv.py, the three out-of-range cases fail and the control passes. With the change, all 13 tests in the file pass.tests/semantic: 2,571 tests. With current SPIRV-Tools first on PATH, all pass apart from the suite's own skips.spirv-valfirst on PATH, 5 SPIR-V-tools checks fail (test_fma_khr,test_image_coherent). The same 5 fail the same way onmain, so they come from that machine's tools, not this change.python -m pytest tests/test_translate.py: 541 passed, 4 skipped.scripts/run_gpu_tests.py: 175/189 passed, 14 skipped, 0 failed after the rebase. Before it, the result was the same with and without the change (170/185, 15 skipped). No test in that suite loads out of range with DST_SEL=1.compileall,tests/test_docs_links.pyandtests/test_text_write_line_endings.pypass.Not tested: a native hardware measurement of my own. The rule rests on @timelery's gfx1036 run. An RDNA1/gfx1013-class measurement, the console's own GPU family, would be worth adding.
Checklist
docs/design.md, with how it was confirmed.🤖 Generated with Claude Code