From cd13b17199cea4ce88f6956c5d6dae791a43048e Mon Sep 17 00:00:00 2001 From: Kalmarv <59708937+Kalmarv@users.noreply.github.com> Date: Sat, 28 Nov 2026 11:49:21 -0500 Subject: [PATCH] Tests: the mixed-window remake tests run in a child process `a_refused_gpu_upload_segment_becomes_custom` and `mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment` remade a window inside the lib test binary. After the lib's earlier tests the remake's CreateCommandQueue returns E_OUTOFMEMORY (here and on throny's RTX 4080), also with --test-threads=1, so it is something earlier tests leave in the process, not the tests running beside it. The queue is made after a segment was mapped, so the remake cannot restore the window and stops the process with 0x7C10003. That ended the lib test binary after ~1,390 tests on NVIDIA (reported on #3041). Making the stop panic in tests instead is not enough: the binary then died later with an access violation, after the failed remake left the window to the driver. Each of the two tests now runs again on its own in a child process, as `failed_restore_stops_before_importing_an_unbacked_window` already does; the parent fails when the child does and passes the child's SKIPPED lines on. A failing child's exit code (decimal and hex) heads the parent's failure message: a stop without a panic, such as 0x7C10003, leaves only a partial transcript. Co-Authored-By: Claude Opus 5.5 --- crates/xcl/src/hle/d3d12x/uma_driver.rs | 33 +++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/uma_driver.rs b/crates/xcl/src/hle/d3d12x/uma_driver.rs index 3efb5a26bd..56ba6cfac3 100644 --- a/crates/xcl/src/hle/d3d12x/uma_driver.rs +++ b/crates/xcl/src/hle/d3d12x/uma_driver.rs @@ -694,6 +694,33 @@ mod tests { /// its reservations meanwhile lets a segment land elsewhere, which stops the process. static MIXED_REMAKE: std::sync::Mutex<()> = std::sync::Mutex::new(()); + /// Runs the test `name` of this module again on its own in a child process and fails when the + /// child does; false in the child, which runs the test's body. After the lib's earlier tests the + /// remake's `CreateCommandQueue` can fail with E_OUTOFMEMORY (with one test thread too), and a + /// remake that fails after a segment was mapped stops the process: in the test binary that ended + /// every test after it. + fn ran_in_child(name: &str) -> bool { + use std::io::Write; + const CHILD: &str = "XCL_TEST_UMA_REMAKE_CHILD"; + if std::env::var_os(CHILD).is_some() { + return false; + } + let output = std::process::Command::new(std::env::current_exe().unwrap()) + .args(["--exact", &format!("hle::d3d12x::uma_driver::tests::{name}"), "--nocapture", "--test-threads=1"]) + .env(CHILD, "1") + .output() + .unwrap(); + let transcript = format!("{}{}", String::from_utf8_lossy(&output.stdout), String::from_utf8_lossy(&output.stderr)); + for line in transcript.lines().filter(|l| l.starts_with("SKIPPED ")) { + let _ = writeln!(std::io::stderr(), "{line}"); + } + // (the child's exit code too: a stop with no panic leaves only a partial transcript) + let code = output.status.code().map_or("none".into(), |c| format!("{c} ({:#x})", c as u32)); + assert!(output.status.success(), "child exit code {code}\n{transcript}"); + assert!(transcript.contains("1 passed"), "child exit code {code}\n{transcript}"); + true + } + /// On by default for NVIDIA outside Wine only; the switch overrides either way. #[test] fn driver_windows_by_default_on_nvidia_outside_wine() { @@ -732,6 +759,9 @@ mod tests { use super::*; use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0; let _alone = MIXED_REMAKE.lock().unwrap_or_else(|e| e.into_inner()); + if ran_in_child("mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment") { + return; + } let mut dev: Option = None; if unsafe { D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut dev) }.is_err() { return crate::gpu::recomp::runner::skip_test("no D3D12 device"); @@ -789,6 +819,9 @@ mod tests { use super::*; use windows::Win32::Graphics::Direct3D::D3D_FEATURE_LEVEL_12_0; let _alone = MIXED_REMAKE.lock().unwrap_or_else(|e| e.into_inner()); + if ran_in_child("a_refused_gpu_upload_segment_becomes_custom") { + return; + } let mut dev: Option = None; if unsafe { D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut dev) }.is_err() { return crate::gpu::recomp::runner::skip_test("no D3D12 device");