rdna2spirv: form MUBUF byte offsets in 64 bits (SHADER-MUBUF-OFFSET-WRAP) #1068
Closed
Moriz82 wants to merge 1 commit from
upstream-pr/1068 into main
pull from: upstream-pr/1068
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
ProjectLeonida/mandy!1068
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1068"
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?
Imported from ubiquitarianism/leonida. Originally posted by Moriz82 on 2026-11-24T17:40:59Z.
Claimed in the coordination issue as: SHADER-MUBUF-OFFSET-WRAP (claim).
Part of the split of #984 (first child). Depends on: none. Overlaps: none found (searched open and merged pull requests for
buffer_address, stride, index and offset wrap; #513 changes the CBV's V# stride in the runtime, not the translator's address arithmetic; #1021 editsdocs/design.mdnear the swizzled-buffer row).What and why
Gen.buffer_addressintools/rdna2spirv.pyforms the byte offset of every MUBUF/MTBUF access,off + soffset + index * stride(and the swizzled form), in 32 bits and adds it to the 48-bit V# base. The hardware does not wrap there: the RDNA2 ISA (8.1.5) gives the address as base + stride * index + offset with a 48-bit base, and onlyoff(vaddr + inst_offset) wraps at 32 bits. So an index of0xFFFFFFFFwith a 20-byte stride addresses base + 0x13_FFFF_FFEC on the console, while the translated shader turns it into base − 20:OOB_SELECT 3(raw) checksoffset + soffsetagainstNUM_RECORDSand does not look at the index;OOB_SELECT 2(disabled) checks only that the buffer is not empty.Both let the wrapped access through, so a store writes 20 bytes below the buffer and a load reads them. When the view is one slice of a larger pool that is mapped as a whole, that is a silent write into a neighbour's records.
The change forms the linear and the swizzled offset as a 64-bit value and adds that to the base. Nothing else changes: each mode checks exactly what it checked before, and a literal V# and a run-time V# take the same path.
What changed since the first version
The first version also treated every offset above
0xFFFFFFFFas out of range. The reviews showed two faults in that, and both are fixed by removing the bound instead of patching it:What this does not do
docs/d3d12_vulkan.md), so there an offset of 4 GiB or more always leaves the arena. Whether the runtime should refuse an address outside the arena is a separate decision, with the arena size as the bound and not 2^32. It is not part of this pull request.b9b57e2), credited in the source. It was not measured by us on AMD hardware; the contract row anddocs/buffer_bounds.mdsay so. Someone with thetools/hw_oraclesetup could pin it with one probe (raw view, stride 20, index −1).Cost: two or three 64-bit conversions and adds and one 64-bit multiply per access, now for every access including folded structured views (the first version left those alone). On a sample of 200 compute programs of a retail library (translated locally with
--wave64-emulate, not included) 114 modules change and the 200 grow by 0.45 % together; all 200 passspirv-valbefore and after.Tested
Linux (CachyOS, kernel 7.3.5), Python 3.14, LLVM
llvm-mc23.1.5 and SPIRV-Tools v2026.4 from the distribution. GPU suite on an NVIDIA GeForce RTX 4070, driver 620.73.04.python3 -I tests/semantic/test_buffer_offset_wrap.py: 8 tests pass. With the translator of the base commit the same file has 13 failing subtests: index −1 in raw and disabled mode with a literal and a run-time V# (4), the mapped 5 GiB offset in disabled mode (2), a structured index belowNUM_RECORDSwhose product passes 4 GiB in modes 0 and 1 (4), a swizzled offset past 4 GiB with a literal and a run-time V# (2), andoff 0xFFFFFFF0 + soffset 0x20(1). The swizzled control below 4 GiB passes on both. The swizzled cases were added after a review noted that the swizzled path had moved to 64 bits without a case above 4 GiB.python3 -I scripts/run_semantic_tests.py tests/semantic: 471 files, 6,176 tests, 0 files failed.tests/the wayci.ymlruns them: 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.python3 -I scripts/check_no_game_data.py: passes.python3 -I scripts/run_gpu_tests.py(run on the head before the swizzled tests were added; the translator has not changed since): 261 shaders translate and passspirv-val; 202 of 252 tests pass, 49 are skipped and 1 fails (cs_imgstore_cube). The run with the base commit's translator gives the same 202, 49 and 1, test for test. The harness programs came from an older native build on this machine (2026-11-23) and were not rebuilt for this, which is the likely reason for that one failure; it is not a result of this change.Not run by us: native Windows, macOS, an AMD GPU, the
tools/hw_oracleprobe. A reviewer ran the GPU suite on an AMD RX 9070 XT (236 of 252 pass, 16 skipped, 0 failed) one01626be9, which has the same translator as this head.GPUs tested: NVIDIA GeForce RTX 4070 (translation only; see above for what is not measured on hardware).
AI-assisted: yes (Claude Code). The numbers above come from runs on the machine named.
Checklist
32950551eand merges cleanly into currentmain.docs/design.md("Buffer bounds checking"), with how it was confirmed and what is not measured.🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T18:10:19Z.
Review: CHANGES_REQUESTED
The new
fits <= 0xFFFFFFFFpredicate is applied in every OOB mode, which appears to reject valid mapped addresses above 4 GiB. The AMD RDNA2 ISA describes a 48-bit resource base and linear addressing asstride * index + offset; forOOB_SELECT=2it specifies onlyNumRecords == 0as the bounds check (“do not check bounds”). It does not define a 32-bit ceiling for the computed byte offset: https://www.amd.com/content/dam/amd/en/documents/radeon-tech-docs/instruction-set-architectures/rdna2-shader-instruction-set-architecture.pdf (section 8.1.5, pp. 59–62).I reproduced the regression with this PR’s translator and interpreter: mode 2,
NumRecords=1, stride 20, index0x10000000gives byte offset0x1_40000000(5 GiB), but the store is suppressed. If that address is backed by the allocation, mode 2’s documented check should not reject it. The external observation cited here establishes that one much larger offset does not wrap back into the pool; it does not establish that every offset above0xFFFFFFFFis out of range.Please add a >32-bit but mapped-address case and limit the guard to the actual hardware address/range condition established by evidence. The new tests in this PR pass (4/4); existing
test_buffer_oob_select.py(36/36) andtest_vector_mem_mubuf.py(53/53) also pass locally, so this is a missing semantic boundary case rather than a test failure.Imported from ubiquitarianism/leonida. Originally posted by kawaii-shakal on 2026-11-24T18:21:47Z.
Review of #1068 (SHADER-MUBUF-OFFSET-WRAP)
Head: ff94bdd72ec46c6009129c5c832c8767e180aeae (one commit on
32950551e). Claim: #14 comment 7139398473 by the author, 17:34 UTC, six minutes before the PR was opened; it matches the scope.Environment: Windows 11, native Python 3 (
-I), LLVM llvm-mc (Windows build), no GPU used (the change has no GPU test, and no AMD GPU is available here).Commands and results
python -I tests/semantic/test_buffer_offset_wrap.py: 4 tests, OK.tests/semantic/test_*matching buffer / tbuffer / mubuf / bounds / oob / swizzle, 26 files) run one by one;test_buffer_formats_all.pyandtest_buffer_swizzle.pythroughscripts/run_semantic_tests.py tests/semantic -p <file> -j 1because they importsupport: all pass (about 300 tests). The full suite was not run.git restore --source=HEAD~1 --worktree -- tools/rdna2spirv.py(the pre-PR translator), new test: FAILED (failures=5), the same five subtests the description names (index -1 in raw, raw literal, disabled, disabled literal;off 0xFFFFFFF0 + soffset 0x20). Restored withgit checkout -- tools/rdna2spirv.py, tree clean.git merge-tree --write-tree origin/main rv/1068(origin/main3aa975421): clean. No commit on main since the base touchestools/rdna2spirv.pyordocs/buffer_bounds.md.tools/rdna2spirv.py(16 of them): none editsGen.buffer_addressordocs/buffer_bounds.md. #1021 editsdocs/design.mdnear the swizzled-buffer row; a pairwisemerge-treeof #1021 and #1068 is clean.idxenaccess (about 448kidxenlines). About 955 also have a non-zerosoffset(a rough text match). 22 files with[in their names were skipped by the search, so these counts are slightly low. Mostidxenaccesses through a run-time V# get the new check, so most translated compute and graphics modules change (the 2 % size estimate in the description is plausible). I did not translate the corpus to compare SPIR-V.Findings
The skip for literal modes 0 and 1 is not exact (tools/rdna2spirv.py:4148, docs/design.md:501, comment at tools/rdna2spirv.py:4133-4134). The skip assumes that
idx < NUM_RECORDSboundsidx * strideto 32 bits. That holds only whenNUM_RECORDS * stride <= 2^32, and NUM_RECORDS is a run-time word even when word3 is literal. A probe (not part of the PR; F:\recomp\tmp\rv1068-probe.py, using the PR's own helpers): mode 1, stride 20, NUM_RECORDS 0xFFFFFFFF, index 0x0CCCCCCD, soidx * stride= 0x1_0000_0004:s_mov_b32literals: 77 is stored at base + 4 and read back.So the same descriptor gives different results depending on whether the translator folded word3. That needs a very large NUM_RECORDS (0xFFFFFFFF "unbounded" descriptors do occur), so it is a corner case, but the docs state the opposite. Either emit
fitsfor literal modes 0/1 too, skip it only when a literal word2 and stride proveNUM_RECORDS * stride <= 2^32, or say in the row and the comment that the folded path does not check it. A literal structured case belongs in the test as well:test_structured_modes_already_refuse_the_index(tests/semantic/test_buffer_offset_wrap.py:96) covers only the run-time V#, which always takes the new check.How the rule was confirmed (docs/design.md:501, docs/buffer_bounds.md:22-26). AGENTS.md:33-35 asks for a GPU test, a Mesa/LLVM reference, or a count over the corpus. The row cites another project's commit and says it was "not measured by us". It is honest, but it is none of the three. Part of the rule is already backed here: the RX 6800 and gfx1036 measurements in the same row show that
soffsetis added before the mode 3 check without truncation. The new parts are not backed: the full 64-bitindex * strideproduct, the "no effect" outcome in mode 2, and the swizzled offset in 64 bits. Also, "lands tens of GiB past the base and has no effect" is an inference. On hardware an address 80 GiB past the base is either a page fault or another mapping, not a guaranteed no-op. Dropping the access is a reasonable choice for a translator, but the docs and test name present it as hardware behaviour. Suggest saying "treated as out of range (the hardware address is far outside the buffer; what the console does there is not measured)", and asking someone withtools/hw_oraclefor the one probe the description proposes before merging, or recording it as a follow-up.AGENTS.md:21 asks for a hand-written
.asmfixture intests/semantic/. The test writes its assembly inline in Python (tests/semantic/test_buffer_offset_wrap.py:36-65). This is common in the suite (29.asmfixtures against 471 test files), so it is a nit.Minor cost: with a literal mode 3, linear addressing, no index and non-zero soffset,
fitsis emitted although the raw check (off + soffset + end <= NUM_RECORDS, 64-bit, at most 0xFFFFFFFF) already implies it (tools/rdna2spirv.py:4148). It is redundant, not wrong.What I checked and found correct: the 64-bit linear form
off + soffset + idx * stride(tools/rdna2spirv.py:4149-4163), whereoff(vaddr + inst_offset) still wraps at 32 bits, as the existing measured docstring says; the 64-bit swizzled form (4151-4157), which matches the 32-bit formula term by term and with L = 0 reduces toidx * stride + off;fitsis ANDed into every per-dword, typed and atomic check throughcheck_end(4256-4264), and it is computed before any branch, so it dominates its uses; and by reading the code, the folded literal-structured path without soffset emits the same SPIR-V as before (nothing new is emitted, and themodeline only moved).Verdict: the main change is correct for the case it targets (raw and disabled, run-time and literal), the test is real (5 failures without the change), and the PR merges cleanly with no overlapping open PR. Request changes on two points before merging: fix or document finding 1, and reword the "hardware observation / no effect" claim in finding 2, or measure it. Findings 3 and 4 are optional.
AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T18:27:59Z.
Review: CHANGES_REQUESTED
Follow-up on the updated head
0c3c8d166dcd1319f90598054f5cb26916eb1baf: I reran the added test file (4/4 pass) and independently reproduced the literal structured-mode boundary issue.With a literal
OOB_SELECT=1V#,NUM_RECORDS=0xFFFFFFFF, stride 20, and index0x0CCCCCCD, the index is in range butindex * stride = 0x1_0000_0004. The translator's literal-mode shortcut omitsfits; the local interpreter writes and reads 77 at wrappedbase+4(0x4004) instead of addressingbase+0x1_0000_0004(0x100004004). The same runtime V# takes thefitspath, so descriptor-folding changes the result. This is a valid structured index by the documented mode-1 check, not an out-of-range index.Please fix the literal mode-0/1 shortcut and add matched literal/runtime tests for a >32-bit product with
index < NUM_RECORDS. My earlier concern also remains: the guard suppresses all runtime mode-2 offsets above 4 GiB even though that mode performs no bounds check. Tests passing on the current head do not cover either mapped-address case; no AMD hardware result is claimed here.Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-24T18:57:07Z.
AI-assisted independent GPU verification (overnight shift, worker w4).
Environment: Windows, Git Bash; runtime built RelWithDebInfo (Ninja, VS2022 BuildTools, SDK 10.0.26100, Vulkan SDK 1.4.363.0).
llvm-mcvia WSL Ubuntu llvm-21; spirv-val on PATH.AMD Radeon iGPU (RDNA2 gfx1035, driver 24.10.24, Vulkan 1.3.280, 128B push constants):
VK_LOADER_DRIVERS_SELECT=*amd-vulkan* LEONIDA_VK_DEVICE=radeon VK_LOADER_LAYERS_DISABLE=~implicit~ LEONIDA_VK_VALIDATION=1 LEONIDA_PC_TAIL_UBO=1 py -3.14 -I scripts/run_gpu_tests.py --work <dir>ms_clip,ms_wave_info_s3: known AMD Windows LLPC 0xC0000005 mesh-shader crashes (SHADER-167; fixes in open PRs #802/#808, not in this base).ms_v5_workgroup: first run lacked spirv-val on PATH; re-run withVulkanSDK/1.4.363.0/Binon PATH → PASS (24/24 workgroup coordinates exact).NVIDIA RTX 4070 SUPER (driver 610.88):
VK_LOADER_DRIVERS_SELECT=*nv-vk* LEONIDA_VK_DEVICE=4070 VK_LOADER_LAYERS_DISABLE=~implicit~ py -3.14 -I scripts/run_gpu_tests.py --work <dir>Translator tests:
py -3.14 -I -m unittest discover -s tests/semantic -p test_buffer_offset_wrap.py→ 4/4 OK.py -3.14 -I scripts/run_semantic_tests.py tests/semantic→ 471 files, 6172 tests, 0 failed.Verdict: verified. The 32-bit buffer-offset wrap change breaks nothing on either GPU; the only AMD failures are the known mesh-shader driver crashes unrelated to this PR.
Imported from ubiquitarianism/leonida. Originally posted by Moriz82 on 2026-11-24T19:26:29Z.
Thank you both for the reviews. You were right on the main point, so the branch is reworked instead of patched: the
fits <= 0xFFFFFFFFbound is gone. The byte offset is now a 64-bit value added to the 48-bit base, in every mode and for a literal and a run-time V# alike, and each mode checks exactly what it checked before. The title and the description are rewritten to match.@KernelSmoker
NumRecords1, stride 20, index0x10000000) is a test with a literal and a run-time V#: the store lands 5 GiB past the base and the load reads it back.NUM_RECORDS0xFFFFFFFF, stride 20, index0x0CCCCCCD) is a test for modes 0 and 1, literal and run-time: all four store and read at base +0x1_0000_0004.@kawaii-shakal
tools/hw_oracleprobe is still wanted and is not done.One consequence is the opposite of the first version, so I want it to be explicit. Index −1 in mode 2 or 3 is now neither base − 20 nor dropped: it is an access tens of GiB past the base. The runtime's arena is at most 4095 MiB, so that address is always outside it, and on Vulkan that is undefined. If the project wants such an access refused, I think the bound should be the arena size and it should live where the arena is known, as a follow-up. If you would rather have it in this pull request, say so.
Run on the new head (CachyOS, Python 3.14, llvm-mc 23.1.5, SPIRV-Tools v2026.4):
tests/semantic/test_buffer_offset_wrap.pypasses 6 tests, and 11 subtests fail with the base commit's translator and with the previous head's. Full semantic suite: 471 files, 6,174 tests, 0 files failed.scripts/run_gpu_tests.pyon an RTX 4070 (620.73.04): 202 of 252 pass, 49 skipped, 1 fails (cs_imgstore_cube), test for test the same as with the base commit's translator; the harness programs were an older local build, not rebuilt. Not run here: native Windows and AMD. Your runs on the previous head do not carry over, since every indexed access now changes its SPIR-V.🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by iFeyz on 2026-11-24T19:51:06Z.
AMD run (the gap the description lists): RX 9070 XT (RDNA4, GFX1201), AMD proprietary Windows driver 26.11.2 (LLPC, Vulkan 1.4.359), Windows 11, MSVC 2022 RelWithDebInfo.
Head
e01626be9:scripts/run_gpu_tests.pywith this translator: 261 of 261 shaders translated andspirv-val-clean, 236 of 252 pass, 16 skipped, 0 failed (native, subgroup 64).tests/semantic/test_buffer_offset_wrap.py(6): OK.Imported from ubiquitarianism/leonida. Originally posted by thesubtleties on 2026-11-24T20:07:31Z.
CPU check of
e01626be9merged onto main3aa97542(CachyOS, Python 3.14).test_buffer_offset_wrap.py: 6 pass; 11 failures with main'srdna2spirv.py.run_semantic_tests.py tests/semantic: 471 files / 6,174 tests, 0 failed.mem_diff.py(2,000 programs, seed 661001) is clean on both, so it doesn't reach this case.One gap: the new tests only use the linear path. The swizzled path also moved to 64 bits and has no case above 4 GiB.
Not tested here: GPU, game corpus, what hardware does at such an address. AI-assisted (Claude Code)
Imported from ubiquitarianism/leonida. Originally posted by Moriz82 on 2026-11-24T21:08:44Z.
@thesubtleties thank you, that gap was real: the swizzled path moved to 64 bits and had no case above 4 GiB. Added to
tests/semantic/test_buffer_offset_wrap.py, with a literal and a run-time V# each:IS8, stride 20, index0x0CCCCCD5(group0x0199999A, element 5): the store and the load are at base +0x1_0000_0054; modulo 2^32 that would be base +0x54;The file now has 8 tests. With the base commit's translator 13 subtests fail (the two swizzled cases above 4 GiB are new among them; the control passes on both). Full semantic suite on the new head: 471 files, 6,176 tests, 0 files failed. The translator itself is unchanged since
e01626be9; only the test and the count in thedocs/design.mdrow changed.@iFeyz thank you for the RX 9070 XT run; the description now cites it.
🤖 Generated with Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Moriz82 on 2026-11-25T03:41:06Z.
@KernelSmoker I rebased this onto main at
bfef489cand reran the full semantic suite ona656d4f0. All 6,287 tests passed across 488 files. The eight focused cases cover mapped offsets above 4 GiB in mode 2, structured modes 0 and 1, and swizzled addressing, with both literal and runtime descriptors. Could you re-review the current head? The console behavior for an unmapped address remains unmeasured.AI-assisted.
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T19:01:31Z.
Review: APPROVED
Approving. Merged into current main (
9f9a7c5) with no conflicts.test_buffer_offset_wrap.pypasses, and the full translator suite gives 491 files / 6,300 tests with onlytest_int32_to_f64failing, the same baseline failure as main here (Linux, Python 3.13).I checked that no 32-bit offset survives in the address path. Both the linear and the swizzled forms now build
wideas a%ulong. That covers index·stride as a full 64-bit product, soffset added in 64 bits, and the swizzledmsb·stride + om4shifted in 64 bits. The finalbase + widetakes it directly. Onlyvaddr + inst_offsetstill wraps at 32 bits, as the comment says, and the bound checks are untouched.AI-assisted (Claude).
Pull request closed