mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 21:30:53 +01:00
[PR #1276] [CLOSED] rdna2spirv: skip the load of a typed buffer format with no decoder (SHADER-TYPED-RESERVED-FORMATS) #1308
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1308
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1276
Author: @Moriz82
Created: 11/24/2026
Status: ❌ Closed
Base:
main← Head:split/shader-typed-reserved-formats📝 Commits (1)
cb009cerdna2spirv: skip the load of a typed buffer format with no decoder (SHADER-TYPED-RESERVED-FORMATS)📊 Changes
2 files changed (+5 additions, -1 deletions)
View changed files
📝
tests/semantic/fixtures/buffer_format_unreadable.asm(+1 -0)📝
tests/semantic/test_buffer_oob_dst_sel.py(+4 -1)📄 Description
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
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.