Skip to content

GPU test cs_global_subdword: global sub-dword loads, d16 loads, byte and d16_hi stores - #2119

Open
Vonsek wants to merge 6 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-global-subdword
Open

Vonsek wants to merge 6 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-global-subdword

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: EGEN-GPU-GLOBAL-SUBDWORD, claim comment

What and why

The docs/design.md row "8/16-bit global stores and d16 loads" and the sub-dword loads were checked on the CPU only. This adds runtime/test/shaders/cs_global_subdword.asm, a one-group dump test that writes 34 words, with every expected word derived by hand from the RDNA2 ISA pseudocode (header of the .asm, not from the translator).

words ops what is checked
0-7 global_load_sbyte, global_load_ushort sign and zero extension of the whole register, offsets 0 to 7 in a dword, ushort at byte offset 1 (unaligned within the dword)
8-18 global_load_ubyte_d16[_hi], global_load_sbyte_d16, global_load_short_d16[_hi] only one 16-bit half changes, the other half is kept (destination starts as 0xa1b2c3d4); sbyte_d16 sign-extends to 16 bits, ubyte_d16_hi zero-extends
17-20 same loads in saddr mode and with negative immediate offsets offset:1, -8, -3, -2
21-33 global_store_byte, global_store_byte_d16_hi, global_store_short_d16_hi each store hits byte 0, 1, 2 or 3 (or both halves) of a seeded dword; the other bytes stay; a short_d16_hi at byte offset 1; saddr mode with offset:1; off mode with offset:-2

Left out because #1760 (cs_global_mem_ext) covers them: global_store_short and global_load_sbyte_d16_hi.

Registration: check.py (GLOBAL_SUBDWORD_WORDS, global_subdword_test, 128 words compared: the 34 results and 94 untouched 0xEEEEEEEE), scripts/run_gpu_tests.py, tests/test_shader_checks.py, tests/semantic/regen_fixtures.py plus the fixture, and tests/semantic/test_global_subdword_fixture.py (the hand constants against a plain-Python byte-memory model, then the translated fixture run on the CPU against the constants). The docs/design.md row now says GPU-checked.

No translator change and no translator bug found.

Tested

  • RTX 5080 (driver 616.92, subgroup 32): cs_global_subdword PASS, 128/128 dumped words exact.
  • AMD Radeon RDNA2 iGPU (Ryzen 9 9950X3D, driver 26.10.1, subgroups 32..64): PASS, 128/128 dumped words exact.
  • Negative control: in Gen.global_sub, the d16 load's OpBitFieldInsert (keeps the other half) replaced by a plain write of the whole register. Both GPUs fail: word 8: expected 0xa1b200a3, got 0x000000a3; the CPU fixture test fails on 11 words. Reverted.
  • python -m unittest discover -s tests/semantic: 1673 tests OK. python tests/semantic/regen_fixtures.py --check clean. python -I tests/test_shader_checks.py OK (60). python -I tests/test_run_gpu_tests.py OK (30).

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule; the existing contract row in docs/design.md is updated with how it was confirmed.

AI-assisted.

…and d16_hi stores

A 34-word GPU dump test for global_load_sbyte, global_load_ushort, the d16 loads
(ubyte/sbyte/short, low and high half) and global_store_byte, _byte_d16_hi and
_short_d16_hi. Expected words are derived by hand in the .asm header: sign and zero
extension, the d16 half kept, unaligned offsets within a dword, positive and
negative immediate offsets, saddr and off addressing, and neighbouring bytes kept
by the stores. The same shader is a tests/semantic fixture with a plain-Python byte
memory model. The docs/design.md row is now GPU-checked.

AI-assisted.
@AvantBras

Copy link
Copy Markdown
Contributor

Tested 1ceb75b1d63ef4c59e824baae6ebf1f11ce9b7fd on RTX 3060 12 GB, NVIDIA 580.178.04, Pop!_OS 22.04. Ran python -I scripts/run_gpu_tests.py --build <build> --filter cs_global_subdword with this PR’s translator and runner and the Linux Vulkan harnesses built at #2048’s head (UBO tail off). The module passed spirv-val; 1/1 fixture passed, no skips. All 128 dumped words matched, including the untouched fill. No game files. AI-assisted verification.

@emirduran707

Copy link
Copy Markdown
Contributor

Tested 1ceb75b on AMD Radeon RX 9060 XT (RDNA4), AMD driver 26.10.44 (LLPC, Vulkan driver 2.0.395), Windows 11 Pro 10.0.26300, subgroup 32..64: pass.

  • python -I scripts/run_gpu_tests.py --build <build> --filter cs_global_subdword: 1 shader translated, passes spirv-val; PASS cs_global_subdword 128/128 dumped words exact. Same with LEONIDA_W64_EMULATE=1.
  • Whole suite (native wave64): 186 shaders translated, 186 pass spirv-val; 168/181 passed, 13 skipped, 0 failed. The skips are the 12 fixtures the d3d12_* tests run, and ps_w64x_readlane (a skip that is on main too, see check.py: judge ps_w64x_readlane where vk_harness required 64 (its line has no "required") #2085; not from this PR).
  • build.py + check.py: 200 shaders translated, 200 pass spirv-val; 157 of 161 pass, 4 skipped (the 3 mesh fixtures and ps_w64x_readlane); cs_global_subdword ok.
  • CPU: tests/semantic/test_global_subdword_fixture.py 2 OK, tests/test_shader_checks.py 60 OK, tests/test_run_gpu_tests.py 30 OK, tests/semantic/regen_fixtures.py --check clean.

Test programs: an MSVC 14.44 build of 4eb6155, this PR's base. The PR changes no C++ or CMake (its only files under runtime/ are check.py and the .asm), so they are what its head builds; the translator, runner and check.py are this PR's. llvm-mc 21.1.8 (native), Vulkan SDK 1.4.363.0.

This adds an RDNA4 card with native 64-wide subgroups to the RDNA2 iGPU and NVIDIA runs above. I did not repeat the negative control. No game files. AI-assisted (Claude Code).

Conflicts:
	docs/design.md
	tests/test_shader_checks.py

AI-assisted.
@Vonsek

Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Merged main (a4c6bed) again; CPU checks and the PR's GPU tests pass on Radeon RDNA2 iGPU. AI-assisted.

docs/design.md
scripts/run_gpu_tests.py
tests/test_shader_checks.py

AI-assisted.
@bobcatchris

Copy link
Copy Markdown
Contributor

@Vonsek, #2860 (docs-only, replaces this same row) is withdrawn in favour of yours. Two things from its review worth carrying into your row so the merge does not lose them:

  • The measured sentence: "Measured on native gfx1100 (single thread), including a 16-bit access at byte 3 that crosses a dword; the byte loads are global_load_d16_u8/global_load_d16_i8 there." gfx1100 is not the console's gfx1013.
  • A caveat for what a single-thread kernel cannot measure: Not GPU-verified for the per-byte merge when two lanes write different bytes of one dword, and for inactive-lane masking. Without it the row reads as fully measured.

Your fixture's "byte stores that keep their neighbours" covers the single-lane merge, not contention.

AI-assisted.

@bobcatchris

Copy link
Copy Markdown
Contributor

Two of the points the row still marks unmeasured are now measured on native gfx1100 (RX 7900 XTX, Windows 11, driver 26.10.1), in case they help this PR or its fixture — they need more than one lane, which is why the single-thread kernels in #2860 could not reach them.

Method: the harness pre-fills the output buffer with 0xDEAD0000, so lane 0 clears the dword with a global_store_b32 under EXEC=0x1, then every lane stores its own byte with global_store_b8 at vaddr = v0 and vdata = 0xA0 + v0. The merged dword is simply what comes back.

case result expected
4 lanes, one byte each into one dword A3A2A1A0 A3A2A1A0
8 lanes, two dwords A3A2A1A0, A7A6A5A4 same
EXEC = 0x5, lanes 1 and 3 off 00A200A0 same

3 of 3. So adjacent lanes writing different bytes of one dword do merge (no lost byte, no dword-granular last-writer-wins), and inactive lanes write nothing — both of which the row currently lists as not GPU-verified. My first attempt looked wrong only because I cleared the buffer with a byte store, leaving two sentinel bytes; with a dword clear the hardware matches the model.

If you would rather keep the verification in your own fixture, the three kernels above are trivial to fold into cs_global_subdword; I am not filing a competing PR for that row.

Separately, this PR currently shows CONFLICTING against main — the row gained an extra sentence in the merge burst (f847748c), so it needs a rebase before it can land.

AI-assisted.

docs/design.md
tests/test_shader_checks.py

AI-assisted.
@zneel

zneel commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested 2db17cb7 on AMD Radeon RX 9070 XT (RDNA4, subgroup 32..64), AMD 26.11.2, Windows 11 Pro 10.0.26300, AMD Ryzen 7 9800X3D CPU (64 GB RAM), Python 3.12.10: pass.

Runtime and test programs built from this head (MSVC 14.51, Ninja, RelWithDebInfo), native Windows llvm-mc 21.1.8, Vulkan SDK 1.4.363.0. No game files.

run result
run_gpu_tests.py (whole suite, native wave64) 186/200, 14 skipped, 0 failed (main 49475796: 170/185)
same with LEONIDA_W64_EMULATE=1 186/200, 14 skipped, 0 failed
pytest tests/test_shader_checks.py tests/test_run_gpu_tests.py 112 passed, 266 subtests passed in 2.98s
unittest discover -s tests/semantic -p test_global_subdword_fixture.py 2 OK
tests/semantic/regen_fixtures.py --check clean

This PR's shaders:

  • native: PASS cs_global_subdword 128/128 dumped words exact; emulated: PASS cs_global_subdword 128/128 dumped words exact

cs_global_subdword gives 128/128 words exact on RDNA4, native and emulated. That includes the unaligned ushort load, the d16_hi loads and stores, and the byte stores.

AI-assisted (Claude Code); I checked the results.

runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/test_shader_checks.py

AI-assisted.
@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b8565faf (the rebased head) on NVIDIA GeForce RTX 3060 Ti (subgroup 32..32), driver 580.173.02, Linux (kernel 6.18), Python 3.14: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed. cs_global_subdword: 128/128 dumped words exact.
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_global_subdword_fixture.py tests/test_shader_checks.py: 81 passed, 264 subtests passed.

No game files. AI-assisted (Claude Code).

@tedin7

tedin7 commented Nov 23, 2026

Copy link
Copy Markdown

Tested b8565fa (merge base aa2988c) on NVIDIA GeForce RTX 5080, Linux 580.65.06: pass

Tested the PR head merged with current main 03b09a08 (clean merge, not pushed). Runtime harnesses built from main 03b09a08 (no PR in this list changes C++/CMake), llvm-mc 21, Python 3.13, Vulkan SDK 1.4.363, Linux native.

Check main 03b09a08 this PR
run_gpu_tests.py native 164/210 passed, 46 skipped 165/211 passed, 46 skipped
run_gpu_tests.py with LEONIDA_W64_EMULATE=1 195/210 passed, 15 skipped 196/211 passed, 15 skipped
failed (native / emulated) 0 / 0 0 / 0
tests/semantic/regen_fixtures.py --check ok ok
pytest tests/semantic/test_global_subdword_fixture.py tests/test_shader_checks.py + tests/test_shader_checks.py 156 passed (3 shared files) 158 passed, 310 subtests passed in 3.57s

Line-by-line against my main run (results that differ from main):

  • native:
    • cs_global_subdword main: - pr: PASS 128/128 dumped words exact
  • emulated:
    • cs_global_subdword main: - pr: PASS 128/128 dumped words exact

Not run: the full unittest discover -s tests/semantic (7456 tests, about 6 minutes; on main alone it shows 7 failures and 2 errors in test_cmp_class_f64, test_loop_ballot_barrier and test_mutations, so I did not repeat it per PR); only the test files this PR touches plus the shared checker tests ran. No other GPU vendor, no Windows. No game files.

AI-assisted (Claude Code).

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b8565faf (merge base aa2988cc) on an NVIDIA GeForce RTX 5070 Ti (Blackwell, subgroup 32..32), driver 616.56, Windows 11 10.0.26300. Translator and fixtures from this head; runtime test programs built from main aa2988cc (MSVC 19.44, Vulkan-Headers fetched by CMake, loader from the NVIDIA driver); spirv-as/spirv-val and llvm-mc 21 from WSL Ubuntu: pass.

  • scripts/run_gpu_tests.py: 165/211 passed, 46 skipped (wave64 programs on a 32-wide GPU), 0 failed.
  • Diffed test by test against main aa2988cc (164/210, 46 skipped): every main result is the same here.
  • New: cs_global_subdword PASS (128/128 dumped words exact).

Not run: LEONIDA_W64_EMULATE=1, other vendors, Linux. No game files.

AI-assisted (Claude Code).

@Mast3rL

Mast3rL commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested b8565faf on AMD Radeon RX 9070 (RDNA4, gfx1201), RADV / Mesa 26.2.6, Fedora 44 Linux, llvm-mc 21: pass.

  • scripts/run_gpu_tests.py (Linux build of the PR head): 197/211 passed, 14 skipped, 0 failed. The only difference from main (03b09a08, 196/210) is the new cs_global_subdword: PASS, 128/128 dumped words exact.
  • runtime/test/shaders/check.py: 185 of 185 pass, 0 skipped, cs_global_subdword ok.
  • tests/test_shader_checks.py: OK. tests/semantic: 7,458 tests; 7 failures + 2 errors, the same 9 as on main at 03b09a08 on this machine (loop/ballot emulation, v_mul_legacy_f32 mutation, v_cmp_class_f64 rejected forms), so none come from this PR.

AI-assisted (Claude Code).

@tylerstraub

Copy link
Copy Markdown
Contributor

Tested f13edfb164440de5809b89cd406f9a35784227c5 on NVIDIA GeForce RTX 5090, 595.99.02 (Linux).

The rebased cs_global_subdword fixture passed on Linux RTX 5090 with the default runner settings and again with LEONIDA_W64_EMULATE=1. Both shaders passed SPIR-V validation. Both dispatches matched all 128 expected buffer words.

The fixture distinguishes signed and unsigned extension of byte 0x80 and checks that a 16-bit load preserves the other half of the destination register. Its store readbacks also check the bytes neighboring a narrow write. This run covered the single synthetic fixture.

AI-assisted (Codex).

AI-assisted verification.

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 / MoltenVK validation of head f13edfb1 (hardware reports Apple M2 / Mac14,3, not M1), macOS 26.4, MoltenVK 1.4.2, subgroup range 4..32, llvm-mc 23.1.6. Python/translator-only change; the C++ harness was built once from the shared base 3eb4410b for a clean A/B.

  • New GPU fixture cs_global_subdword PASS: cs_global_subdword 128/128 dumped words exact
  • Full suite on the PR head: 217 shaders translated, 217 pass spirv-val; 153/218 passed, 58 skipped, 7 failed (the known MoltenVK expected set). Base 3eb4410b with the identical harness: 152/217, 58 skipped, 7 failed. The only difference is this PR's new passing fixture; no common test changed status in either direction.

No code changes, no game data; synthetic fixture and counts only.

AI-assisted.

@gertify

gertify commented Nov 23, 2026

Copy link
Copy Markdown

Tested f13edfb on Intel UHD 630 (CFL GT2), Mesa 25.2.8 ANV, Ubuntu 24.04: pass. run_gpu_tests.py --filter cs_global_subdword on the Intel device: the shader translates and passes spirv-val, and cs_global_subdword gives 128/128 dumped words exact (1/1 passed). AI-assisted.

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.