Shader tests: differential fuzzing against an RDNA2 interpreter ("oracle") #403

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

@⁠simbaui4life on GitHub · 2026-11-27 00:18 UTC · original
simbaui4life:test/rdna2-oracle → main · +1848 −0 · 2 files · 1 commits · open

A differential fuzzer for the shader translator, as tests. One commit on 014d52d; there is no change to the translator, and TRANSLATOR_VERSION is unchanged.

Why: the translator's tests check chosen cases. This one checks whole random programs against a model of the RDNA2 ISA that shares no code with the translator, on the GPU the translation runs on. It covers EXEC-narrowed branches, SCC, VCC and cross-lane reads and writes. It found the faults fixed in the s_min/s_max and lane-select PR (simbaui4life:fix/salu-minmax-scc-lane-masks) and the scalars-after-lane-branches PR (simbaui4life:fix/scalars-after-lane-branches), and four that are still open (below).

How it works (crates/victory-shader/src/emit/oracle_tests.rs, cfg(all(test, windows)))

  • Random compute programs: integer VALU and SALU, lane compares, lane-divergent if/else under EXEC, uniform ifs and loops on SCC, v_readlane/v_writelane/v_readfirstlane.
  • Encoded to GFX10 machine code. The encoder is checked against the decoder's instruction names, so a mismatch points at the translation, not the encoding.
  • Translated by the production path: spill::build, structure, resource::track, io::raise, emit_with_retries.
  • Run on emit::host and compared lane by lane with an interpreter that shares nothing with the translator (not the decoder, the IR or the lowering).
  • A program that differs is minimized and printed as a listing, with the lanes and values that differ.
  • Wave64 programs run on 32-lane host waves (TEST_HOST_WAVE), once with exact forms only (VICTORY_WAVE_LOCAL=idiom) and once as the default.

Running it

  • Default tests, which need no GPU: oracle_encoding_reads_back_as_the_instructions_meant, oracle_interpreter_follows_the_isa_on_known_cases.
  • The fuzzer is #[ignore]d:
    VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1
  • VICTORY_ORACLE_OUT=<file> writes the report. VICTORY_ORACLE_AVOID=salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data leaves out the known classes, so new ones stand out.
  • Without an SM 6.6 hardware device it skips.

Open findings on main (RTX 4070 Ti, so wave64 runs on two 32-lane host waves)

  • v_writelane_b32 to a lane EXEC leaves out: the console writes it, here it is not written.
  • Wave64: VCC read as data after a uniform branch has its high half 0.
  • VCC bits of inactive lanes after a v_cmp under narrowed EXEC: the console writes 0, here they keep what they had.
  • Wave64 v_readfirstlane_b32 is taken per 32-lane half (the shortcut documented in lower.rs). This one goes away with VICTORY_WAVE_WIDE=1.

Tested (RTX 4070 Ti, driver 621.01, Windows 11 26200)

  • This branch alone: cargo clippy -p victory-shader --all-targets -- -D warnings, the same with --all-features, and cargo test -p victory-shader (304 passed, 0 failed, the two default oracle tests included).

Not tested: AMD hardware. On an RDNA card wave64 runs natively, so the wave64 findings above may not show there.

No game data in the commits.

🤖 Generated with Claude Code

**@⁠simbaui4life** on GitHub · 2026-11-27 00:18 UTC · [original](https://github.com/avatarmanz/VIctory-7900XTX/pull/403) `simbaui4life:test/rdna2-oracle` → `main` · +1848 −0 · 2 files · 1 commits · open A differential fuzzer for the shader translator, as tests. One commit on `014d52d`; there is no change to the translator, and `TRANSLATOR_VERSION` is unchanged. **Why:** the translator's tests check chosen cases. This one checks whole random programs against a model of the RDNA2 ISA that shares no code with the translator, on the GPU the translation runs on. It covers EXEC-narrowed branches, SCC, VCC and cross-lane reads and writes. It found the faults fixed in the s_min/s_max and lane-select PR (`simbaui4life:fix/salu-minmax-scc-lane-masks`) and the scalars-after-lane-branches PR (`simbaui4life:fix/scalars-after-lane-branches`), and four that are still open (below). **How it works** (`crates/victory-shader/src/emit/oracle_tests.rs`, `cfg(all(test, windows))`) - Random compute programs: integer VALU and SALU, lane compares, lane-divergent if/else under EXEC, uniform ifs and loops on SCC, `v_readlane`/`v_writelane`/`v_readfirstlane`. - Encoded to GFX10 machine code. The encoder is checked against the decoder's instruction names, so a mismatch points at the translation, not the encoding. - Translated by the production path: `spill::build`, `structure`, `resource::track`, `io::raise`, `emit_with_retries`. - Run on `emit::host` and compared lane by lane with an interpreter that shares nothing with the translator (not the decoder, the IR or the lowering). - A program that differs is minimized and printed as a listing, with the lanes and values that differ. - Wave64 programs run on 32-lane host waves (`TEST_HOST_WAVE`), once with exact forms only (`VICTORY_WAVE_LOCAL=idiom`) and once as the default. **Running it** - Default tests, which need no GPU: `oracle_encoding_reads_back_as_the_instructions_meant`, `oracle_interpreter_follows_the_isa_on_known_cases`. - The fuzzer is `#[ignore]`d: `VICTORY_ORACLE_RUNS=200 VICTORY_ORACLE_SEED=1 cargo test -p victory-shader --lib oracle_fuzz -- --ignored --nocapture --test-threads=1` - `VICTORY_ORACLE_OUT=<file>` writes the report. `VICTORY_ORACLE_AVOID=salu_in_branch,minmax_scc,lane_range,writelane_inactive,mask_data` leaves out the known classes, so new ones stand out. - Without an SM 6.6 hardware device it skips. **Open findings on main** (RTX 4070 Ti, so wave64 runs on two 32-lane host waves) - `v_writelane_b32` to a lane EXEC leaves out: the console writes it, here it is not written. - Wave64: VCC read as data after a uniform branch has its high half 0. - VCC bits of inactive lanes after a `v_cmp` under narrowed EXEC: the console writes 0, here they keep what they had. - Wave64 `v_readfirstlane_b32` is taken per 32-lane half (the shortcut documented in `lower.rs`). This one goes away with `VICTORY_WAVE_WIDE=1`. **Tested** (RTX 4070 Ti, driver 621.01, Windows 11 26200) - This branch alone: `cargo clippy -p victory-shader --all-targets -- -D warnings`, the same with `--all-features`, and `cargo test -p victory-shader` (304 passed, 0 failed, the two default oracle tests included). **Not tested:** AMD hardware. On an RDNA card wave64 runs natively, so the wave64 findings above may not show there. No game data in the commits. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Random compute programs (integer VALU and SALU arithmetic, lane compares,
lane-divergent if/else under EXEC, uniform ifs and loops on SCC, cross-lane
reads and writes) are encoded to GFX10 machine code, translated by the
production path (spill::build, structure, resource::track, io::raise,
emit_with_retries), run on the host GPU and compared lane by lane with an
interpreter that shares nothing with the translator (not the decoder, the
IR or the lowering). The encoder is checked against the decoder's
instruction names, so a mismatch means the translation, not the encoding.
Failing programs are minimized and printed as a listing.

Wave64 runs on a host of 32-lane waves (TEST_HOST_WAVE), once with exact
translations only (VICTORY_WAVE_LOCAL=idiom) and once as the default.

Default tests: the encoder round trip and the interpreter on known cases
(no GPU needed). The fuzzer is #[ignore]d:
  cargo test -p victory-shader --lib oracle -- --ignored --nocapture --test-threads=1
with VICTORY_ORACLE_RUNS (200), VICTORY_ORACLE_SEED (1), VICTORY_ORACLE_OUT
(report file) and VICTORY_ORACLE_AVOID (leave out known bug classes).
Without an SM 6.6 hardware device it skips.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:56:41 +00:00
This pull request can be merged automatically.
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/403/head:github-bot/gh-403'
git switch 'github-bot/gh-403'

Merge

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