Skip to content

Shader tests: a software adapter (a CI runner's) skips what only GPU hardware does - #1752

Closed
BastienRodz wants to merge 1 commit into
Marvisak:mainfrom
BastienRodz:shader-tests/software-adapter
Closed

BastienRodz wants to merge 1 commit into
Marvisak:mainfrom
BastienRodz:shader-tests/software-adapter

Conversation

@BastienRodz

Copy link
Copy Markdown
Contributor

What's wrong

CI on main (run 45492970391, windows-latest, no GPU) fails two tests in victory-shader:

  • emit::synthetic_tests::gathers_at_a_level_match_the_hardware:
    assertion `left == right` failed: hardware: lane 4 against its gather (left: [66.0, 67.0, 35.0, 34.0], right: [65.0, 66.0, 34.0, 33.0])
  • emit::synthetic_tests::permutes_read_the_lane_named_and_zero_from_lanes_left_out:
    no device ran the permute

On a runner without a GPU, Host::new(false) (D3D12CreateDevice(None, ...), adapter 0) gets the Microsoft Basic Render Driver (WARP behind the default adapter). The gather test skipped the hardware-rounding check only when the warp flag was true, so it ran the hardware-only check against WARP. The permute test skipped every device that refused the wave-32 pipeline and then failed assert!(ran > 0, "no device ran the permute") when both adapters were WARP.

What the fix does

  • Adds Host::is_software(&self) -> bool in crates/victory-shader/src/emit/host.rs, querying the device's adapter via GetAdapterLuid, IDXGIFactory4::EnumAdapterByLuid, and IDXGIAdapter1::GetDesc1, and reporting true when DXGI_ADAPTER_FLAG_SOFTWARE is set or VendorId == 0x1414 && DeviceId == 0x8c.
  • In gathers_at_a_level_match_the_hardware (synthetic_tests.rs), skips the "against its gather" rounding assertion when warp || host.is_software() instead of only warp.
  • In permutes_read_the_lane_named_and_zero_from_lanes_left_out (synthetic_tests.rs), prints no device ran the permute; skipped and returns when ran == 0, while keeping assert_eq!(out[0], want, "{label}") for any device that runs the pipeline.
  • Uses the same warp || host.is_software() check in flow_tests.rs and diff_tests.rs where fixed-wave-size pipeline creation errors are skipped on WARP.
  • Leaves translator code and all real-hardware assertions unchanged.

Tests

  • cargo xwin clippy --workspace --all-targets --locked --target x86_64-pc-windows-msvc -- -D warnings: pass
  • cargo xwin clippy --workspace --all-targets --all-features --locked --target x86_64-pc-windows-msvc -- -D warnings: pass
  • cargo xtask policy: pass
  • cargo xwin test -p victory-shader --target x86_64-pc-windows-msvc -- --test-threads=1 (Linux host under Wine, no SM 6.6 device): 147 passed; 62 failed; 2 ignored (vs 146 passed; 63 failed; 2 ignored on origin/main; permutes_read_the_lane_named_and_zero_from_lanes_left_out now skips and passes, while the remaining 62 failures require an SM 6.6 device).
  • On GitHub's windows-latest with the upstream CI's commands (clippy -D warnings with and without --all-features, then cargo test --workspace --locked): everything passes; victory-shader 209 passed, 0 failed, including both tests above: https://github.com/BastienRodz/VIctory/actions/runs/45496058662

Not tested: a GPU where Host::new(false) is real hardware. Behavior on a real hardware adapter is unchanged (host.is_software() is false, so every hardware assertion still runs).

No game data used. AI-assisted: implemented with Gemini 4 Neon, reviewed and verified with Claude Code.

Related: the same two failures show on the open PRs rebased onto 70564ae (#926, #928).

🤖 Generated with Claude Code

…hardware does

On a GPU-less windows-latest CI runner, Host::new(false) gets the
Microsoft Basic Render Driver (WARP behind adapter 0), causing two
tests in victory-shader to fail on main:

- gathers_at_a_level_match_the_hardware only skipped the hardware
  gather-rounding check when the warp flag was true, so the "hardware"
  pass ran it against WARP and failed on lane 4.
- permutes_read_the_lane_named_and_zero_from_lanes_left_out skipped
  each device that refused the wave-32 pipeline and then failed
  assert!(ran > 0) when both adapters were WARP.

Add Host::is_software(&self) to inspect the device's adapter via
GetAdapterLuid, IDXGIFactory4::EnumAdapterByLuid, and GetDesc1
(DXGI_ADAPTER_FLAG_SOFTWARE or VendorId 0x1414 / DeviceId 0x8c). Skip
the gather-rounding check when warp || host.is_software(), and have the
permute test print a skip line and return when no device can run it.
Apply the same software-adapter check where flow_tests and diff_tests
skip fixed-wave-size pipeline rejections on WARP.

Co-Authored-By: Gemini 4 Neon <noreply@google.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@steven-seagull27

Copy link
Copy Markdown

Tested 1bf4933 on Windows 11 build 26300.10075 with an RTX 5080 (driver 621.24), built-in Windows WARP, and app-local Microsoft WARP 1.0.22. The adapter check identified the RTX as hardware and both WARP drivers as software.

Adapter Gather results matching the expected values Wave32 permutation
RTX 5080 0/64 All 32 lanes matched
Built-in WARP 64/64 Skipped: the driver could not create the Wave32 pipeline
WARP 1.0.22 64/64 Ran; 7 of 32 lanes differed

The RTX gather failure predates this PR. The unmodified test failed on lane 0 on both the parent (70564ae) and the PR head (1bf4933): it returned [0, 1, 0, 0] and expected [0, 0, 0, 0]. I used temporary counters to get past the first assertion. The 64 comparisons above cover 32 lanes each for the plain and offset gathers. The separate hardware-only comparison against the native gather also ran on the RTX and differed on 3 of 16 lanes.

With WARP 1.0.22, the unmodified permutation test reproduced the failure. Lanes 5, 6, 12, 13, 18, 21, and 22 differed. For example, lane 5 returned 1022 and expected 1006. With built-in WARP forced for both adapter requests, the test runner reported two passes, but the permutation explicitly logged no device ran the permute; skipped.

@BastienRodz

Copy link
Copy Markdown
Contributor Author

Thanks, that confirms the scope. The adapter check sorts the RTX as hardware and both WARPs as software. The CI runner's case, built-in WARP with no wave-32 pipeline, now skips the permute instead of failing. The other two results are failures this PR leaves exactly as they were, and they look worth an issue of their own each, since they come from main's new tests on real setups and not from the runner:

  • the RTX 5080 gather mismatch, which you saw on 70564ae too: lane 0 returns [0, 1, 0, 0] where [0, 0, 0, 0] is expected, and 3 of 16 lanes differ from the native gather;
  • WARP 1.0.22 running the wave-32 permute with 7 lanes wrong (lane 5 returns 1022 where 1006 is expected).

Would you file those with your numbers? You have the setups that reproduce them.

@DenRakEiw DenRakEiw left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verified locally merged onto origin/main (70564ae, Windows 11 x64, NVIDIA GeForce RTX 5090 + WARP, Rust 1.98.1 MSVC):

  • cargo test -p victory-shader --lib emit::flow_tests:: — passed on both RTX 5090 hardware and VICTORY_D3D12_WARP=1
  • cargo clippy -p victory-shader --all-targets — 0 warnings
  • cargo xtask policy — ok

Clean Host::is_software() guard so software adapters (such as CI WARP runners) skip hardware-only shader tests cleanly. Looks good.

AI-assisted (Gemini 4 Neon).

@BastienRodz

Copy link
Copy Markdown
Contributor Author

Superseded by 42363ab on main (the test host refuses a software default adapter, and the permute test skips when only WARP is there), which fixes the same two CI failures. Thanks to steven-seagull27 and DenRakEiw for testing this one.

@steven-seagull27

Copy link
Copy Markdown

@BastienRodz I filed the executable Wave32 permutation failure as #2949. On current main 63bcca43 the RTX 5080 matched 32/32 and WARP 1.0.22 matched 25/32. A native HLSL shader reproduced the exact same seven lanes, including lane 5 returning 1022 for an expected 1006. Built-in WARP skipped before dispatch.

The other requested follow-up, the NVIDIA gather mismatch, is already covered by the raw-view fixture changes in #2323 and #2357.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants