Skip to content

d3d12-gpu: a test that needs a card says SKIP when there is none - #2908

Open
aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:gpu/test-require-host
Open

aznohonza wants to merge 1 commit into
ProjectLeonida:mainfrom
aznohonza:gpu/test-require-host

Conversation

@aznohonza

Copy link
Copy Markdown
Contributor

Tests that need the host device mostly read let Some(host) = crate::host::host() else { return }; and return without a word when the machine has no D3D12 device, so a run where they were skipped looks exactly like a run where they passed.

host::require_host() is the same lookup with one stderr line when there is none:

SKIP: no D3D12 device

The 67 test call sites that used the silent form now call it. Sites that already print their own reason (e.g. sampler, pool::small, compose, indirect/bench) are left as they were, and production callers are untouched — require_host exists in test builds only (#[cfg(test)]).

Verification:

  • cargo xwin check --target x86_64-pc-windows-msvc --workspace --all-targets --locked passes, and again with --features diagnostics.
  • On a host with no D3D12 device (this Linux box, the test binary under Wine), a silent site now prints SKIP: no D3D12 device (e.g. indirect::tests::host_list_reuses_and_grows_scratch_across_submissions, descriptor::host::tests::an_oversized_constant_buffer_view_leaves_the_device_alive), while sampler::tests::the_host_takes_its_anisotropic_samplers still prints only its own skipped: no host GPU here.
  • No test changes its assertions, runs or environment; no game data; no new switch.

Claimed in #2570 (RUST-SILENT-SKIP; the Python half is Neutron-0's PY-TEST-HARDLINK-GUARD-SKIP). AI-assisted.

Most tests that need the host device read

    let Some(host) = crate::host::host() else { return };

and return without a word when the machine has no D3D12 device, so a run
that skipped them reads as if they passed. `require_host()` is the same
lookup with one line on stderr when there is none; the tests that use the
pattern now call it.

Sites that already print their own reason keep it (left as they were), and
production callers are untouched: `require_host` exists in test builds
only.

@KelboLive KelboLive 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.

The rewrite is safe and mechanical — 67 call sites, cargo test -p leonida-gpu --lib is 632/0/59 both with a card and with host() forced to return None, and cargo check without --tests proves every require_host() is inside #[cfg(test)]. But it does not deliver the visibility it is for:

  1. The SKIP line is invisible in CI. libtest captures stderr for passing tests, and .github/workflows/d3d12.yml:76 runs cargo test without --nocapture on a runner labelled "no GPU". With a simulated no-device run, ambient::tests::the_passes_build prints nothing in default output and only shows SKIP: no D3D12 device under --nocapture. So "the run says it did" is false in exactly the configuration that matters — either add --nocapture to the no-GPU step or count skips in a summary.
  2. The sweep is incomplete. Still silent under a simulated no-device run: descriptor/host.rs:7625, indirect.rs:2377, resource.rs:4657, and 14 tests gated by HostHeap::new(...) else { return } (e.g. descriptor/host.rs:8039, 8137, 8170, 8217, 8483, 8511). I ran those with --nocapture and no device — all pass with no SKIP at all.

Two small things:

  • host.rs:5761's use super::{…, host, …} is now an unused import (new warning).
  • The six host.rs sites that already print their own reason now print two lines (generic SKIP plus their own): host.rs:5763, 10547, 10591, 10656, 10715, 10752.

Cross-PR: #2893 appends gather_dispatches_the_partial_group right after the_passes_build (ambient.rs:912) with the same silent let Some(host) = host() else { return }. No textual conflict, but whichever lands second leaves that new test silent — sweep it in the second one.

Verdict: changes requested, with zero behavioural risk — the guard works, but the central claim is not observable in CI and the sweep leaves 18 silent sites.

@merzleckeier

Copy link
Copy Markdown
Contributor

Independent device-availability matrix at 42957b26b + d2a564b66 (Win64, Wine 11.22).

With the Vulkan ICD deliberately unavailable, main was silent for the descriptor and indirect tests. Main plus this PR emitted exactly one SKIP: no D3D12 device for each of those two tests. The sampler test kept its existing specific skip message on both revisions. The test runner still counts those early returns as passes.

With each real adapter exposed separately, the three tests passed on both revisions without skip messages. The sampler test confirmed it created an anisotropic sampler on both the AMD Radeon integrated graphics (RADV 26.3.1) and the GeForce RTX 4070 SUPER (620.73.4 as reported by Wine).

MEASURED with synthetic inputs. AI-assisted (Codex).

@aznohonza

Copy link
Copy Markdown
Contributor Author

Thanks for the device-availability matrix — that is exactly the behaviour this is meant to have: one SKIP: no D3D12 device line for the descriptor/indirect tests on a host without an adapter, none when one exists, and the sampler test keeps its own message. No further changes on my side.

AI-assisted.

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