shader: pin the lockstep rewrites with unit tests #485

Manually merged
github merged 1 commit from github-bot/gh-481 into main 2026-11-28 01:36:54 +00:00 AGit
Owner

@⁠AnastasisKon on GitHub · 2026-11-27 21:59 UTC · original
AnastasisKon:vibe/lockstep-rewrite-tests-4f9c68 → main · +106 −0 · 2 files · 1 commits · merged 2026-11-28 01:35 UTC

What this changes

Refs #482.

crates/victory-shader/src/emit/lockstep.rs rewrites a wave's instructions before DXIL is emitted, so the two host waves of a console wave arrive together: a mask branch becomes a 64-bit compare with zero plus an SCC branch of the same distance, and a group barrier goes around each LDS write. lockstep.rs had two end-to-end tests of the refusal path and nothing on the rewrites themselves, so a change there is invisible until a shader is refused or lowered wrongly.

emit/lockstep_tests.rs (declared under cfg(test), so the build hash is unchanged) pins the two pure passes on hand-assembled programs built through ir::build, the approach gfx_refusal_tests.rs already uses:

  • branches: s_cbranch_execz becoming s_cmp_eq_u64 over the EXEC pair plus s_cbranch_scc1, the compare writing SCC, the branch reading it, and the original distance and opcode kept; s_cbranch_execnz, s_cbranch_vccz and s_cbranch_vccnz picking the matching compare over EXEC or VCC; a branch already on SCC, and a branch that is not on a mask, left untouched.
  • lds_barriers: a group barrier before and after each LDS write, and none around reads.

No behaviour change, no new dependencies, no game data.

How it was tested

  • cargo test -p victory-shader: 406 passed, 0 failed, 3 ignored (the new module included).
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings: no warnings on this tree.
  • cargo xtask policy: 398 files ok.
  • Shader corpus sweep: not applicable — this changes no translation, only tests.
  • Ran the game: not needed (test-only).

Checklist

  • No game files, game code, disassembly listings or SDK files are included
  • Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added — the tests pin the rewrites as they are
  • New diagnostics are behind a VICTORY_* variable and documented: none added
**@⁠AnastasisKon** on GitHub · 2026-11-27 21:59 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/481) `AnastasisKon:vibe/lockstep-rewrite-tests-4f9c68` → `main` · +106 −0 · 2 files · 1 commits · merged 2026-11-28 01:35 UTC ## What this changes Refs #482. `crates/victory-shader/src/emit/lockstep.rs` rewrites a wave's instructions before DXIL is emitted, so the two host waves of a console wave arrive together: a mask branch becomes a 64-bit compare with zero plus an SCC branch of the same distance, and a group barrier goes around each LDS write. `lockstep.rs` had two end-to-end tests of the refusal path and nothing on the rewrites themselves, so a change there is invisible until a shader is refused or lowered wrongly. `emit/lockstep_tests.rs` (declared under `cfg(test)`, so the build hash is unchanged) pins the two pure passes on hand-assembled programs built through `ir::build`, the approach `gfx_refusal_tests.rs` already uses: - `branches`: `s_cbranch_execz` becoming `s_cmp_eq_u64` over the EXEC pair plus `s_cbranch_scc1`, the compare writing SCC, the branch reading it, and the original distance and opcode kept; `s_cbranch_execnz`, `s_cbranch_vccz` and `s_cbranch_vccnz` picking the matching compare over EXEC or VCC; a branch already on SCC, and a branch that is not on a mask, left untouched. - `lds_barriers`: a group barrier before and after each LDS write, and none around reads. No behaviour change, no new dependencies, no game data. ## How it was tested - [x] `cargo test -p victory-shader`: 406 passed, 0 failed, 3 ignored (the new module included). - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings`: no warnings on this tree. - [x] `cargo xtask policy`: 398 files ok. - [x] Shader corpus sweep: not applicable — this changes no translation, only tests. - [ ] Ran the game: not needed (test-only). ## Checklist - [x] No game files, game code, disassembly listings or SDK files are included - [x] Guesses about undocumented console behaviour are marked in the code and in docs/native-host.md: none added — the tests pin the rewrites as they are - [x] New diagnostics are behind a `VICTORY_*` variable and documented: none added
lockstep.rs had two tests of its end-to-end refusal path. Add
emit/lockstep_tests.rs (declared under cfg(test), so the build hash is
unchanged) pinning the pure rewrites on hand-assembled programs: branches()
turns s_cbranch_execz/execnz/vccz/vccnz into the matching 64-bit compare with
0 plus an SCC branch of the same distance and leaves an SCC branch alone;
lds_barriers() puts a group barrier before and after each LDS write and none
around reads.

Refs #478
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 21:59:42 +00:00
github manually merged commit 924bc08262 into main 2026-11-28 01:36:54 +00:00
Author
Owner

@⁠Olima34 on GitHub · 2026-11-28 01:35 UTC · original · approved these changes

Check report (helping the maintainer clear the queue):

  • CI: check and macos-scripts green on the current head.
  • Read: the whole diff (tests only, synthetic encodings). It pins the lockstep branch and LDS-barrier rewrites. No translator code changes, so a corpus sweep can't move.
  • Local check: current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). On it, the victory-gpu (arm64), victory-shader, victory-backend, victory-metal and victory tests pass, as do the macOS script tests (rustup-path.sh, run-summary-compare.sh, run-summary.sh --self-test), Windows clippy (-D warnings) and cargo xtask policy. One victory-gpu run in four failed main's own multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately. That test also flakes on main alone, so it isn't from this batch.
  • Not checked: no game run (the maintainer asked us to work on GitHub only).

Thanks @⁠AnastasisKon!

**@⁠Olima34** on GitHub · 2026-11-28 01:35 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/481#pullrequestreview-6094922891) · **approved these changes** Check report (helping the maintainer clear the queue): - **CI:** `check` and `macos-scripts` green on the current head. - **Read:** the whole diff (tests only, synthetic encodings). It pins the lockstep branch and LDS-barrier rewrites. No translator code changes, so a corpus sweep can't move. - **Local check:** current main (226645f9) merged with this PR and the other test/docs/tools PRs we're landing in this batch (#401 #403 #426 #471 #475 #479 #483 #485 #490 #493 #498 #502 #509 #515). On it, the `victory-gpu` (arm64), `victory-shader`, `victory-backend`, `victory-metal` and `victory` tests pass, as do the macOS script tests (`rustup-path.sh`, `run-summary-compare.sh`, `run-summary.sh --self-test`), Windows clippy (`-D warnings`) and `cargo xtask policy`. One `victory-gpu` run in four failed main's own `multi_mip_array_and_placed_depth_twins_preserve_all_subresources_and_remirror_immediately`. That test also flakes on main alone, so it isn't from this batch. - **Not checked:** no game run (the maintainer asked us to work on GitHub only). Thanks @⁠AnastasisKon!
This discussion has been locked. Commenting is limited to contributors.
No description provided.