Skip to content

wave64_halves: accept kill exits through mask arithmetic (SHADER-1155) - #7380

Open
shdann wants to merge 1 commit into
ItsNotRexed:mainfrom
shdann:shdann/leonida-w64-exits
Open

shdann wants to merge 1 commit into
ItsNotRexed:mainfrom
shdann:shdann/leonida-w64-exits

Conversation

@shdann

@shdann shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Claim: #7231 (comment) (SHADER-1155, carried to #7333).

An exact kill exit can set empty EXEC with WQM or SAVEEXEC, or through a temporary mask. The old inert_exit check only accepts a direct MOV or AND into EXEC. It gives these other forms tier C.

This change uses the existing confine_step mask facts on the exit. Each export and the end must have EXEC inside the whole quads of the voted mask. Only mask arithmetic and plain jumps can run before that. An exit cannot enter the run side. The mask-emptiness test, confined run side, and check for a prior vm export are unchanged.

Why this is exact: when one half votes no, the mask in that half is empty. Its whole quads and all tracked subsets are empty too. The exit writes no lane output. The run side keeps those same lanes off in the full wave. Scalar results of the exit cannot reach another path, since the exit ends.

Tests use hand-written listings only. Six accepted forms are tier A and give equal outputs as one 64-lane wave and two 32-lane waves; the same six forms are also checked as pixel shaders. Six near misses stay tier C and give different outputs: a different mask, restore of the saved launch EXEC, a rewritten copy, a rewritten mask half, union with the launch mask, and export before clearing EXEC. All twelve vertex listings produce the same SPIR-V before and after this change.

The pixel fixture ps_w64_a_discard_exit_masks has three kill exits: direct WQM, SAVEEXEC and WQM through a temporary mask. On NVIDIA GeForce RTX 4090, driver 621.01, Windows 11, with required fragment subgroup size 32, all 4096 pixels match the derived words. The harness prints the device and applied size. The same draw passes with validation enabled. A 64-wide GPU comparison was not run.

Validation on main 8575d36ed and head 7b7f64133, Python 3.14.7, LLVM 21.1.8, Vulkan SDK 1.4.363.1:

  • Full semantic suite, 12 jobs: main has 5889 tests; this branch has 5891 tests. Both fail the same two files, test_image_atomics_guard and test_image_store_d16. The 48 failure entries match by test and subtest name. No new failure occurs.
  • All test_wave64*.py: 237 tests pass. The new file has two tests: six accepted forms, checked as VS and PS, and six differing exit near misses. The 160 tests in test_wave64_halves*.py also pass.
  • Fixture, argument, reference and contract-row tests: 18 pass, with two subtests. Other design-row and table-row checks: seven pass, with 12 subtests.
  • Hygiene and contract tests: eight pass; the line-ending scan fails on tools/leonida_tui.py:753 and tools/wave_diff.py:373. Untouched main has the same failure. Neither file is changed here.
  • New fixture and vs_ids: two translated, two valid for spirv-val, before and after. The new fixture is tier C before and tier A after; its SPIR-V is byte-identical.
  • Targeted compileall, git diff --check and scripts/check_no_game_data.py: pass.

The full-suite summaries are:

443 files, 5889 tests, 2 files failed in 659 s with 12 jobs: test_image_atomics_guard, test_image_store_d16
444 files, 5891 tests, 2 files failed in 663 s with 12 jobs: test_image_atomics_guard, test_image_store_d16

Scope and overlap: this extends merged #2674. It does not implement the two-sided join of #5747, the run-side check of #4541, or the uniform compare of #6963. It uses the existing run-side confinement for kills. General other-side-exits and no-narrowing cases stay out. No corpus count is claimed. No game files are used.

Please run a before/after census if you have your own game copy. Report tier A/B/C counts and the number of changed SPIR-V files, counts only. This change is expected to change no SPIR-V file, but its corpus coverage is not measured.

AI-assisted: OpenAI Codex wrote the change and ran the checks on this machine.

  • No game data, keys or decryption, including in this report.
  • The new rule and its checks are in the SHADER-10 contract row of docs/design.md.

@SlopTart

Copy link
Copy Markdown

Verification row — RX 7900 XT (RADV NAVI31, Mesa 26.2.5, Arch, native wave64 subgroups 32..64). Merged head 7b7f64133 clean onto current main 042c5f378, full build:

Two harness usability notes for the next verifier (not PR-blocking): w64_graphics.py's first argument is the work dir (it appends spirv/ itself) — passing the spirv dir yields a misleading missing X.spv; and the fixture must first be translated by build.py into that same work dir, since run_gpu_tests.py deliberately skips w64_* graphics cases there.

No game files; all synthetic fixtures. Posted by Hermes (agent).

@devnull34 devnull34 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: passes all 125 tests in test_wave64_halves.py and test_wave64_kill_exit_masks.py. Correctly tracks empty masks through kill exit paths with mask arithmetic (s_or_b64, s_xor_b64, s_andn2_b64), allowing wave64-to-wave32 partition invariance verification without spurious tier C regressions.

@ErayOzdayioglu

Copy link
Copy Markdown

Tested 7b7f641 on Windows 11 26200 with AMD's Windows driver (the run above was RADV). MSVC 14.51 (VS 2026), Vulkan SDK 1.4.363, llvm-mc 23.1.6, test programs built from this head. pass

  • pytest tests/semantic/test_wave64_kill_exit_masks.py tests/test_wave64_halves_fixtures.py: 12 passed, 12 subtests passed.
  • Control, the same two files with the merge base's tools/wave64_halves.py: 7 failed, e.g. test_accepted [copy_union] and test_fixtures_are_classified_as_their_headers_say. So the new cases do pin the change.
  • GPU: runtime/test/shaders/build.py (5/5 translated and valid, tier A: 3), then w64_graphics.py <out> <tools> ps_w64_a_discard_exit_masks ps_w64_a_discard:
    • Radeon iGPU, Ryzen 5 7600 (RDNA2, subgroup 32..64, AMD 32.0.21042.62): it can require 64 and 32 in the fragment stage, so this is the full one-wave-vs-two-halves comparison. Result: ps_w64_a_discard_exit_masks A ok, ps_w64_a_discard A ok.
    • RTX 5070 (617.42, 32 only, so a check against the derived words): both A ok.

AI-assisted: yes

@DeSunShine

Copy link
Copy Markdown
Contributor

Tested 7b7f64133 merged into main 6f58bd2c5 on NVIDIA GeForce RTX 4090 (driver 621.24), Windows 11 Pro 26200, MSVC (VS Build Tools 18) + Ninja, Vulkan SDK 1.4.363, llvm-mc 23.1.6, Python 3.15: pass.

  • python -m pytest -q tests/semantic/test_wave64_kill_exit_masks.py tests/test_wave64_halves_fixtures.py: 12 passed, 12 subtests passed.
  • python -I scripts/run_gpu_tests.py (native): 191/240 passed, 48 skipped, only FAIL is ms_wave_info_s3 (same as plain main 6f58bd2c5).
  • LEONIDA_W64_EMULATE=1 python -I scripts/run_gpu_tests.py: 222/240 passed, 17 skipped, only FAIL is ms_wave_info_s3 (same as plain main).
  • --filter ps_w64_a selects no test in run_gpu_tests.py (the new ps_w64_a_discard_exit_masks.asm is not run on the GPU by it), so the GPU runs above are a regression check only.

AI-assisted (Claude Code).

@airp1ane

Copy link
Copy Markdown
Contributor

Tested 7b7f641 on Windows 11, Python 3.15.2, NVIDIA RTX 4060 Ti (driver 621.24; CPU-only checks, no game files, no GPU/llvm-mc/MSVC used): pass.

Ran the test files this PR adds or changes, from a clean checkout of the PR head: test_wave64_halves_fixtures.py - all exit 0. The translator semantic suite was not run for this PR.

AI-assisted (Claude Code).

@InCaseOf

Copy link
Copy Markdown

Tested 7b7f641 on RX 5700 XT (RDNA1, gfx1010, RADV NAVI10), Mesa 26.3.1, Linux 6.18: pass

  • scripts/run_gpu_tests.py: 211/239 passed, 28 skipped, 0 failed.
  • ps_w64_a_discard_exit_masks (added/changed here): not run by run_gpu_tests.py (C++ test or w64_graphics.py).
  • w64_graphics.py over all fixtures: 30/30 ok.
  • tests/test_wave64_halves_fixtures.py: 10 passed in 1.37s
  • scripts/run_semantic_tests.py tests/semantic -j 8: 444 files, 5891 tests, 2 files failed (the same 2 files that fail on main here, nothing new).
  • python -m unittest discover -s tests/semantic -p test_wave64_kill_exit_masks.py: 2 tests OK.

LLVM llvm-mc 23.1.5, SPIRV-Tools v2026.4, Python 3.14; test programs built from main e36d4c4 unless rebuilt for the PR as noted. main e36d4c4 on the same GPU: run_gpu_tests.py 212/240, 28 skipped, 0 failed; w64_graphics.py 29/29; semantic suite 2 files failing (test_image_atomics_guard, test_image_store_d16). No game files.

AI-assisted (Claude Code).

@Kev-Ball

Copy link
Copy Markdown

The requested retail 1.0.2.1 census is complete. On CachyOS I translated the same 26,503 ordinary DXBC listings at parent 8575d36ed and PR head 7b7f64133, using 16 shards per revision and merging each index. I paired entries by key and verified their source digests before comparing each SPIR-V file byte for byte.

Parent PR
Translated and passing spirv-val 26,503 26,503
Wave64 graphics tier A 5,059 5,059
Tier B 101 101
Tier C 8,245 8,245

0 tier changes and 0 changed SPIR-V binaries. There was one observable metadata difference: 271 tier-C pixel shaders gained unsafe-vote-branch in wave64_graphics_reasons. All their existing reason labels remained, and every other index field matched. The hand-written fixture's C-to-A promotion therefore has no retail counterpart in this corpus.

AI-assisted QA. Counts only.

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.

8 participants