OLD-9919: wave64_halves: clear ('vote', 'exec', ...) on EXEC writes and propagate SCC uses taint (SHADER-820) #1468

Closed
Tortoche wants to merge 2 commits from upstream-pr/1468 into main
Tortoche commented 2026-11-25 00:50:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Tortoche on 2026-11-25T00:50:26Z.


Item ID: OLD-9919 (SHADER-820)
Carries forward Draft #187 (old-pr/9919 by Luiz Neves / LouisRiverstone, with original commit authorship preserved at ed9ea453e), rebased onto main (364ab4eab), plus follow-up soundness fix (2ab9758e0) for 3-tuple ("vote", "exec", "empty") clearing and uses SCC taint propagation in exec_write.
Claimed in #14: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147742087

AI-assisted: yes

Summary

  • tools/wave64_halves.py (Analysis.exec_write):
    • Clear both 2-tuple ("vote", "exec") and 3-tuple ("vote", "exec", "empty") tags on st["g"]["scc"] whenever EXEC is rewritten by an SCC-preserving instruction (v_cmpx, s_mov_b64, s_cselect_b64, s_cmov_b64, or any op without scc in defs) or on fallback EXEC writes.
    • Propagate taint and staleness from implicit uses (e.g., scc on s_cselect_b64 exec, ... / s_cmov_b64 exec, ...) into mt on the non-v_cmpx exec_write path.
  • runtime/test/shaders/ps_w64_c_vote_rewrite.asm, runtime/test/shaders/ps_w64_c_vote_exec.asm, runtime/test/shaders/w64_graphics.py, tests/test_wave64_halves_fixtures.py: add and register the two SHADER-820 GPU fixtures (Tier C, tainted-branch).
  • tests/semantic/test_wave64_halves_soundness.py: add VS soundness/divergence tests and pure-Python PS classification tests covering vote-on-EXEC reset, 3-tuple s_cmp_eq_u64 exec, 0 clearing (vs_exec_vote_cmp_eq_mov, vs_exec_vote_cmp_eq_cselect), s_cselect_b64 exec SCC taint/staleness (test_s_cselect_exec_reads_scc_taint), clean scalar-compare s_cselect_b64 exec invariant (vs_clean_cselect_exec), rewritten mask, and v_cmpx.
  • docs/design.md: document the EXEC vote reset rule in the SHADER-10 contract row.

Tests Executed (Linux x86_64 CPU, no GPU/retail corpus run)

  • python3 -I tests/semantic/test_wave64_halves_soundness.py -v: 37/37 passed
  • python3 -I tests/semantic/test_wave64_halves.py: 126/126 passed
  • python3 -I tests/semantic/test_wave64_halves_wqm_uvote.py: 18/18 passed
  • python3 -I tests/semantic/test_wave64_halves_partial_dst.py: 13/13 passed
  • python3 -I tests/semantic/test_wave64_halves_readlane_uniform.py: 2/2 passed
  • python3 -m pytest tests/test_wave64_halves_fixtures.py -v: 9 passed / 1 skipped (test_fixtures_are_classified_as_their_headers_say skipped due to llvm-mc absent on PATH)
  • python3 -I tests/test_design_contract_rows.py: 5/5 passed
  • python3 -I tests/test_docs_links.py: 16/16 passed
  • python3 -I tests/test_text_write_line_endings.py: 3/3 passed
  • python3 -m compileall -q make_game.py tools tests: OK (exit 0)
  • python3 -I scripts/check_no_game_data.py on all 7 modified/added files: OK (exit 0, zero game data)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5482961681 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1468). Originally posted by [Tortoche](https://github.com/Tortoche) on 2026-11-25T00:50:26Z. --- Item ID: `OLD-9919` (`SHADER-820`) Carries forward Draft `#187` (`old-pr/9919` by `Luiz Neves` / `LouisRiverstone`, with original commit authorship preserved at `ed9ea453e`), rebased onto `main` (`364ab4eab`), plus follow-up soundness fix (`2ab9758e0`) for 3-tuple `("vote", "exec", "empty")` clearing and `uses` SCC taint propagation in `exec_write`. Claimed in `#14`: https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7147742087 AI-assisted: yes ### Summary - `tools/wave64_halves.py` (`Analysis.exec_write`): - Clear both 2-tuple `("vote", "exec")` and 3-tuple `("vote", "exec", "empty")` tags on `st["g"]["scc"]` whenever `EXEC` is rewritten by an `SCC`-preserving instruction (`v_cmpx`, `s_mov_b64`, `s_cselect_b64`, `s_cmov_b64`, or any op without `scc` in `defs`) or on fallback `EXEC` writes. - Propagate taint and staleness from implicit `uses` (e.g., `scc` on `s_cselect_b64 exec, ...` / `s_cmov_b64 exec, ...`) into `mt` on the non-`v_cmpx` `exec_write` path. - `runtime/test/shaders/ps_w64_c_vote_rewrite.asm`, `runtime/test/shaders/ps_w64_c_vote_exec.asm`, `runtime/test/shaders/w64_graphics.py`, `tests/test_wave64_halves_fixtures.py`: add and register the two `SHADER-820` GPU fixtures (Tier `C`, `tainted-branch`). - `tests/semantic/test_wave64_halves_soundness.py`: add VS soundness/divergence tests and pure-Python PS classification tests covering vote-on-`EXEC` reset, 3-tuple `s_cmp_eq_u64 exec, 0` clearing (`vs_exec_vote_cmp_eq_mov`, `vs_exec_vote_cmp_eq_cselect`), `s_cselect_b64 exec` SCC taint/staleness (`test_s_cselect_exec_reads_scc_taint`), clean scalar-compare `s_cselect_b64 exec` invariant (`vs_clean_cselect_exec`), rewritten mask, and `v_cmpx`. - `docs/design.md`: document the `EXEC` vote reset rule in the `SHADER-10` contract row. ### Tests Executed (Linux x86_64 CPU, no GPU/retail corpus run) - `python3 -I tests/semantic/test_wave64_halves_soundness.py -v`: **37/37 passed** - `python3 -I tests/semantic/test_wave64_halves.py`: **126/126 passed** - `python3 -I tests/semantic/test_wave64_halves_wqm_uvote.py`: **18/18 passed** - `python3 -I tests/semantic/test_wave64_halves_partial_dst.py`: **13/13 passed** - `python3 -I tests/semantic/test_wave64_halves_readlane_uniform.py`: **2/2 passed** - `python3 -m pytest tests/test_wave64_halves_fixtures.py -v`: **9 passed / 1 skipped** (`test_fixtures_are_classified_as_their_headers_say` skipped due to `llvm-mc` absent on `PATH`) - `python3 -I tests/test_design_contract_rows.py`: **5/5 passed** - `python3 -I tests/test_docs_links.py`: **16/16 passed** - `python3 -I tests/test_text_write_line_endings.py`: **3/3 passed** - `python3 -m compileall -q make_game.py tools tests`: **OK** (exit 0) - `python3 -I scripts/check_no_game_data.py` on all 7 modified/added files: **OK** (exit 0, zero game data)
ecox982745 commented 2026-11-25 01:16:00 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-11-25T01:16:00Z.


I assembled the two new pixel fixtures and compared their identical input listings at the branch point 364ab4ea and PR head 2ab9758e. Strict mode now catches the EXEC vote that the baseline accepted.

Fixture Branch point PR head
ps_w64_c_vote_exec Tier A, accepted Tier C (tainted-branch), refused
ps_w64_c_vote_rewrite Tier C (tainted-branch), refused Same
ps_w64_a_skip control Tier A, accepted Same

CPU. I also tried two synthetic vertex shaders that select EXEC with s_cselect_b64 exec, 0, s[10:11] after an empty/nonempty VCC vote. In each case, 32 of 64 lane outputs differed between the interpreter's one 64-lane wave and two 32-lane waves. Both cases were labelled A at the branch point and C (tainted-exec) at the PR head. The soundness suite passed 37/37. The fixture suite passed 10/10 with LLVM available, including the previously skipped classification test.

GPU. On an RTX 4090 (Windows 11, NVIDIA 616.64), I rendered both pixel fixtures in default mode with the PR head's Vulkan harness and subgroup size 32. All four 64×64 frames were byte-identical across fixtures and revisions. The vote channel was 1 for 32 pixels and 0 for 4,064; the origin marker was set only at (0,0). This GPU supports only 32-wide subgroups, so the 64-lane comparison above is CPU evidence. AI-assisted verification; synthetic inputs throughout.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7149372881 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1468#issuecomment-7149372881). Originally posted by [ecox982745](https://github.com/ecox982745) on 2026-11-25T01:16:00Z. --- I assembled the two new pixel fixtures and compared their identical input listings at the branch point `364ab4ea` and PR head `2ab9758e`. Strict mode now catches the EXEC vote that the baseline accepted. | Fixture | Branch point | PR head | | --- | --- | --- | | `ps_w64_c_vote_exec` | Tier A, accepted | Tier C (`tainted-branch`), refused | | `ps_w64_c_vote_rewrite` | Tier C (`tainted-branch`), refused | Same | | `ps_w64_a_skip` control | Tier A, accepted | Same | **CPU.** I also tried two synthetic vertex shaders that select EXEC with `s_cselect_b64 exec, 0, s[10:11]` after an empty/nonempty VCC vote. In each case, 32 of 64 lane outputs differed between the interpreter's one 64-lane wave and two 32-lane waves. Both cases were labelled A at the branch point and C (`tainted-exec`) at the PR head. The soundness suite passed 37/37. The fixture suite passed 10/10 with LLVM available, including the previously skipped classification test. **GPU.** On an RTX 4090 (Windows 11, NVIDIA 616.64), I rendered both pixel fixtures in default mode with the PR head's Vulkan harness and subgroup size 32. All four 64×64 frames were byte-identical across fixtures and revisions. The vote channel was 1 for 32 pixels and 0 for 4,064; the origin marker was set only at (0,0). This GPU supports only 32-wide subgroups, so the 64-lane comparison above is CPU evidence. AI-assisted verification; synthetic inputs throughout.
potatoe0100 commented 2026-11-25 10:12:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by potatoe0100 on 2026-11-25T10:12:53Z.


Tested head 284cbfacf on NVIDIA GeForce RTX 4060 (Ada, subgroup 32 only), driver 621.14, Windows 11 Pro 26300, VS 2022, Vulkan SDK 1.4.363.0. It merges cleanly onto main 57ba40bd6 despite the needs rebase label; results are from that merge.

  • pytest: test_wave64_halves_soundness.py 37 passed, test_wave64_halves_fixtures.py 10 passed.
  • build.py on the 34 wave64 graphics fixtures: 34 translated, 34 pass spirv-val; tier C count 12 -> 14 (the two new fixtures).
  • w64_graphics.py: 18 ok, 14 tier C SKIP, 0 failed. ps_w64_c_vote_exec and ps_w64_c_vote_rewrite SKIP as expected on a 32-only device, so this run doesn't confirm their tier C outputs; that needs a device that can require 64 (or W64G_REF).

No game files. AI-assisted (Claude Code), run for a non-developer tester.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7159387653 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/1468#issuecomment-7159387653). Originally posted by [potatoe0100](https://github.com/potatoe0100) on 2026-11-25T10:12:53Z. --- Tested head `284cbfacf` on NVIDIA GeForce RTX 4060 (Ada, subgroup 32 only), driver 621.14, Windows 11 Pro 26300, VS 2022, Vulkan SDK 1.4.363.0. It merges cleanly onto `main` `57ba40bd6` despite the `needs rebase` label; results are from that merge. - pytest: `test_wave64_halves_soundness.py` 37 passed, `test_wave64_halves_fixtures.py` 10 passed. - `build.py` on the 34 wave64 graphics fixtures: 34 translated, 34 pass spirv-val; tier C count 12 -> 14 (the two new fixtures). - `w64_graphics.py`: 18 ok, 14 tier C SKIP, 0 failed. `ps_w64_c_vote_exec` and `ps_w64_c_vote_rewrite` SKIP as expected on a 32-only device, so this run doesn't confirm their tier C outputs; that needs a device that can require 64 (or `W64G_REF`). No game files. AI-assisted (Claude Code), run for a non-developer tester.
MoonEyes commented 2026-11-28 02:59:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T02:59:31Z.


Hi @Tortoche, thanks for this pull request. It currently conflicts with main (conflicting file(s): docs/design.md), so it carries the needs rebase label. CONTRIBUTING.md asks authors to rebase their branch on main; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7232722971 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1468#issuecomment-7232722971). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T02:59:31Z. --- Hi @Tortoche, thanks for this pull request. It currently conflicts with `main` (conflicting file(s): `docs/design.md`), so it carries the `needs rebase` label. CONTRIBUTING.md asks authors to rebase their branch on `main`; once it merges cleanly the label goes within the hour, and reviews start with the pull requests that do. Could you update the branch when you have a moment? If you no longer plan to continue with it, please say so here. AI-assisted (Claude Code, Claude Opus 5.5).
enlight3d commented 2026-11-29 12:34:18 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T12:34:18Z.


Run of #1468 on Windows (NVIDIA RTX 3090 box). This PR has no ctest test: its tests are Python (translator soundness checks plus two GPU pixel fixtures), so no GPU test ran. Synthetic inputs only, no game files.

Heads: PR 284cbfacf, main 8fb974878.
Merged or head-only: head-only. git merge --no-ff of the PR into main conflicts in docs/design.md and tools/wave64_halves.py, so everything below ran on the PR head itself (detached at 284cbfacf, merge base 604ddff0b).

Commands (from the repo root, Python 3.13):

git checkout --detach pr-1468
python -I tests/semantic/test_wave64_halves_soundness.py
python -I tests/semantic/test_wave64_halves.py
python -I tests/semantic/test_wave64_halves_wqm_uvote.py
python -I tests/semantic/test_wave64_halves_partial_dst.py
python -I tests/semantic/test_wave64_halves_readlane_uniform.py
python -I tests/test_design_contract_rows.py

Green: all six OK (37, 127, 18, 13, 2 and 5 tests).

Red (behavioural): tools/wave64_halves.py and docs/design.md reverted to the merge base, tests and fixtures kept:

  • test_wave64_halves_soundness.py: 9 failures in 3 tests (test_vote_on_exec_then_a_new_exec_is_unsafe, test_s_cselect_exec_reads_scc_taint, test_ps_vote_exec_rewrite_and_vcmpx_are_tainted_branch)
  • test_wave64_halves.py: 1 failure, test_ps_w64_fixtures for ps_w64_c_vote_exec
  • The other four files stay OK (they do not measure this change).
    All six pass again with the PR restored.

Not run here: tests/test_wave64_halves_fixtures.py (needs pytest and llvm-mc with the AMDGPU target, neither is installed on this machine) and the two new GPU fixtures on hardware (the PR describes them as run elsewhere; a 3090 would only exercise subgroup size 32).

Link: not applicable. The PR changes no file under runtime/ except test inputs, so gta6rt.exe was not rebuilt or compared.

Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, RelWithDebInfo, Ninja, Vulkan SDK 1.4.363.1.

The branch conflicts with main in the two files above; could you merge main into it so it can be tested merged?

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7255908136 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1468#issuecomment-7255908136). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T12:34:18Z. --- Run of #1468 on Windows (NVIDIA RTX 3090 box). This PR has no ctest test: its tests are Python (translator soundness checks plus two GPU pixel fixtures), so no GPU test ran. Synthetic inputs only, no game files. Heads: PR `284cbfacf`, main `8fb974878`. Merged or head-only: **head-only**. `git merge --no-ff` of the PR into main conflicts in `docs/design.md` and `tools/wave64_halves.py`, so everything below ran on the PR head itself (detached at `284cbfacf`, merge base `604ddff0b`). Commands (from the repo root, Python 3.13): ``` git checkout --detach pr-1468 python -I tests/semantic/test_wave64_halves_soundness.py python -I tests/semantic/test_wave64_halves.py python -I tests/semantic/test_wave64_halves_wqm_uvote.py python -I tests/semantic/test_wave64_halves_partial_dst.py python -I tests/semantic/test_wave64_halves_readlane_uniform.py python -I tests/test_design_contract_rows.py ``` Green: all six OK (37, 127, 18, 13, 2 and 5 tests). Red (behavioural): `tools/wave64_halves.py` and `docs/design.md` reverted to the merge base, tests and fixtures kept: - `test_wave64_halves_soundness.py`: 9 failures in 3 tests (`test_vote_on_exec_then_a_new_exec_is_unsafe`, `test_s_cselect_exec_reads_scc_taint`, `test_ps_vote_exec_rewrite_and_vcmpx_are_tainted_branch`) - `test_wave64_halves.py`: 1 failure, `test_ps_w64_fixtures` for `ps_w64_c_vote_exec` - The other four files stay OK (they do not measure this change). All six pass again with the PR restored. Not run here: `tests/test_wave64_halves_fixtures.py` (needs pytest and `llvm-mc` with the AMDGPU target, neither is installed on this machine) and the two new GPU fixtures on hardware (the PR describes them as run elsewhere; a 3090 would only exercise subgroup size 32). Link: not applicable. The PR changes no file under `runtime/` except test inputs, so gta6rt.exe was not rebuilt or compared. Machine: RTX 3090 24 GB, NVIDIA 621.40, Windows 11 Pro 10.0.26300, MSVC 19.44, RelWithDebInfo, Ninja, Vulkan SDK 1.4.363.1. The branch conflicts with main in the two files above; could you merge main into it so it can be tested merged?
aslan2142 commented 2026-12-01 11:54:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T11:54:14Z.

Review: CHANGES_REQUESTED


Reviewed against current main: clearing ('vote', 'exec', ...) on EXEC writes and propagating SCC taint in tools/wave64_halves.py looks well-tested, but this branch conflicts with main and has failing CI. Please rebase onto current main so CI runs cleanly.

(AI-assisted review.)

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6130734349 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1468#pullrequestreview-6130734349). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T11:54:14Z. **Review:** CHANGES_REQUESTED --- Reviewed against current `main`: clearing `('vote', 'exec', ...)` on EXEC writes and propagating SCC taint in `tools/wave64_halves.py` looks well-tested, but this branch conflicts with `main` and has failing CI. Please rebase onto current `main` so CI runs cleanly. *(AI-assisted review.)*
aslan2142 commented 2026-12-01 16:36:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-12-01T16:36:10Z.


Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (d3d12/) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, d3d12/, or general docs), please feel free to reopen it.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7317878180 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/1468#issuecomment-7317878180). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-12-01T16:36:10Z. --- Closing this PR because the legacy C++ Vulkan runtime (and legacy Python shader compiler) is now considered deprecated in favor of the new Rust Vulkan runtime (in progress) and the Rust DX12 runtime (`d3d12/`) available now. Thank you for the contribution! If you believe this PR was closed by mistake (for example, if it still applies to active tools, `d3d12/`, or general docs), please feel free to reopen it.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
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!1468
No description provided.