Skip to content

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

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

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
Contributor

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.

@merzleckeier

Copy link
Copy Markdown
Contributor

Skip visibility with the serial workflow command on 42957b26 plus #2923 (d2fefa98) on 1fff69129. I used the workflow’s default features and serial libtest arguments. In three fresh no-ICD runs with default capture, the added SKIP: no D3D12 device lines from the descriptor list-ahead and indirect scratch tests were hidden. The same binary showed both lines in all three --show-output runs and all three --nocapture runs. Every run still reported three passed, zero ignored (including a neighboring descriptor control). Across NVIDIA and RADV the same selected tests passed with no generic skip messages.

For the full no-ICD comparison I used Wine’s built-in DXGI/D3D12 because the bundled DXVK path faults in existing WARP fixtures without an ICD. The full log with default capture had zero generic markers on both trees. With --show-output, main had 1 and the combined tree had 47. The same three existing watch tests failed on both trees. The serial workflow and a success-output flag address separate parts of the result.

MEASURED under Wine 11.22, with synthetic inputs, OpenAI Codex and a separate read-only review.

@aznohonza

Copy link
Copy Markdown
Contributor Author

You are right on both, and the 21:12 runs settle the visibility half.

  1. CI visibility: .github/workflows/d3d12.yml:76 runs cargo test ... -- --skip ... with no --show-output/--nocapture, so libtest captures the SKIP: lines of passing tests and the job prints none of them. The body's "the run says it did" is false in CI; it is true only for a no-capture run. I will add --show-output to that step (successful tests' captured output, in order) rather than --nocapture (interleaved), unless you would rather have a skip count and no extra log volume.
  2. The sweep: the three named sites, the 14 HostHeap::new(...) else { return } sites, ambient.rs, and gpu/ambient: LDS-tile gather compute pass and scope internal UAV barriers (D3D12-GPU-AMBIENT-LDS-GATHER) #2893's new gather_dispatches_the_partial_group are still silent. You are right that the PR reads as though every require_host() is covered.
  3. Nits: the unused host import at host.rs:5761 and the six double-line sites are mine; I will fold them in.

I will extend this PR with the sweep, the two nits and the CI flag, and re-request review. If you would rather keep it to the guard alone, say so and I will narrow the body and take the sweep as its own item.

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