Skip to content

test(shader): GPU fixture cs_w32_ds_minmax for LDS atomic min/max (ds_max_u32, ds_min_i32, ds_max_i32, ds_min_u32) - #2582

Open
Vonsek wants to merge 3 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-ds-minmax
Open

Vonsek wants to merge 3 commits into
ItsNotRexed:mainfrom
Vonsek:test/gpu-ds-minmax

Conversation

@Vonsek

@Vonsek Vonsek commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Requested by Lucas · project thread

Claimed in the coordination issue as: #2516 (comment)

What and why

gaps.md lists ds_max_u32 and ds_min_i32 as tested on the CPU only; no runtime/test/shaders shader names any of the 32-bit LDS min/max atomics. This adds cs_w32_ds_minmax.asm, a wave32 compute fixture for ds_max_u32, ds_min_i32, ds_max_i32, ds_min_u32 and their _rtn_ forms, with the expected words derived by hand from the ISA pseudocode in its header.

  • 32 lanes run each op on one address with data 0x7FFFFFF0 + lane, so the values straddle the signed boundary. Min and max do not depend on arrival order, so the final word is exact (out[0..3]).
  • Lane 0 then runs the four _rtn_ forms; out[4..7] is the returned old value XOR the word left in memory, so both are checked.
  • Every word differs from what the other signedness would give.

Registered in check.py and run_gpu_tests.py, as a regen_fixtures.py fixture, with a CPU twin tests/semantic/test_lds_minmax_fixture.py (plain-Python reference, lane 0 through the interpreter) and a docs/design.md row. No translator change: the translator was already right on both GPUs.

ds_wrxchg_rtn_b64 and the other exchanges are left out because #2003 covers them. The ds_or/xor_b64 ops are #1850's. #2295 is the CPU-only ds_min_i32 test and does not overlap.

Tested

  • NVIDIA GeForce RTX 5080 (driver 616.92, subgroup 32): 8/8 words, cs_w32_ds_minmax PASS.
  • AMD Radeon RDNA2 iGPU (driver 26.10.1, run at subgroup size 32): 8/8 words, PASS.
    Both: 0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01 (device lines confirmed with vk_compute_test).
  • Negative control: changing ds_max_u32 to OpAtomicSMax in the translator makes the test fail on both GPUs (out[0] 0x7fffffff, out[4] 0x0) and the semantic twin; reverted.
  • python -m unittest discover -s tests/semantic: 2571 tests OK (3 skipped). regen_fixtures.py --check and tests/test_shader_checks.py pass.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • No new translator rule; the existing LDS min/max row is added to the contract table in docs/design.md with its GPU check.

AI-assisted.

…gned and unsigned, plain and _rtn_

32 lanes contend for one address with data straddling the signed boundary, then lane 0 runs the _rtn_ forms.
Checked on an RTX 5080 and the Radeon RDNA2 iGPU. Semantic twin and design.md row included.

AI-assisted.
@duudiis

duudiis commented Nov 22, 2026

Copy link
Copy Markdown

Independent RTX 5070 / Windows 11 result at 1e011ae (driver 621.24, 32-wide physical subgroups): the PR fixture matched all eight words. The four focused semantic tests and all 60 shader-check tests passed.

I also checked all four _rtn_ forms under contention. In 64 groups of 128 lanes, 112 lanes per group updated the same dword per operation. The remaining lanes were disabled through EXEC, with signed and unsigned boundary operands in some disabled lanes. I reconstructed a valid sequential history from the old values: every changing return formed one monotonic chain from the seed to the final word, and every no-op return belonged to a state on that chain.

Both native wave32 and emulated wave64 passed SPIR-V validation and each matched 28,672 returned values, 32,768 final reads and 4,096 inactive-register checks. A negative control kept the atomic update but wrote its input to the destination instead of its old value. The final words still matched and the reconstructed history failed in both configurations.

@Yourrespawn

Copy link
Copy Markdown
Contributor

Tested 1e011ae6 on NVIDIA GeForce RTX 4080 (Ada, subgroup 32..32), driver 617.14, Vulkan API 1.4.351, Windows 11 Pro 10.0.26200: pass.

  • run_gpu_tests.py: cs_w32_ds_minmax PASS natively — 0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01 — the signed/unsigned boundary words exact on NVIDIA silicon, closing another "not GPU-verified" LDS family cross-vendor; suite 140/186 passed, 46 skipped (native wave64, expected on this 32-lane GPU)
  • tests/semantic/test_lds_minmax_fixture.py via discover: 4/4 OK

AI-assisted (ZCode agent): builds and runs executed by a coding agent on this machine.

@ricarmandoagent

Copy link
Copy Markdown

Tested 1e011ae6 on NVIDIA GeForce RTX 4060 (Ada, AD107; Vulkan subgroupSize 32..32), NVIDIA 620.70.06, Vulkan 1.4.357, Bazzite 45 / Linux 7.3.4 (Wayland).

Test programs built from 4947579 (this PR changes no runtime/ C++):

python -I scripts/run_gpu_tests.py --build runtime/build/linux --filter cs_w32_ds_minmax
  PASS  cs_w32_ds_minmax      0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01
1/1 passed

The eight LDS atomic min/max words (signed and unsigned, plain and _rtn) match the fixture's derivation on a second vendor and driver. .spv passed spirv-val (LLVM 23.1.5). AI-assisted run on a contributor machine.

@Marukooh

Copy link
Copy Markdown
Contributor

Tested 1e011ae on NVIDIA GeForce RTX 5070 Ti (Blackwell), NVIDIA 620.73.04, CachyOS Linux. Built the Vulkan harness from this PR and ran scripts/run_gpu_tests.py --filter cs_w32_ds_minmax with LEONIDA_W64_EMULATE=0 and =1. The synthetic module passed SPIR-V validation and matched all eight expected words in both runs. The four semantic fixture tests passed too. AI-assisted.

@umnitus

umnitus commented Nov 22, 2026

Copy link
Copy Markdown

Independent Windows GPU check: PASS on RTX 3060 12 GB (driver 621.14, Vulkan 1.4.357, Windows 11 26H2, Ryzen 5 3600).

Head: 1e011ae
With LEONIDA_W64_EMULATE=0, ran:
python -B -I scripts/run_gpu_tests.py --build --work --filter cs_w32_ds_minmax

The shader translated and passed spirv-val. GPU readback matched all eight expected words (1/1 passed, exit 0):
0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01

AI-assisted test execution and write-up.

@shadshuvo

Copy link
Copy Markdown

Independent check of #2582 (1e011ae677e1e138cc55a9a0da2f5609b7882b9f) on Windows 11, AMD Radeon RX 7800 XT (driver 24.20.19.05 / Vulkan 1.4.359):

  • python -m compileall -q make_game.py tools tests: pass.
  • python -I make_game.py --help: pass.
  • python tests/semantic/regen_fixtures.py --check: pass (exit 0).
  • python tests/test_shader_checks.py: 60/60 passed.
  • python -m unittest discover -s tests/semantic -p "test_lds_minmax_fixture.py": 4/4 passed (test_ds_max_i32_reference, test_ds_max_u32_reference, test_ds_min_i32_reference, test_ds_min_u32_reference).
  • python -m unittest discover -s tests/semantic: 2,571 passed, 3 skipped (0 regressions).

The 32-lane signed-boundary straddle 0x7FFFFFF0 + lane correctly distinguishes unsigned vs signed min/max, and the _rtn_ XOR verify in lane 0 matches expected words. Clean addition with no regressions.

Synthetic test fixtures only; no game files. AI-assisted.

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

AI-assisted.
@crastinator

Copy link
Copy Markdown
Contributor

Tested abb2724 merged into main 16282101 (clean merge) on AMD Radeon RX 6700 XT (Navi 22, gfx1031, subgroup 32..64), RADV Mesa 26.3.1, CachyOS, Linux 7.3.5, GCC 16.2.1, llvm-mc 23.1.5: pass.

  • New test passes natively: cs_w32_ds_minmax (0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01).
  • Whole run_gpu_tests.py: 176/190 native, 176/190 with LEONIDA_W64_EMULATE=1 (the skips are the D3D12-only fixtures and ps_w64x_readlane, as on main). ctest 37/37.
  • tests/semantic/test_lds_minmax_fixture.py: 4 passed, 2 subtests passed.

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

@bobcatchris

Copy link
Copy Markdown
Contributor

Apple M2 data for the new LDS min/max fixture (macOS 26.4, MoltenVK 1.4.2 direct, subgroup 4..32, llvm-mc 23.1.6, Python 3.13.18), head abb2724.

python -I scripts/run_gpu_tests.py --filter cs_w32_ds_minmax --build runtime/build/linux: 1 shader translated, 1 pass spirv-val, but 0/1 passed / 1 skipped — "the device can't run this shader at 32 lanes on request" (the known MoltenVK 32-lane harness limitation). I then locally merged open PR #2886 (exact-32-lane fix) into a throwaway worktree of this head — no push, no change to your branch — rebuilt and re-ran: 1 shader translated, 1 pass spirv-val; 1/1 passed, out words 0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01, 0 mismatches. So the fixture is correct on this Apple GPU once the 32-lane harness issue is resolved.

Full builds at these heads fail on AppleClang 17 at vk_pipeline_check.cpp:567 (BUILD-822, fixed by open PR #2927); GPU binaries built, so the runs above are valid. Synthetic shader and counts only; no game files.

AI-assisted.

@Kam471

Kam471 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

Tested abb272484560308ff3111da375267cc9cf46c658 on Windows 11, NVIDIA GeForce RTX 5070 Ti (desktop, 16 GB), driver 621.24, Vulkan 1.4.357.

  • python -I scripts/run_gpu_tests.py --build ... --filter ds_minmax -> 1/1 passed, 0 skipped, 0 failed; translator 1 shader, 1 pass spirv-val. cs_w32_ds_minmax returned 0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01.
  • python tests/semantic/test_lds_minmax_fixture.py -> 4 tests OK (run without -I).

Nit: python -I tests/semantic/test_lds_minmax_fixture.py fails with ModuleNotFoundError: No module named spirv_mini_interp because -I removes the script directory from sys.path; adding the usual support bootstrap would make the mandated -I invocation work. No game files.

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested abb2724 merged onto main f847748 on an RTX 5090 (driver 616.92), Windows 11, Vulkan SDK 1.4.363. The GPU test programs were built from the same tree:

  • scripts/run_gpu_tests.py: 154/200 passed, 46 skipped, 0 failed. main f847748 gives 153/199, 46 skipped, 0 failed. All 205 test shaders translate and pass spirv-val.
  • New GPU tests: cs_w32_ds_minmax PASS.
  • tests/semantic/test_lds_minmax_fixture.py: ran 4 tests in 0.078s; OK.

AI-assisted (Claude Code).

docs/design.md
runtime/test/shaders/check.py
scripts/run_gpu_tests.py
tests/semantic/regen_fixtures.py

AI-assisted.
@throny

throny commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested f0a6cdb on NVIDIA RTX 4080, driver 610.88, Windows 11: pass

This is the head rebased on aa2988cc; the earlier checks were at abb27248. Ran (MSVC 19.44 / VS 2022 BuildTools, Ninja, RelWithDebInfo, Vulkan SDK 1.4.363.0, native llvm-mc 23.1.6; test programs built from this branch):

  • python -I scripts/run_gpu_tests.py --filter ds_minmax, three runs: 1/1 each, cs_w32_ds_minmax PASS with the same eight words every time.
  • Full run_gpu_tests.py: 165/211 passed, 46 skipped, 0 failed.
  • python -I runtime/test/shaders/check.py <that work dir> <build>: 151 of 185 pass, 34 skipped, 0 failed; cs_w32_ds_minmax ok.
  • CPU: test_lds_minmax_fixture (run from tests/semantic) and tests/test_run_gpu_tests.py: OK.

AI-assisted.

@TreXito

TreXito commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested f0a6cdb9 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_w32_ds_minmax passes with the same 8 words as your two GPUs: 0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01.
  • ctest: 47/47 passed.
  • pytest tests/semantic/test_lds_minmax_fixture.py: 4 passed, 2 subtests. Same with the base's tools/ (aa2988c), as expected with no translator change.

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

@tunczzz

tunczzz commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Tested f0a6cdb9 (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_w32_ds_minmax PASS (0x8000000f 0x80000000 0x7fffffff 0x7ffffff0 0xf0000000 0xfffffffe 0xefffffff 0xffffff01).

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

AI-assisted (Claude Code).

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.