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

Merged
Sandile-0511 merged 1 commit from upstream-pr/286 into main 2026-11-27 13:05:59 +00:00
Sandile-0511 commented 2026-11-27 08:45:57 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by Sandile-0511 on 2026-11-27T08:45:57Z.


What this changes

Refs #282

Puts the shader corpus sweep in the repository, without any shader data, as asked on #258 (https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/258#issuecomment-7213183271). 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)
<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:issue:5523767804 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/286). Originally posted by [Sandile-0511](https://github.com/Sandile-0511) on 2026-11-27T08:45:57Z. --- ## What this changes Refs #282 Puts the shader corpus sweep in the repository, without any shader data, as asked on #258 (https://github.com/LakshanSivakumar/Native-Victory-macOS/issues/258#issuecomment-7213183271). 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)
LakshanSivakumar commented 2026-11-27 10:32:30 +00:00 (Migrated from github.com)

Imported from LakshanSivakumar/Native-Victory-macOS. Originally posted by LakshanSivakumar on 2026-11-27T10:32:30Z.


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.

<!-- greyfinch-sync:LakshanSivakumar/Native-Victory-macOS:comment:7216008583 --> Imported from [LakshanSivakumar/Native-Victory-macOS](https://github.com/LakshanSivakumar/Native-Victory-macOS/pull/286#issuecomment-7216008583). Originally posted by [LakshanSivakumar](https://github.com/LakshanSivakumar) on 2026-11-27T10:32:30Z. --- 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.
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
LakshanSivakumar/Native-Victory-macOS!286
No description provided.