Skip to content

shader, docs: skip GPU tests through one helper for XTP_REQUIRE_GPU - #65

Merged
simnJS merged 1 commit into
MiamiGame:mainfrom
GamerOG563:shader/require-gpu-helper
Nov 25, 2026
Merged

simnJS merged 1 commit into
MiamiGame:mainfrom
GamerOG563:shader/require-gpu-helper

Conversation

@GamerOG563

@GamerOG563 GamerOG563 commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What and why

xtp-shader's GPU tests previously returned early and passed when no SM 6.6 device was available (eprintln!("...; skipped") or silent else { return }), even when XTP_REQUIRE_GPU was set.

This change:

  • adds xtp-testkit as a dev-dependency of xtp-shader;
  • adds shared test helpers in crates/xtp-shader/src/emit/host.rs (Host::test_device, Host::test_warp, Host::test_hosts, skip_gpu, and skip_once) that write canonical SKIPPED <test>: <reason> markers through xtp_testkit::skip (at most once per test and reason) and panic when XTP_REQUIRE_GPU (or XTP_REQUIRE=no-gpu) forbids skipping;
  • routes every GPU, compiler (dxc.exe, XTP_CONSOLE_DXC), validator (dxil.dll), and device-capability skip that returns early across crates/xtp-shader/src through these helpers (including buffer16_tests, helper_tests, and all WARP tests in rayquery_tests), while keeping plain eprintln! notes in non-returning validation/disassembly helpers so skip counts are not inflated and keeping expect on #[ignore = "hardware: ..."] tests;
  • lets tests previously hardcoded to Host::new(true) without a WARP-only reason (input_tests, loop_limit_tests, meshidx_tests, r1_tests, userdata_tests, lower::flow, lower::smem::tests::scalar_load_keeps_an_unaligned_byte_offset_with_a_cbv_slot) follow XTP_TEST_ADAPTER, while keeping WARP with explanatory comments on group_id_tests::flat_ids_on_warp, rayquery_tests's warp::run tests, smem_tests::run_scalar_reads, and lower::smem::tests::a_heap_slot_read_by_scalar_and_vector_loads_is_read_raw_both_ways;
  • updates docs/analysis/hardware-tests.md and docs/contributing-without-a-gaming-pc.md to reflect the new xtp-shader skip behaviour.

Size note (size/L, ~760 changed lines across 38 files): the change is mechanical across the test modules in crates/xtp-shader/src plus the helper/unit tests in emit/host.rs and two doc updates.

Fixes: #60
Depends on: none

Area

shader (crates/xtp-shader), docs

Tests

  • cargo xtask pr-check passes on my machine
  • New or changed behaviour has tests that need no game files, or I explain below why it cannot
  • Ran on a title: no (test-harness change; verified across WARP, strict no-GPU, non-strict no-GPU, and hardware NVIDIA RTX 3050 Laptop GPU)

Commands verified:

  • $env:XTP_TEST_ADAPTER='none'; $env:XTP_REQUIRE_GPU='1'; cargo test -p xtp-shader --locked --lib -> all 118 GPU tests fail as expected (387 passed; 118 failed)
  • Remove-Item Env:XTP_REQUIRE_GPU; $env:XTP_TEST_ADAPTER='none'; cargo test -p xtp-shader --locked --lib -> 505 passed; 0 failed, 122 canonical SKIPPED <test>: <reason> markers (118 GPU + 4 no-console-dxc)
  • Remove-Item Env:XTP_REQUIRE_GPU; $env:XTP_TEST_ADAPTER='warp'; cargo test -p xtp-shader --locked --lib -> 505 passed; 0 failed (5 canonical skips: 4 no-console-dxc + each_adapter_gets_what_it_runs)
  • $env:XTP_TEST_ADAPTER='hardware'; $env:XTP_REQUIRE_GPU='1'; cargo test -p xtp-shader --locked --lib -> 505 passed; 0 failed on GeForce RTX 3050 Laptop GPU (4 no-console-dxc skips)

Provenance

  • I wrote all of this change myself for XTP, or it only moves code already in XTP.
  • Some of it comes from elsewhere. Each source, its licence and the files concerned are listed here, and every licence is compatible with GPL-3.0-or-later:

Written for XTP from XTP's own crates/xtp-gpu/src/testgpu.rs and crates/xtp-testkit. xcl and AnyPS5 were not read.

AI assistance: Gemini assisted with auditing the skip sites in crates/xtp-shader, writing the shared helper and unit tests, and running the test matrix.

Checklist

  • No game data, keys, console SDK code or headers, and nothing that circumvents DRM (asset policy)
  • No code copied from xcl or AnyPS5 (references only: read them to understand, write your own)
  • I agree to license this contribution under GPL-3.0-or-later
  • Title and every commit follow <area>: <summary>; one topic; under 400 changed lines, or the reason is above
  • Docs updated where behaviour, commands or variables changed (README, docs/)

@github-actions github-actions Bot added area/shader touches crates/xtp-shader area/deps Cargo.lock size/L 400 to 999 changed lines conflict conflicts with its base branch labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown

This pull request now conflicts with its base branch. Please rebase it on main (or merge main into it) and resolve the conflicts; the conflict label goes away by itself once it merges cleanly.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for this first contribution, and for the thorough test matrix! The helper is clean, test_hosts reports every empty path, and the child-process test is a nice touch.

A few things before it can land:

  1. Rebase needed. rayquery_tests.rs changed a lot on main today. After rebasing, three WARP tests there still use Host::new(true) with eprintln!("…; skipped"), and they also have "tier 1.1" skips. Please route them through test_warp/skip_once too.
  2. Validation helpers. validate/verdict now print SKIPPED <test>: no-dxil while the test keeps running. That inflates the skip counts, breaks the "return after skip" rule of xtp-testkit, and loses the error detail. A plain note with {what}: {e} may fit better (geometry_tests.rs:1133, rect_gs.rs:911, smem_data_tests.rs:99, stride_tests.rs:134, waterfall_tests.rs:98, validator_tests.rs:20).
  3. Names and docs. warp_draws_the_last_primitive_export and the doc of loop_limit_tests::run still say WARP. docs/analysis/hardware-tests.md (lines 155 and 157) still describes the gap this PR closes.
  4. Minor: the ignored test at salu.rs:809 used to panic without a device and now skips unless strict mode is on. Please say whether that's intended.

I'll approve the CI runs once the rebase is pushed. Happy to re-review then!

@GamerOG563
GamerOG563 force-pushed the shader/require-gpu-helper branch from 18b96e0 to 7437240 Compare November 25, 2026 17:57
@GamerOG563 GamerOG563 changed the title shader: skip GPU tests through one helper that honours XTP_REQUIRE_GPU shader, docs: skip GPU tests through one helper for XTP_REQUIRE_GPU Nov 25, 2026
@GamerOG563

Copy link
Copy Markdown
Contributor Author

Thanks for the thorough review! Rebased onto main (458cd45) and addressed all four points:

  1. Rebase & new tests on main (rayquery_tests.rs, buffer16_tests.rs, helper_tests.rs):
    • Resolved the rebase conflict in rayquery_spliced_program_traces_on_warp and routed rayquery_family_a_misses_rays_dxr_leaves_undefined_on_warp, rayquery_family_a_translates_validates_and_binds_alone, and rayquery_family_a_end_to_end_on_warp through Host::test_warp() and skip_once("WARP has no ray-tracing tier 1.1").
    • Also routed the newly landed buffer16_tests::run (Host::test_hosts()) and helper_tests::hosts / draw_everywhere (skip_gpu) on main.
  2. Non-returning validation & disassembly helpers:
    • Reverted non-returning dxil.dll and dxc.exe helpers (geometry_tests.rs, rect_gs.rs, validator_tests::verdict, smem_data_tests.rs, stride_tests.rs, waterfall_tests.rs, rayquery_tests::check_dxil, limits_tests::heap_kinds, and smem_tests::disassembly) to plain eprintln! notes preserving {what} and {e} (and avoiding the word skipped so test-each.ps1 does not count passing runs as skips).
    • Kept skip_once strictly on early returns (validator_tests::the_validator_knows_the_declared_version, emit::tests::constant_color_validates, diff_tests, image_tests, lds, each_adapter_gets_what_it_runs, and WARP ray-tracing tier 1.1 checks).
  3. Names and docs:
    • Renamed warp_draws_the_last_primitive_export to draws_the_last_primitive_export in meshidx_tests.rs.
    • Updated stale WARP references in the doc comments of loop_limit_tests::run, r1_tests.rs, and lower/flow.rs.
    • Updated docs/analysis/hardware-tests.md (Section 3 table) and docs/contributing-without-a-gaming-pc.md.
  4. salu.rs (#[ignore = "hardware: 32-lane waves"]):
    • Restored Host::new(false).expect("an SM 6.6 device") in a_first_lane_code_table_read_is_the_first_lanes_for_every_lane so running --ignored hardware tests without a device fails immediately, matching group_id_tests, lane_read_loop_tests, and split_tests.

Re-verified all four xtp-shader adapter/requirement modes (118 GPU tests fail under XTP_TEST_ADAPTER=none + XTP_REQUIRE_GPU=1; 505 passed, 0 failed with 122 canonical SKIPPED lines when XTP_REQUIRE_GPU is unset; 505 passed, 0 failed on both WARP and hardware GPU) and cargo xtask pr-check.

@github-actions github-actions Bot added area/docs docs/, Markdown conflict conflicts with its base branch and removed conflict conflicts with its base branch labels Nov 25, 2026

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks, all four earlier points are addressed, and the supply chain is clean: xtp-testkit is a workspace path crate, and Cargo.lock gets no new package.

One change, please: keep a_heap_slot_read_by_scalar_and_vector_loads_is_read_raw_both_ways (crates/xtp-shader/src/emit/lower/smem.rs:1315) on Host::test_warp(). Its doc comment explains why WARP is the check there. The test removes the device on the old handle, and hardware behaviour is undefined in that case, so on a real GPU it can pass or crash at random.

I've approved the CI runs for this head. Once that line is back and CI is green, we'll merge.

Add xtp-testkit as a dev-dependency of xtp-shader and centralise test
skip reporting in crates/xtp-shader/src/emit/host.rs (Host::test_device,
Host::test_warp, Host::test_hosts, skip_gpu, and skip_once).

When no host D3D12 device is available, GPU tests now fail if
XTP_REQUIRE_GPU (or XTP_REQUIRE=no-gpu) is set and otherwise emit one
canonical SKIPPED <test>: <reason> marker through xtp_testkit::skip
before returning. Non-returning optional validation and disassembly
helpers emit plain notes so skip counts stay exact.

Unpin tests that hardcoded Host::new(true) without a WARP-only reason so
they follow XTP_TEST_ADAPTER, keep WARP where required (4-lane waves,
root-signature-only heap binding, raw scalar reads of a structured
slot, and undefined hardware behaviour on the old handle in smem), and
update docs/analysis/hardware-tests.md and
docs/contributing-without-a-gaming-pc.md.

Fixes: MiamiGame#60
@GamerOG563
GamerOG563 force-pushed the shader/require-gpu-helper branch from 7437240 to 91ed24c Compare November 25, 2026 18:19
@GamerOG563

Copy link
Copy Markdown
Contributor Author

Restored Host::test_warp() (with a comment explaining the undefined hardware behaviour on the old handle) in a_heap_slot_read_by_scalar_and_vector_loads_is_read_raw_both_ways (crates/xtp-shader/src/emit/lower/smem.rs) and re-verified cargo xtask pr-check.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks! The smem heap-slot test is back on Host::test_warp() with a clear reason, and nothing else changed. I've approved the CI runs; we'll merge once they're green.

@simnJS simnJS left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

CI is green and the review is clean. Approving, thanks for the cleanup.

@simnJS
simnJS merged commit 12be0a1 into MiamiGame:main Nov 25, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/deps Cargo.lock area/docs docs/, Markdown area/shader touches crates/xtp-shader size/L 400 to 999 changed lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

shader: GPU tests skip silently without a device, even with XTP_REQUIRE_GPU

2 participants