Merge pull request #51 from Foniass/t3/make-gpu-test-skips-visible

GPU tests that cannot run on the adapter say so: SKIPPED lines, a count in scripts/test.ps1, XCL_REQUIRE_GPU (#42)
This commit is contained in:
ivall
2026-11-22 23:37:39 +01:00
8 changed files with 56 additions and 5 deletions
+4 -1
View File
@@ -128,7 +128,10 @@ xcl rpf D:\data\shaders.rpf --extract NAME --out folder
Unit tests, an end-to-end test with our own "console title" (`tests/testtitle`) and GPU tests
(D3D12, SM 6.6; skipped without a GPU / DXC; `XCL_ADAPTER=1` or `XCL_ADAPTER=radeon` picks
another adapter than the first high-performance one, for titles too). Tests on real game data are opt-in through
another adapter than the first high-performance one, for titles too). A GPU test that cannot run on
the adapter (no GPU / DXC / wave64 / mesh shaders) passes too, but prints `SKIPPED <test>: <reason>`, and
`scripts/test.ps1` counts them at the end; `XCL_REQUIRE_GPU=wave64` (or `mesh`, or `wave64,mesh`) makes
those skips fail. Tests on real game data are opt-in through
environment variables pointing at your own files – `XCL_SAMPLE_RPF` (shader pack),
`XCL_SAMPLE_DLLS` (the game's console DLLs), `XCL_SAMPLE_TTPF` (texture archive),
`XCL_SAMPLE_BK2` (a movie), `XCL_SAMPLE_BVH4`, `XCL_SAMPLE_AWC` (a sound) – described in `HANDOFF.md`; without them those
@@ -297,6 +297,7 @@ mod tests {
#[test]
fn gpu_dispatch_matches_native_wave64_reference() {
if super::super::dxc::location().is_err() {
super::super::runner::skip_test("no DXC");
return;
}
let hlsl = validation_hlsl();
+21
View File
@@ -358,6 +358,27 @@ pub fn mesh_shaders_supported() -> Result<bool, String> {
gpu.as_ref().map(|x| x.mesh).map_err(|x| x.clone())
}
/// A GPU test (or a part of one) that cannot run here, `reason` one of "no GPU", "no DXC",
/// "no wave64", "no mesh shaders": `SKIPPED <test>: <reason>` written to stderr itself, so the
/// line shows without `--nocapture` (libtest captures only `print!` / `eprint!`), and
/// `scripts/test.ps1` counts them. `XCL_REQUIRE_GPU=wave64` or `=mesh` (or both, comma-separated)
/// turns a skip that leaves that coverage out into a failure.
pub fn skip_test(reason: &str) {
use std::io::Write;
let thread = std::thread::current();
let test = thread.name().unwrap_or("?");
let required = std::env::var("XCL_REQUIRE_GPU").unwrap_or_default();
let fails = required.split(',').map(str::trim).any(|r| match r {
"wave64" => reason != "no mesh shaders",
"mesh" => reason != "no wave64",
_ => false,
});
if fails {
panic!("{test}: {reason}, but XCL_REQUIRE_GPU={required}");
}
let _ = writeln!(std::io::stderr(), "SKIPPED {test}: {reason}");
}
/// Run a compiled kernel (DXIL) with `state` and flat memory `mem`.
pub fn run(dxil: &[u8], state: &KernelState, mem: &[u32]) -> Result<KernelResult, String> {
run_with(dxil, state, mem, &[], &[])
+8 -2
View File
@@ -10,7 +10,8 @@ fn gpu_ready() -> bool {
match (runner::adapter(), runner::wave64_supported(), super::dxc::location()) {
(Ok(_), Ok(true), Ok(_)) => true,
(a, w, d) => {
println!("GPU/DXC wave64 unavailable – skipping ({:?} / {:?} / {:?})", a.err(), w.ok(), d.err());
println!("GPU/DXC wave64 unavailable – skipping ({:?} / {:?} / {:?})", a.as_ref().err(), w.ok(), d.as_ref().err());
runner::skip_test(if a.is_err() { "no GPU" } else if d.is_err() { "no DXC" } else { "no wave64" });
false
}
}
@@ -20,7 +21,8 @@ fn gpu_ready_wave32() -> bool {
match (runner::adapter(), super::dxc::location()) {
(Ok(_), Ok(_)) => true,
(a, d) => {
println!("GPU/DXC unavailable – skipping ({:?} / {:?})", a.err(), d.err());
println!("GPU/DXC unavailable – skipping ({:?} / {:?})", a.as_ref().err(), d.as_ref().err());
runner::skip_test(if a.is_err() { "no GPU" } else { "no DXC" });
false
}
}
@@ -32,6 +34,7 @@ fn mesh_ready() -> bool {
Ok(true) => true,
r => {
println!("GPU without mesh shaders – skipping ({r:?})");
runner::skip_test(if r.is_err() { "no GPU" } else { "no mesh shaders" });
false
}
}
@@ -1655,6 +1658,7 @@ fn gpu_packed_math_dots_movrel() {
fn dxc_mesh_shader_probe() {
use super::dxc;
if dxc::location().is_err() {
runner::skip_test("no DXC");
return;
}
let src = r#"
@@ -2501,6 +2505,8 @@ fn gpu_geometry_wave32_prefix_count_over_a_mask() {
let native = translate_geometry(&code, g, false).unwrap();
if runner::wave64_supported() == Ok(true) {
run(&native);
} else {
runner::skip_test("no wave64");
}
}
+1
View File
@@ -573,6 +573,7 @@ mod tests {
fn gpu_console_textures_upload_every_mip_and_slice() {
let Some((dev, queue)) = device() else {
println!("no D3D12 device – skipping");
crate::gpu::recomp::runner::skip_test("no GPU");
return;
};
let rgba8 = desc::gfx10_format(DXGI_FORMAT_R8G8B8A8_UNORM).unwrap();
+3
View File
@@ -319,6 +319,7 @@ fn run_both(c: &IDxcCompiler3, body: &str) -> Result<(Vec<u32>, Vec<u32>), Strin
fn console_compiled_kernels_match_the_pc_compile() {
let Some(c) = console_compiler() else { return };
if runner::adapter().is_err() {
runner::skip_test("no GPU");
return;
}
let mut failed = Vec::new();
@@ -515,6 +516,7 @@ fn console_compiled_graphics_reads_its_root_arguments() {
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32B32_FLOAT;
let Some(c) = console_compiler() else { return };
if runner::adapter().is_err() {
runner::skip_test("no GPU");
return;
}
let common = "cbuffer k : register(b0) { float k0; float k1; float k2; float k3; };\ncbuffer m : register(b1) { float4 m0; float4 m1; };\n#define ROOT [RootSignature(\"RootConstants(num32BitConstants=4, b0), CBV(b1)\")]\n";
@@ -558,6 +560,7 @@ fn console_compiled_derivatives_hold_on_triangle_edges() {
use windows::Win32::Graphics::Dxgi::Common::DXGI_FORMAT_R32G32B32_FLOAT;
let Some(c) = console_compiler() else { return };
if runner::adapter().is_err() {
runner::skip_test("no GPU");
return;
}
let root = "#define ROOT [RootSignature(\"RootFlags(ALLOW_INPUT_ASSEMBLER_INPUT_LAYOUT)\")]\n";
+3
View File
@@ -38,6 +38,7 @@ fn mesh_shaders(dev: &ID3D12Device) -> bool {
&& o7.MeshShaderTier.0 >= D3D12_MESH_SHADER_TIER_1.0;
if !ok {
println!("GPU without mesh shaders – skipping");
xcl::gpu::recomp::runner::skip_test("no mesh shaders");
}
ok
}
@@ -56,6 +57,7 @@ fn setup(names: &[&str]) -> Option<(Vec<Vec<u8>>, ID3D12Device, std::sync::Mutex
};
if xcl::gpu::recomp::dxc::location().is_err() {
println!("no DXC – skipping");
xcl::gpu::recomp::runner::skip_test("no DXC");
return None;
}
let recs = pack::scan(data, 0x40);
@@ -70,6 +72,7 @@ fn setup(names: &[&str]) -> Option<(Vec<Vec<u8>>, ID3D12Device, std::sync::Mutex
.collect();
if xcl::hle::d3d12x::backend() != xcl::hle::d3d12x::Backend::Real {
println!("no real D3D12 device – skipping");
xcl::gpu::recomp::runner::skip_test("no GPU");
return None;
}
println!("backend device: {}", real::stats().adapter);
+15 -2
View File
@@ -6,5 +6,18 @@ $missing = 'XCL_SAMPLE_RPF', 'XCL_SAMPLE_DLLS', 'XCL_SAMPLE_TTPF', 'XCL_SAMPLE_B
if ($missing) { Write-Host "not set, their tests are skipped: $($missing -join ', ')" }
cargo build --workspace
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
cargo test --workspace -- --test-threads=4
exit $LASTEXITCODE
# GPU tests that cannot run on this adapter pass too: each prints "SKIPPED <test>: <reason>"
# to stderr (XCL_REQUIRE_GPU=wave64 / =mesh makes them fail); counted at the end
$ErrorActionPreference = 'Continue'
$skipped = @()
cargo test --workspace -- --test-threads=4 2>&1 | ForEach-Object {
$line = "$_"
if ($line -match '^SKIPPED \S+: (.+)$') { $skipped += $Matches[1] }
Write-Host $line
}
$code = $LASTEXITCODE
if ($skipped) {
$counts = $skipped | Group-Object | Sort-Object Count -Descending | ForEach-Object { "$($_.Count) ($($_.Name))" }
Write-Host "GPU tests skipped on this adapter: $($counts -join ', ')"
}
exit $code