Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions crates/xcl/src/hle/d3d12x/uma_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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<ID3D12Device> = None;
if unsafe { D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut dev) }.is_err() {
return crate::gpu::recomp::runner::skip_test("no D3D12 device");
Expand Down Expand Up @@ -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<ID3D12Device> = None;
if unsafe { D3D12CreateDevice(None, D3D_FEATURE_LEVEL_12_0, &mut dev) }.is_err() {
return crate::gpu::recomp::runner::skip_test("no D3D12 device");
Expand Down
Loading