feat(tools): add the shader corpus sweep and its comparison #286

Manually merged
github merged 1 commit from github-bot/gh-286 into main 2026-11-27 13:08:27 +00:00 AGit
Owner

@⁠Sandile-0511 on GitHub · 2026-11-27 08:45 UTC · original
Sandile-0511:tools/corpus-sweep → main · +590 −1 · 6 files · 1 commits · merged 2026-11-27 13:05 UTC

What this changes

Refs #282

Puts the shader corpus sweep in the repository, without any shader data, as asked on #258 (#258). Anyone with a dump of their own can now check a translator change against every shader the title registers, and see what it does by output and not only by counts.

  • crates/victory-shader/examples/sweep.rs translates every <stage>_<hash>.bin container of a folder with the native host's options (wave32_host, zero_copy_memory) and prints one line per shader: ok, refused, panic, timeout or missing, then the output fingerprint or the reason, then the milliseconds. It has worker threads (-j), a list of files (--list), a time limit per shader (--timeout, 120 s by default: the stuck worker is left running and another takes its place) and --show for the host-side description in place of the fingerprint. It is an example of the crate so that it is always built with the translator of the tree it sits in.
  • tools/corpus/compare.sh tallies one sweep (outcomes per stage, refusal reasons by count) or compares two: newly translated, regressions, output changed, other reason now. --world FILE adds how many of each are among the shaders a reference run bound. It is bash and awk like run-summary.sh, with a --self-test on made-up sweeps that CI's macos-scripts job now runs.
  • Docs: "Sweeping a shader corpus" in docs/native-host.md (dump your own corpus with VICTORY_DUMP_ALL_SHADERS=1 VICTORY_DUMP_REFUSED=<folder>, sweep two builds, compare, what the fingerprint is, what a sweep does not cover, and that the corpus and the sweep files stay outside the repository), and a short section in AGENTS.md.

The fingerprint is the one behind the numbers already posted on #258: std's DefaultHasher over the DXIL, then over the Debug text of the rest of the HostShader. A test pins it.

Things to know before reviewing:

  • The comparison is a shell script, not the Python I used locally, because cargo xtask policy allows no .py file without an exception. Its output is the same byte for byte on the sweeps I had (see below).
  • crates/victory-shader/Cargo.toml gains an [[example]] entry with test = true, so cargo test -p victory-shader and CI's cargo test --workspace run the sweep's tests. The manifest is part of SOURCE_HASH, so the on-disk translation cache is made again once, as after any change to the crate's sources.
  • No translator or host code changes, no new diagnostic, no shader data. The tests use a four-word pixel program written for them and made-up sweep files.
  • A sweep does not cover the host's other translations of a container (thread_counts, rectangle lists, extra_params) or anything after translation. The docs say so.
  • Fingerprints compare only between builds of one toolchain with the same HostShader fields. A change that adds a field changes every fingerprint. The docs say so too.

How it was tested

  • cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory: not run, the change touches none of these crates
  • cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings
  • Ran the game: not needed

Also:

  • cargo test -p victory-shader: the 330 library tests and the 5 new sweep tests pass (one line per container, in name order, the same again on a second sweep; --show; the fingerprint covers the DXIL and the host description, and its definition is pinned; a panic is a line; a translation past the limit is given up on and the sweep goes on). These ran on macOS only: CI's Windows job is their first run there.
  • cargo xtask policy: 372 files ok. cargo test -p xtask passes.
  • /bin/bash tools/corpus/compare.sh --self-test: ok with bash 3.2 and macOS's awk. Not run with gawk or mawk.
  • Against the numbers on #258: the example, built in a worktree at 2a3b03d, swept my 21,608 shaders at -j 4 in 2 min 14 s. 17,479 translate and 4,129 are refused, and every line's outcome, fingerprint and reason is identical to the baseline sweep those numbers came from.
  • compare.sh against the Python script it replaces: identical output on 16 invocations over real sweeps (the tally with and without a world list, eleven pairs of sweeps, --show 0 and --show 3, --names).

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 made)
  • New diagnostics are behind a VICTORY_* variable and documented (none added)
**@⁠Sandile-0511** on GitHub · 2026-11-27 08:45 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/286) `Sandile-0511:tools/corpus-sweep` → `main` · +590 −1 · 6 files · 1 commits · merged 2026-11-27 13:05 UTC ## What this changes Refs #282 Puts the shader corpus sweep in the repository, without any shader data, as asked on #258 (https://git.gtahub.st/github/LakshanSivakumar--Native-Victory-macOS/issues/258). Anyone with a dump of their own can now check a translator change against every shader the title registers, and see what it does by output and not only by counts. - `crates/victory-shader/examples/sweep.rs` translates every `<stage>_<hash>.bin` container of a folder with the native host's options (`wave32_host`, `zero_copy_memory`) and prints one line per shader: `ok`, `refused`, `panic`, `timeout` or `missing`, then the output fingerprint or the reason, then the milliseconds. It has worker threads (`-j`), a list of files (`--list`), a time limit per shader (`--timeout`, 120 s by default: the stuck worker is left running and another takes its place) and `--show` for the host-side description in place of the fingerprint. It is an example of the crate so that it is always built with the translator of the tree it sits in. - `tools/corpus/compare.sh` tallies one sweep (outcomes per stage, refusal reasons by count) or compares two: newly translated, regressions, output changed, other reason now. `--world FILE` adds how many of each are among the shaders a reference run bound. It is bash and awk like `run-summary.sh`, with a `--self-test` on made-up sweeps that CI's `macos-scripts` job now runs. - Docs: "Sweeping a shader corpus" in `docs/native-host.md` (dump your own corpus with `VICTORY_DUMP_ALL_SHADERS=1 VICTORY_DUMP_REFUSED=<folder>`, sweep two builds, compare, what the fingerprint is, what a sweep does not cover, and that the corpus and the sweep files stay outside the repository), and a short section in `AGENTS.md`. The fingerprint is the one behind the numbers already posted on #258: std's `DefaultHasher` over the DXIL, then over the `Debug` text of the rest of the `HostShader`. A test pins it. Things to know before reviewing: - The comparison is a shell script, not the Python I used locally, because `cargo xtask policy` allows no `.py` file without an exception. Its output is the same byte for byte on the sweeps I had (see below). - `crates/victory-shader/Cargo.toml` gains an `[[example]]` entry with `test = true`, so `cargo test -p victory-shader` and CI's `cargo test --workspace` run the sweep's tests. The manifest is part of `SOURCE_HASH`, so the on-disk translation cache is made again once, as after any change to the crate's sources. - No translator or host code changes, no new diagnostic, no shader data. The tests use a four-word pixel program written for them and made-up sweep files. - A sweep does not cover the host's other translations of a container (`thread_counts`, rectangle lists, `extra_params`) or anything after translation. The docs say so. - Fingerprints compare only between builds of one toolchain with the same `HostShader` fields. A change that adds a field changes every fingerprint. The docs say so too. ## How it was tested - [ ] `cargo test --target x86_64-apple-darwin -p victory-hle -p victory-loader -p victory`: not run, the change touches none of these crates - [x] `cargo clippy --workspace --all-targets --locked --target x86_64-pc-windows-gnullvm -- -D warnings` - [x] Ran the game: not needed Also: - `cargo test -p victory-shader`: the 330 library tests and the 5 new sweep tests pass (one line per container, in name order, the same again on a second sweep; `--show`; the fingerprint covers the DXIL and the host description, and its definition is pinned; a panic is a line; a translation past the limit is given up on and the sweep goes on). These ran on macOS only: CI's Windows job is their first run there. - `cargo xtask policy`: 372 files ok. `cargo test -p xtask` passes. - `/bin/bash tools/corpus/compare.sh --self-test`: ok with bash 3.2 and macOS's awk. Not run with gawk or mawk. - Against the numbers on #258: the example, built in a worktree at `2a3b03d`, swept my 21,608 shaders at `-j 4` in 2 min 14 s. 17,479 translate and 4,129 are refused, and every line's outcome, fingerprint and reason is identical to the baseline sweep those numbers came from. - `compare.sh` against the Python script it replaces: identical output on 16 invocations over real sweeps (the tally with and without a world list, eleven pairs of sweeps, `--show 0` and `--show 3`, `--names`). ## 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 made) - [x] New diagnostics are behind a `VICTORY_*` variable and documented (none added)
The sweep is an example of victory-shader, so it is built with the
translator of the tree it sits in: it translates every dumped container
of a folder with the native host's options and prints the outcome and an
output fingerprint (or the refusal reason) per shader.
tools/corpus/compare.sh tallies one sweep or compares two: newly
translated, regressions, output changed, other reason now. No shader
data: the tests use a program written for them and made-up sweep files.

Refs #282
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 08:47:30 +00:00
Author
Owner

@⁠LakshanSivakumar on GitHub · 2026-11-27 10:32 UTC · original

Thank you. This is the sweep I asked for, with no shader data in it, and the docs say that the corpus and the sweep files never go into the repository. It is a draft, so I will read it again when you mark it ready.

Two questions. Does the shell comparison give the same counts as the numbers you posted in #258 on the sweeps you had (the text says byte for byte; please say it was checked on the real ones)? And the change to ci.yml is one line; I will look at it myself. I have not run it.

**@⁠LakshanSivakumar** on GitHub · 2026-11-27 10:32 UTC · [original](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/286#issuecomment-7216008583) Thank you. This is the sweep I asked for, with no shader data in it, and the docs say that the corpus and the sweep files never go into the repository. It is a draft, so I will read it again when you mark it ready. Two questions. Does the shell comparison give the same counts as the numbers you posted in #258 on the sweeps you had (the text says byte for byte; please say it was checked on the real ones)? And the change to `ci.yml` is one line; I will look at it myself. I have not run it.
github manually merged commit 1034c39b20 into main 2026-11-27 13:08:27 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.