Skip to content

Shader tests: VICTORY_ADAPTER picks the GPU the hardware checks run on - #1889

Open
alexdeliu wants to merge 2 commits into
Marvisak:mainfrom
alexdeliu:feat/test-adapter
Open

alexdeliu wants to merge 2 commits into
Marvisak:mainfrom
alexdeliu:feat/test-adapter

Conversation

@alexdeliu

Copy link
Copy Markdown

Host::new always takes the default adapter. On a machine with two GPUs (common: an iGPU beside a graphics card, or a laptop's Intel and NVIDIA), the hardware checks in victory-shader's tests can only run on one of them, and testers post results for half their hardware.

With VICTORY_ADAPTER=<n>, Host::new uses DXGI's nth adapter (0 is the default). The first host of a run names the device on stderr. A wrong index says so once and the hardware checks skip, as they do on a machine without a device. When the variable is unset nothing changes. The README's test section gets two lines about it.

Tested on one machine with an AMD RX 9070 (RDNA4, adapter 0) and the Ryzen 7700's iGPU (gfx1036, RDNA2, adapter 1), on main @ 70564ae:

  • both CI clippy runs are clean;
  • cargo test -p victory-shader --locked --lib gives the same result on both adapters: 208 passed, plus the 2 PSV0 tests that fail on main with the Windows SDK's dxil.dll 1.7. Those fail without this change too;
  • VICTORY_ADAPTER=1 … -- --nocapture prints VICTORY_ADAPTER=1: AMD Radeon(TM) Graphics, and VICTORY_ADAPTER=7 prints no such adapter;
  • a new unit test, adapter_index_reads_a_number_or_nothing, covers parsing the variable.

This makes RDNA2 and RDNA4 runs of the same commit from one machine routine, for example for #1599 (AMD's i64 compares, which reproduce on both).

AI-assisted (Claude Code).

🤖 Generated with Claude Code

Host::new always took the default adapter, so a machine with a second
GPU (an iGPU beside a graphics card, say) could not run the GPU checks
on it. VICTORY_ADAPTER=<n> picks DXGI's nth adapter; the first host of
a run names it on stderr, or says the index has no adapter, since the
tests then skip as they do without a device.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aycow

aycow commented Nov 25, 2026

Copy link
Copy Markdown

@fiestorra Upstream CI at ccfb029 passed. I separately selected each adapter in a local selector-only overlay. Both hardware paths executed on AMD Radeon Graphics and RTX 5070 Laptop GPU. WARP still runs the gather oracle, and its fixed Wave32 pipeline is refused as expected.

Explicit NVIDIA selection exposed a separate reproducible issue on driver 581.91. gathers_at_a_level_match_the_hardware at synthetic_tests.rs:261 returns [0.0, 1.0, 0.0, 0.0] for lane 0 (NaN U) where the CPU oracle expects zeros. Two runs on ccfb029 and one on 42363ab with only the DXGI ordinal changed gave the same result. The NVIDIA permute test passes. The old Windows runner failure was at a different assertion and lane. Sharing here because explicit selection already has coverage in this PR.

The AMD iGPU reports 512 MiB dedicated. NVIDIA reports 7.62 GiB and WARP reports zero. A non-software adapter that reports zero dedicated memory would still be excluded by the default filter, and I did not have one to verify. No assertions were changed.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

Merge candidate. Host::new in crates/victory-shader/src/emit/host.rs, the D3D12 host the shader tests' GPU checks use, gains VICTORY_ADAPTER=<n>. When set, it takes DXGI's adapter n in place of main's hardware_adapter choice and prints the adapter's name, or "no such adapter", once per run. When unset or empty, behaviour is exactly main's. adapter_index is unit-tested, and the README gains three short lines. This is useful for machines with two GPUs: a tester has already used it to reach a separate NVIDIA gather result. One thing to know: an explicit index bypasses the software-adapter refusal, which is acceptable for an opt-in setting.

Thanks for merging main: the conflict with hardware_adapter is resolved, and both behaviours are kept.

CI: passing (check).


Generated by Claude Code

@Headache3318

Copy link
Copy Markdown

Tested on Linux (Arch, kernel 7.3.5, 3× RTX 4090 driver 620.73.04), Rust 1.98.1 (pinned). PR head 13afa69 applied cleanly onto current main ccfb029.

  • cargo test -p victory-shader --locked: 118 passed, 0 failed, 1 ignored. All tests pass, including the new adapter_index_reads_a_number_or_nothing test.
  • cargo clippy -p victory-shader --all-targets -- -D warnings: 3 pre-existing errors in test code (fail identically on main ccfb029). The PR introduces no new clippy warnings.

Not tested: Windows MSVC build, the title itself. AI-assisted.

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict with current main (940d32f) — test-infra PR (VICTORY_ADAPTER GPU selection for hardware checks) needs a rebase. Will re-test after.

# Conflicts:
#	crates/victory-shader/src/emit/host.rs
@alexdeliu

Copy link
Copy Markdown
Author

@catminou4 merged main (940d32f) in as 113f280; no force-push. The conflict was with #1911/#1925's hardware_adapter in host.rs. Both behaviours are kept: with no VICTORY_ADAPTER, the first adapter that is not software and has dedicated memory is used, exactly as on main. VICTORY_ADAPTER=<n> takes DXGI's adapter n instead, and the first host of a run names it.

Rechecked on the RX 9070 + gfx1036 machine:

  • both CI clippy runs are clean;
  • cargo test -p victory-shader --locked --lib gives 246 passed both by default and with VICTORY_ADAPTER=1 (AMD Radeon(TM) Graphics), plus the 2 PSV0 tests main itself fails with the SDK's dxil.dll 1.7;
  • VICTORY_ADAPTER=7 prints no such adapter.

github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 25, 2026
@sinan-cmyk

Copy link
Copy Markdown

Offline measurement on a retail dump

Result: no count change against main.

I merged head 113f280 onto main 940d32f (clean merge) and ran victory translate --validate --list on shaders.rpf (1.0.2.1), with dxil.dll 1.8.2502.11. I compared the result with main program by program (25,889 programs). Validated: 23,918 on main, 23,918 with this PR.

No program changes its failure reason. The count shows that the change rejects nothing on this data. It does not show whether the output is right.

No shader names or data are included, per the asset policy. AI-assisted (Claude Code).

@KainanP

KainanP commented Nov 25, 2026

Copy link
Copy Markdown

Tested head 113f280 (identical to a merge onto main 940d32f) on a dual-GPU laptop. DXGI adapter 0 is an RTX 4060 Laptop (driver 610.47 / 32.0.16.1047), 1 is Intel UHD 8086:a78b (31.0.101.5445), 2 is Microsoft Basic Render Driver. Windows 11 26200, Rust 1.98.1 MSVC, no game data. Ran cargo test -p victory-shader --lib --locked --no-fail-fast -- --nocapture once per setting.

setting adapter named passed / failed / ignored
unset (none; hardware_adapter = RTX 4060) 245 / 3 / 3
VICTORY_ADAPTER=0 VICTORY_ADAPTER=0: NVIDIA GeForce RTX 4060 Laptop GPU 245 / 3 / 3
VICTORY_ADAPTER=1 VICTORY_ADAPTER=1: Intel(R) UHD Graphics 240 / 8 / 3
VICTORY_ADAPTER=2 VICTORY_ADAPTER=2: Microsoft Basic Render Driver 246 / 2 / 3
VICTORY_ADAPTER=7 VICTORY_ADAPTER=7: no such adapter (...) 248 / 0 / 3
VICTORY_ADAPTER=Intel none (not an adapter index) 173 / 75 / 3
VICTORY_WARP=1 none 246 / 2 / 3
VICTORY_WARP=1 VICTORY_ADAPTER=1 none (WARP wins) 246 / 2 / 3
VICTORY_WARP=1 VICTORY_ADAPTER=Intel none 173 / 75 / 3

The switch works. With =1, the Intel UHD result matches what main 940d32f gave earlier on this same iGPU with a local adapter hook: 239 / 8 / 3, plus this PR's own test = 240 / 8 / 3. The 8 failures are the iGPU's: bvh_tests ×3, arithmetic_matches_the_hardware, the stride_tests no-view read, permutes_read_the_lane_named_and_zero_from_lanes_left_out, image_atomics_of_64_bits, fspx_programs_run_with_the_hardwares_dot_products. Unset and =0 give the same 3 NVIDIA failures as main (stride_tests ×2, gathers_at_a_level_match_the_hardware). VICTORY_WARP=1 takes precedence over the index, as documented.

Things worth knowing:

  1. An out-of-range index turns the whole hardware suite green. With =7, every hardware check skips and the run reports 248 passed / 0 failed. The one no such adapter line is the only sign, and plain cargo test captures it unless a test fails. A typo looks like a clean run. Suggestion: fail with an error instead of skipping when VICTORY_ADAPTER is set but unusable.
  2. A non-numeric value also kills WARP. adapter_index is parsed before the warp branch, so Host::new(true) returns the same error. With =Intel (or =igpu), no device opens at all, so the 75 tests that need at least one device panic (e.g. check()'s no SM 6.6 device assert), even with VICTORY_WARP=1. Parsing the index only on the non-WARP path would keep WARP working.
  3. An explicit index reaches WARP (=2 here) and runs the hardware-only checks on it. That yields the 2 WARP failures hardware_adapter exists to avoid (the Wave32 permute, gathers). This is acceptable for an opt-in setting, as the triage says.

Relation to #2367. No conflict: git merge-tree is clean for this PR onto main, #2367 onto main, and the two together. They touch different files (victory-shader/src/emit/host.rs vs victory-gpu/src/host.rs), so they are complementary (test host vs title host), not duplicates. But they claim the same variable with different grammars. #2367 documents VICTORY_ADAPTER=igpu|dgpu|<index>|<name substring> in the README's switch table. Here only an index is accepted, and anything else fails 75 tests (item 2). A user who follows #2367's README and then runs cargo test --workspace hits that. Sharing one parser would fix it (victory-gpu already depends on victory-shader with host), or this PR could accept the same spellings. At minimum, the indices agree: both use EnumAdapters1 order.

AI use: Claude Code (Claude Opus 5.5) ran the tests and wrote this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants