shader: retranslate example checks translations against a session's #504

Open
github-bot wants to merge 1 commit from github-bot/gh-504 into main AGit
Owner

@⁠Benflex1 on GitHub · 2026-12-04 19:47 UTC · original
Benflex1:retranslate-example → main · +539 −0 · 4 files · 1 commits · open

Problem

Checking what a translator change does to the shaders the game actually uses currently means running the game, or reading a whole-archive tally. There's no quick offline way to answer two questions: which of a session's shaders would now translate differently, and did translation get slower?

translate_file looks at one container at a time, and isa_probe makes pipelines for driver dumps. Neither compares output.

Change

A new example, retranslate, in victory-shader:

  • Inputs: the containers a session saved with VICTORY_SHADER_SAVE=<dir>. That writes <hash>.<stage>.cdxil plus the session's own <hash>.<stage>.dxil beside it.
  • Setup: the translator is set up as host.rs / descriptor/host.rs set it up:
    • an RDNA host with waves of 32 and 64 (--generic turns this off);
    • the full view heap, with view records and their integer twins;
    • the card's node test with --card-tests.
    • VICTORY_* translator switches apply as in the game.
  • Comparison: each translation is compared byte for byte with the session's .dxil, or with an earlier run's --out via --ref.
  • Timing: each translation is timed. --repeat N reports the fastest of N and flags any translation that isn't the same every time.
  • Output and exit status: only what differs, fails or is unstable is listed (--list lists everything), then a summary. The exit status is 1 if anything differs, fails or is unstable, so it can gate a script.
  • Output location: --out is refused inside the source tree (victory_core::ensure_outside_repo, rule #1).

Other changes:

  • docs/DIAGNOSTICS.md gets a short section, which also documents VICTORY_SHADER_SAVE.
  • victory-shader gains tempfile and victory-core as dev-dependencies only.
  • The example has test = true, so its tests run with cargo test -p victory-shader.

There is no change to the translator or the runtime, and nothing game-derived is included.

Verified

  • Unit tests: 9 tests pass on Linux, and in the x86_64-pc-windows-msvc build (built with --locked, run under Wine). They cover:
    • option parsing;
    • directory discovery;
    • comparison against the sibling and --ref references;
    • writing output;
    • instability across repeats;
    • the summary and exit status;
    • a real emit::translate failure on bytes that aren't a container;
    • refusing output inside a source tree.
  • Formatting and lints: rustfmt and clippy are clean for the new file, and cargo xtask policy --staged passes.
  • Exactness on real data: I ran it on the 4,402 containers one session saved, using a build of the same translator that session ran, with the session's switches. All 4,402 came out byte-identical to the session's .dxil, with 0 failures. So the offline setup matches the runtime's.
  • Current main: on a sample of 293 of those containers, built from current main with --repeat 2, there were 0 failures and 0 unstable translations. The ones that differ are expected, since that session ran a different translator build.
**@⁠Benflex1** on GitHub · 2026-12-04 19:47 UTC · [original](https://github.com/lobomfz/VIctory-xmem/pull/504) `Benflex1:retranslate-example` → `main` · +539 −0 · 4 files · 1 commits · open ## Problem Checking what a translator change does to the shaders the game actually uses currently means running the game, or reading a whole-archive tally. There's no quick offline way to answer two questions: which of a session's shaders would now translate differently, and did translation get slower? `translate_file` looks at one container at a time, and `isa_probe` makes pipelines for driver dumps. Neither compares output. ## Change A new example, `retranslate`, in `victory-shader`: - **Inputs:** the containers a session saved with `VICTORY_SHADER_SAVE=<dir>`. That writes `<hash>.<stage>.cdxil` plus the session's own `<hash>.<stage>.dxil` beside it. - **Setup:** the translator is set up as `host.rs` / `descriptor/host.rs` set it up: - an RDNA host with waves of 32 and 64 (`--generic` turns this off); - the full view heap, with view records and their integer twins; - the card's node test with `--card-tests`. - `VICTORY_*` translator switches apply as in the game. - **Comparison:** each translation is compared byte for byte with the session's `.dxil`, or with an earlier run's `--out` via `--ref`. - **Timing:** each translation is timed. `--repeat N` reports the fastest of N and flags any translation that isn't the same every time. - **Output and exit status:** only what differs, fails or is unstable is listed (`--list` lists everything), then a summary. The exit status is 1 if anything differs, fails or is unstable, so it can gate a script. - **Output location:** `--out` is refused inside the source tree (`victory_core::ensure_outside_repo`, rule #1). Other changes: - `docs/DIAGNOSTICS.md` gets a short section, which also documents `VICTORY_SHADER_SAVE`. - `victory-shader` gains `tempfile` and `victory-core` as dev-dependencies only. - The example has `test = true`, so its tests run with `cargo test -p victory-shader`. There is no change to the translator or the runtime, and nothing game-derived is included. ## Verified - **Unit tests:** 9 tests pass on Linux, and in the `x86_64-pc-windows-msvc` build (built with `--locked`, run under Wine). They cover: - option parsing; - directory discovery; - comparison against the sibling and `--ref` references; - writing output; - instability across repeats; - the summary and exit status; - a real `emit::translate` failure on bytes that aren't a container; - refusing output inside a source tree. - **Formatting and lints:** rustfmt and clippy are clean for the new file, and `cargo xtask policy --staged` passes. - **Exactness on real data:** I ran it on the 4,402 containers one session saved, using a build of the same translator that session ran, with the session's switches. All **4,402 came out byte-identical** to the session's `.dxil`, with 0 failures. So the offline setup matches the runtime's. - **Current main:** on a sample of 293 of those containers, built from current main with `--repeat 2`, there were 0 failures and 0 unstable translations. The ones that differ are expected, since that session ran a different translator build.
Translates the containers a session saved with VICTORY_SHADER_SAVE, with
the translator set up as the session sets it up (RDNA host, full view
heap, view records and their integer twins, the card's node test when
asked), and compares each translation byte for byte with the one the
session saved beside it, or with an earlier run's output (--ref). It
times each translation (--repeat N: the fastest, and a translation that
is not the same every time is flagged), lists what differs or fails,
and exits 1 when anything does. Output is refused inside the source tree
(rule #1).

Documents VICTORY_SHADER_SAVE and the example in docs/DIAGNOSTICS.md.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-04 19:49:09 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/504/head:github-bot/gh-504'
git switch 'github-bot/gh-504'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-504'
git switch 'github-bot/gh-504'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-504'
git switch 'github-bot/gh-504'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-504'
git switch 'main'
git merge --squash 'github-bot/gh-504'
git switch 'main'
git merge --ff-only 'github-bot/gh-504'
git switch 'main'
git merge 'github-bot/gh-504'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.