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

Open
simbaui4life wants to merge 1 commit from upstream-pr/403 into main
simbaui4life commented 2026-11-27 00:18:11 +00:00 (Migrated from github.com)

Imported from avatarmanz/VIctory-7900XTX. Originally posted by simbaui4life on 2026-11-27T00:18:11Z.


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

<!-- greyfinch-sync:avatarmanz/VIctory-7900XTX:issue:5519009753 --> Imported from [avatarmanz/VIctory-7900XTX](https://github.com/avatarmanz/VIctory-7900XTX/pull/403). Originally posted by [simbaui4life](https://github.com/simbaui4life) on 2026-11-27T00:18:11Z. --- 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)
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/403:upstream-pr/403'
git switch 'upstream-pr/403'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/403'
git switch 'upstream-pr/403'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/403'
git switch 'upstream-pr/403'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/403'
git switch 'main'
git merge --squash 'upstream-pr/403'
git switch 'main'
git merge --ff-only 'upstream-pr/403'
git switch 'main'
git merge 'upstream-pr/403'
git push origin 'main'
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
avatarmanz/VIctory-7900XTX!403
No description provided.