Repository navigation
rdna2spirv: skip the load of a typed buffer format with no decoder (SHADER-TYPED-RESERVED-FORMATS) - #1276
Closed
Moriz82 wants to merge 1 commit into
Closed
rdna2spirv: skip the load of a typed buffer format with no decoder (SHADER-TYPED-RESERVED-FORMATS)#1276Moriz82 wants to merge 1 commit into
Moriz82 wants to merge 1 commit into
Conversation
This was referenced Nov 24, 2026
Contributor
|
Tested
AI-assisted; synthetic fixtures only, no game data. |
…HADER-TYPED-RESERVED-FORMATS) A buffer_load_format_* whose format comes from the V# read one dword at the V# address when the FORMAT was INVALID or a reserved code, and discarded it: such a format has no data channels. An INVALID format marks a V# that is not a view of any buffer, so that address need not be mapped. The explicit-format MTBUF path already refuses the load of an INVALID V#. Treat a run-time format without a decoder like an out-of-bounds load: no memory access, data channels 0, DST_SEL 0/1 as before. The loaded values do not change for any of the 128 codes. The new read-log test fails on main for codes 0, 78 and 127 (five reads of the span) and passes here. A sweep of all 128 codes, three DST_SEL sets and OOB_SELECT 0..3 over four load forms gives the same words in all 1,536 runs. The typed-format and out-of-bounds GPU fixtures pass on an RTX 4070 with both translators; none of them reaches the new skip, which is CPU-checked only. The translator suite ran 470 files and 6,169 tests with 0 failing files, and of the other Python test files only tests/test_imhex_patterns.py fails, as on main. AI-assisted (Claude Code). Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Moriz82
force-pushed
the
split/shader-typed-reserved-formats
branch
from
November 25, 2026 03:38
4e98025 to
cb009ce
Compare
Collaborator
Author
|
Thanks for the MoltenVK and KosmicKrisp runs. #984 already brought the no-decoder path into main. The rebased head AI-assisted. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rebased onto
bfef489catcb009ce6. Main already skips the backing load for reserved and invalid typed formats. This diff strengthens the test's positive control to require a read from the expected address. All six focused CPU tests passed.Claimed in the coordination issue as: SHADER-TYPED-RESERVED-FORMATS (claim).
Part of the split of #984 into small pull requests.
Depends on: none
Overlaps: #984 is the parent integration. #811 (open, demand-driven decode for 1/2/3-component loads) edits the decode and swizzle part of the same function,
Gen.buffer_load_format; it does not touch the load condition changed here, its current diff applies cleanly on this branch, and with it appliedtests/semantic/test_buffer_oob_dst_sel.pystill passes (6 tests). #829 and #858 (open) are about typed stores and thed16_hiforms, and #925 (open) edits other rows ofdocs/design.md; their diffs apply cleanly too, as does #1068. No open or merged pull request found for the load of anINVALIDor reserved format (searchedbuffer_load_format,DST_SEL,typed buffer,reserved format,INVALID format).What and why
A MUBUF
buffer_load_format_*takes its format from the V# (word3 bits 12-18) at run time. A FORMAT without a decoder,INVALID(0) or a reserved code (78..127), has no data channels in the translator: such a load already returned zeros and theDST_SELconstants (the row "Out-of-bounds typed buffer loads andDST_SEL=1" has the hardware measurement of those constants for all 128 codes).The translated shader still dereferenced such a V#. When its span was non-empty and the offset in range, the load block ran, read one dword at the V# address (five
OpLoads of it) and discarded the value. A FORMAT ofINVALIDmarks a V# that is not a view of any buffer (the translator says so itself where it handles an explicit MTBUF format), so its base andNUM_RECORDSsay nothing about mapped memory, and a load through a physical storage buffer pointer outside every buffer is undefined in Vulkan. The explicit-format path,tbuffer_load_format_*, already refuses the load of an unbound V#.The change makes the run-time path do the same: the condition that lets a load touch memory now also needs a format with an element size. Such a load is treated like an out-of-bounds one: no memory access, data channels 0,
DST_SEL0/1 as before. OneOpLogicalAndreplaces oneOpSelectper load, so the modules do not grow.The loaded values do not change for any of the 128 codes; only the memory access goes away.
What this does not do
INVALIDor reserved format over a mapped span, so no GPU run shows the skipped load itself; the GPU runs below show that loads of real formats are unaffected.Tested
CachyOS (kernel 7.3.5), Python 3.14, LLVM
llvm-mc23.1.5 and SPIRV-Tools v2026.4. GPU fixtures on an NVIDIA GeForce RTX 4070, driver 620.73.04.python3 -I tests/semantic/test_buffer_oob_dst_sel.py: 6 tests pass. The newtest_format_without_a_decoder_skips_the_backing_loadruns the fixturetests/semantic/fixtures/buffer_format_unreadable.asmwith a read log over a 16-byte in-range span. With the base commit's translator (LEONIDA_TOOLS_DIR=<export of the base's tools>) it fails in 3 of its 4 subtests, codes 0, 78 and 127: five reads of the span's first dword where none is expected. The control,32_UINT, passes on both.xyzw,d16_xyzw,xwithoffen,xyat byte offset 1), every FORMAT code 0..127, threeDST_SELsets andOOB_SELECT0..3, run throughspirv_mini_interpwith each translator: 1,536 runs, the nine output words are the same in every one. The number of memory reads differs only for the 51 codes without a decoder: in 459 of their 612 runs the base read memory (20 loads) and this branch reads none; in the other 153, all withOOB_SELECT0, neither reads any. The module is 2,686 assembly lines on both. This sweep is a local script, not part of the pull request.python3 -I scripts/run_semantic_tests.py tests/semantic -p <file>for the 17 test files that load or decode typed buffers (test_buffer_*,test_format_decode_table.py,test_norm_decode.py,test_tbuffer_load_format.py,test_value_semantics.py,test_wave64_halves*.py): 334 tests, 0 files failed.python3 -I scripts/run_gpu_tests.py --filter fmtand--filter oob: 9 shaders translate and passspirv-val;cs_buf_fmt8,cs_fmt_1010102,cs_fmt_d16_xyz,cs_fmt_int_narrow,cs_fmt_sint32,cs_fmt_xy_xyz,cs_oob_selectandcs_oob_tailpass, 8 of 8, with the base commit's translator and with this one. The harness programs are from a native Linux build of 2026-11-23 on this machine and were not rebuilt.python3 -I scripts/run_semantic_tests.py tests/semantic -j 2: 470 files, 6,169 tests, 0 files failed (the base: 470 files, 6,168 tests, 0 failed).tests/the wayci.ymlruns them, andpython3 -I -m compileall -q make_game.py tools tests: 520 files, 519 pass.tests/test_imhex_patterns.pyfails (6 of its 9 tests) and fails the same way on the base commit, so it is not from this change.compileallpasses.python3 -I scripts/check_no_game_data.py: passes.Not run: native Windows, macOS, an AMD or Intel GPU, the full GPU suite, a GPU run of the new fixture (it needs a harness case that binds a V# with an unreadable format, which does not exist), the
tools/hw_oracleprobe, the runtime build and a game boot.GPUs tested: NVIDIA GeForce RTX 4070, driver 620.73.04, Linux (the eight typed-format and out-of-bounds fixtures above; none of them exercises the new skip).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
6293c1c4f, one commit.DST_SEL=1" ofdocs/design.md, with how it was confirmed (CPU read log) and that it is not GPU-verified.🤖 Generated with Claude Code