Skip to content

rdna2spirv: buffer_load_{u,s}{byte,short}, GFX10_FORMAT_8_UINT, and global_atomic_fmin/fmax - #1968

Closed
SweatierKey wants to merge 1 commit into
ItsNotRexed:mainfrom
SweatierKey:xboxbvh-translator-rules
Closed

SweatierKey wants to merge 1 commit into
ItsNotRexed:mainfrom
SweatierKey:xboxbvh-translator-rules

Conversation

@SweatierKey

Copy link
Copy Markdown
Contributor

Follow-up to #1813 covering the four remaining translator rules needed by the 10 untranslated XboxBvhBuilder.dll compute shaders (claim: #1902 (comment)).

Changes

  • Sub-dword MUBUF loads (tools/rdna2spirv.py, Gen.buffer_load_sub): buffer_load_ubyte, buffer_load_sbyte, buffer_load_ushort, and buffer_load_sshort using buffer_address(..., elem=1|2) for exact element-end OOB_SELECT checks, zero/sign extension to 32 bits, dword-crossing 16-bit merge at addr % 4 == 3 without over-reading past the buffer, and inactive-lane preservation. Unblocks Box16Rehydration, Box32Rehydration, ReloadTriangles.
  • GFX10_FORMAT_8_UINT (code 5) (tools/rdna2spirv.py, Gen.FORMATS): 1-byte unsigned integer format for tbuffer_load_format_* and buffer_load_format_* (with DST_SEL integer 1 and invalid V# format-0 suppression). Unblocks LeafRehydration.
  • 32-bit float global atomics (tools/rdna2spirv.py, Gen.global_atomic_float): global_atomic_fmin and global_atomic_fmax lowered to a structured OpAtomicCompareExchange CAS loop with GLSL.std.450 NMin/NMax (no shader float-atomic Vulkan extension required; NaN returns the non-NaN operand, -0.0 < +0.0, inactive lanes do not touch memory and keep vdst). Unblocks BuildKDOP, LoadInstances, ReloadProcedurals, LoadProceduralGeometry, LoadTriangles, PT_LoadInstances.
  • Semantic interpreter (tests/semantic/spirv_mini_interp.py): ignore OpLoopMerge at runtime (already checked structurally by check_structure()) and permit bounded backward branches (10,000 back-edge cap) so structured CAS loops execute on the CPU.
  • Tests & docs: added tests/semantic/test_buffer_load_sub.py, extended tests/semantic/test_global_atomics.py, and documented the contract rows in docs/design.md.

Testing (CPU / synthetic only, no game files, no GPU)

  • python3 -m compileall -q make_game.py tools tests: OK
  • tests/semantic/test_global_atomics.py: 12/12 OK (value grid incl. NaN/±0/±inf, multi-lane CAS contention, inactive lane, offsets, off addressing, glc/non-glc, first-read analysis)
  • tests/semantic/test_buffer_load_sub.py: 9/9 OK (all byte offsets 0..7 incl. dword-crossing 16-bit, OOB modes 0/1/2/3, inactive lane, tbuffer_load_format_x/buffer_load_format_xyzw GFX10_FORMAT_8_UINT)
  • tests/semantic/test_buffer_load_format.py (27/27), test_buffer_swizzle.py (7/7), test_global_atomics_x2.py (4/4), test_interp_merge_check.py (4/4), tests/test_isa_coverage.py, tests/test_shader_index.py, tests/test_docs_links.py: all OK
  • spirv-as --target-env vulkan1.2 + spirv-val --target-env vulkan1.2 --allow-offset-texture-operand (SPIRV-Tools v2025.5): all 6 synthetic fixtures pass (native and --wave64-emulate).

AI-assisted.

@SweatierKey
SweatierKey force-pushed the xboxbvh-translator-rules branch from 427c137 to 71f6358 Compare November 22, 2026 15:43
@MelonPy

MelonPy commented Nov 22, 2026

Copy link
Copy Markdown

Tested 427c137 on Intel Arc Graphics (Meteor Lake-H iGPU, Xe-LPG, 0x8086:0x7d55), Intel driver 32.0.101.6127, Vulkan 1.3.295, Windows 11 Pro 26H2 (build 26300), llvm-mc 23.1.6 (native, conda-forge): pass, no regression.

  • python -m unittest discover -s tests/semantic: 1657 tests OK.
  • scripts/run_gpu_tests.py: 178 shaders, 177 translated, 177 pass spirv-val; 123/173 passed, 50 skipped, 0 failed (native); 154/173 passed, 19 skipped, 0 failed (LEONIDA_W64_EMULATE=1). The skips are this device's usual ones (no 64-wide subgroup natively, no fragment barycentrics, no maintenance8).

The PR adds no GPU test, so this checks that the translator change breaks nothing on a 32-wide Intel device, not the new loads and atomics on hardware. The branch has moved since (now 71f6358); I have not rerun that head.

@bielfreedom

Copy link
Copy Markdown

Tested 71f63581 (the current head) on AMD Radeon RX 9070 XT (RDNA4), AMD driver 32.0.32029.2010 (subgroup 32..64), Windows 11 Pro build 26200: pass, no regression. This adds an AMD run to the Intel Arc result above, which was on 427c1376.

  • Full scripts/run_gpu_tests.py built from the PR's own runtime/ (MSVC, -DLEONIDA_VULKAN_HEADERS_FETCH=ON): 185 shaders, 185 translated, 185 pass spirv-val; 167/180 passed, 13 skipped, 0 failures. The 13 skips: 12 shaders run by the d3d12 tests (cs_buf_counter, cs_buf_typed, cs_m4_*, ps_m15/ps_m2*/ps_m3*, vs_m15/vs_m2/vs_m3) and ps_w64x_readlane (no required 64-wide fragment subgroup on this device).
  • python -m unittest discover -s tests/semantic: 1684 tests OK.

The new sub-dword loads, 8_UINT and float global atomics have no GPU fixture in this PR, so this run shows nothing else regressed; it does not exercise those paths on hardware.

Tools: llvm-mc 23.1.6 and SPIRV-Tools from conda-forge on Windows. No game files.

AI-assisted (Claude Code).

@wildheathen

Copy link
Copy Markdown
Contributor

Checked on the 52 XboxBvhBuilder.dll programs (1.0.2.1 package). I extracted them with tools/pe_shader_containers.py, unpacked them with fssm_unpack.py and disassembled them with shader_disasm.py --mcpu gfx1013 (llvm-mc 21), following docs/embedded_shaders.md. The extracted shaders stay local.

branch translated and spirv-val-valid left
main (4eb6155) 43 / 52 Box16Rehydration, Box32Rehydration, BuildKDOP, LoadInstances, LoadProceduralGeometry, LoadTriangles, PT_LoadInstances, ReloadProcedurals, ReloadTriangles
this PR (71f6358) 51 / 52 Box16Rehydration: buffer_store_short

buffer_store_short is in #1864 (8/16-bit MUBUF stores). With both, all 52 builder programs should translate, including the three rehydration programs (Box16, Box32, Leaf). I did not run them on a GPU. CPU only, Windows 11.

AI-assisted.

@SweatierKey

Copy link
Copy Markdown
Contributor Author

Already merged into main as 427c1376 during round 39 (right around my rebase push 71f63581). Closing to keep the PR queue clean.

ItsNotRexed added a commit that referenced this pull request Nov 22, 2026
# Conflicts:
#	docs/design.md
Vonsek added a commit to Vonsek/Leonida that referenced this pull request Nov 22, 2026
… rule (buffer_store_short) left (PROC-120)

Recounted with main 4947579 on the 1.0.2.1 package (counts only): 52/52 unpack,
42 clean and 10 with invalid words in the disassembly, 51 translate and pass
spirv-val. The four rules embedded_shaders.md listed are three since 427c137
(ItsNotRexed#1968); Box16Rehydration stops at buffer_store_short (ItsNotRexed#1864). d3d12_vulkan.md
and the docs index quoted 41/42 and four rules in seven places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
adriaespii added a commit to adriaespii/Leonida that referenced this pull request Nov 22, 2026
Update docs/embedded_shaders.md §4 and §5 and related references in
docs/d3d12_vulkan.md to reflect current main: 51 of 52 XboxBvhBuilder.dll
compute shaders now translate and pass spirv-val since ItsNotRexed#1871
(GFX10_FORMAT_8_UINT) and ItsNotRexed#1968 (427c137: global_atomic_fmax/fmin and
buffer_load_ushort) landed.

Only Box16Rehydration remains blocked, awaiting buffer_store_short (ItsNotRexed#1864).

Claim: ItsNotRexed#2300 (comment)
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
… rule (buffer_store_short) left (PROC-120)

Recounted with main 4947579 on the 1.0.2.1 package (counts only): 52/52 unpack,
42 clean and 10 with invalid words in the disassembly, 51 translate and pass
spirv-val. The four rules embedded_shaders.md listed are three since 427c137
(#1968); Box16Rehydration stops at buffer_store_short (#1864). d3d12_vulkan.md
and the docs index quoted 41/42 and four rules in seven places.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ItsNotRexed pushed a commit that referenced this pull request Nov 22, 2026
Update docs/embedded_shaders.md §4 and §5 and related references in
docs/d3d12_vulkan.md to reflect current main: 51 of 52 XboxBvhBuilder.dll
compute shaders now translate and pass spirv-val since #1871
(GFX10_FORMAT_8_UINT) and #1968 (427c137: global_atomic_fmax/fmin and
buffer_load_ushort) landed.

Only Box16Rehydration remains blocked, awaiting buffer_store_short (#1864).

Claim: #2300 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants