From 3f60df5a5ace7b6cef3e222be808037772b61aa6 Mon Sep 17 00:00:00 2001 From: ivall Date: Wed, 25 Nov 2026 20:30:51 +0100 Subject: [PATCH] Tests: host comparisons take the driver's own answer under Wine The host-driver tests of #1612, #1578 and #1613 required the driver to refuse invalid descriptions. vkd3d-proton accepts some of them, and XCL answers as it does, so the tests failed under Wine on the driver's answer and not on XCL's. They now compare XCL with the driver, and still require the refusal on Windows. The null-description step of #1608 does not run under Wine, where vkd3d-proton dereferences it and the process ends. The console heap tests of #1687 returned in silence without unified memory; they report a skip now. --- crates/xcl/tests/console_heap_contract.rs | 27 ++++++++++++------- .../d3d12_command_objects_and_root_sig.rs | 9 +++++-- .../tests/d3d12_create_committed_resource.rs | 9 +++++-- .../xcl/tests/d3d12_create_placed_resource.rs | 15 ++++++----- .../d3d12_query_and_command_signature.rs | 18 ++++++++++--- 5 files changed, 55 insertions(+), 23 deletions(-) diff --git a/crates/xcl/tests/console_heap_contract.rs b/crates/xcl/tests/console_heap_contract.rs index 533af0e9bf..d8e7041443 100644 --- a/crates/xcl/tests/console_heap_contract.rs +++ b/crates/xcl/tests/console_heap_contract.rs @@ -5,13 +5,22 @@ use xcl::hle::d3d12x::console_heap::{self, Slot}; +/// The unified memory, or a counted skip. +fn uma() -> Option<&'static xcl::gpu::uma::Uma> { + let u = xcl::gpu::uma::get(); + if u.is_none() { + xcl::gpu::recomp::runner::skip_test("no unified memory"); + } + u +} + fn rel(u: &xcl::gpu::uma::Uma, p: u64) -> u32 { (p as usize - u.base()) as u32 } #[test] fn view_heap_slots_window_zero_and_release() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC001, 4, 0x2000, 0x5000, 32, false, false, true)); let v = console_heap::start(0xC001).unwrap(); assert_eq!(u.window_of(v as usize), Some(0), "view heap must live in window 0 (32-bit table addressing)"); @@ -42,7 +51,7 @@ fn view_heap_slots_window_zero_and_release() { #[test] fn view_heap_indexing_is_per_page_slot_number() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC002, 4, 0x3000, 0x6000, 32, false, false, true)); let v = console_heap::start(0xC002).unwrap(); // 4 slots: 0..3, each 32 bytes apart, k = (addr - base) / 32 @@ -61,7 +70,7 @@ fn view_heap_indexing_is_per_page_slot_number() { #[test] fn sampler_heap_slots_and_copy() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC003, 2, 0x9000, 0, 16, true, false, true)); let sm = console_heap::start(0xC003).unwrap(); assert_eq!(u.window_of(sm as usize), Some(0), "sampler heap must live in window 0"); @@ -91,7 +100,7 @@ fn sampler_heap_slots_and_copy() { #[test] fn image_copy_renumbers_word_0_and_buffer_copy_keeps_address() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC004, 4, 0x1000, 0x5000, 32, false, false, true)); let v = console_heap::start(0xC004).unwrap(); let s1 = console_heap::slot(v + 32).unwrap(); @@ -121,7 +130,7 @@ fn image_copy_renumbers_word_0_and_buffer_copy_keeps_address() { #[test] fn words_at_reads_the_console_address_space() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC005, 2, 0x4000, 0x7000, 32, false, false, true)); let v = console_heap::start(0xC005).unwrap(); let s0 = console_heap::slot(v).unwrap(); @@ -142,7 +151,7 @@ fn words_at_reads_the_console_address_space() { fn heap_not_window_zero_is_still_registered_but_reported_elsewhere() { // a heap registered here is in window 0 by construction; the release path is what this // pins: after unregister, words_at reports None and the heap is forgotten - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC006, 1, 0x5000, 0x8000, 32, false, false, true)); let v = console_heap::start(0xC006).unwrap(); assert!(console_heap::words_at(rel(u, v)).is_some()); @@ -153,7 +162,7 @@ fn heap_not_window_zero_is_still_registered_but_reported_elsewhere() { #[test] fn non_shader_visible_heap_reports_no_gpu_uav() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; // pc_gpu = 0: the title made the heap CPU-only; slots report pc_gpu_uav == 0 assert!(console_heap::register(0xC007, 2, 0x6000, 0, 32, false, false, false)); let v = console_heap::start(0xC007).unwrap(); @@ -169,7 +178,7 @@ fn non_shader_visible_heap_reports_no_gpu_uav() { fn copy_words_of_a_view_to_a_buffer_slot_does_not_crash_on_short_words() { // copy_words reads exactly the source's word count and writes exactly 8 (a view slot); // a source slot written with only 4 words must not be read past the slot - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC008, 2, 0x7000, 0x9000, 32, false, false, true)); let v = console_heap::start(0xC008).unwrap(); let s0 = console_heap::slot(v).unwrap(); @@ -187,7 +196,7 @@ fn copy_words_of_a_view_to_a_buffer_slot_does_not_crash_on_short_words() { #[test] fn start_is_stable_across_slot_calls() { - let Some(u) = xcl::gpu::uma::get() else { return }; + let Some(u) = uma() else { return }; assert!(console_heap::register(0xC009, 2, 0x8100, 0x9100, 32, false, false, true)); let v = console_heap::start(0xC009).unwrap(); let _s = console_heap::slot(v).unwrap(); diff --git a/crates/xcl/tests/d3d12_command_objects_and_root_sig.rs b/crates/xcl/tests/d3d12_command_objects_and_root_sig.rs index 6d5f46440e..3b2806ddb4 100644 --- a/crates/xcl/tests/d3d12_command_objects_and_root_sig.rs +++ b/crates/xcl/tests/d3d12_command_objects_and_root_sig.rs @@ -67,8 +67,13 @@ fn create_command_queue_and_allocator_match_host_driver() { let (mut p_hook, mut p_host) = (std::ptr::null_mut(), std::ptr::null_mut()); let hr_hook = q_hook(dev, &bad, &q_iid, &mut p_hook); let hr_host = q_host(dev, &bad, &q_iid, &mut p_host); - assert!(hr_hook < 0 && hr_host < 0, "expected queue failure: hook={hr_hook:#x}, host={hr_host:#x}"); - assert!(p_hook.is_null() && p_host.is_null()); + assert_eq!(hr_hook, hr_host, "HRESULT mismatch for {bad:?}"); + assert_eq!((p_hook.is_null(), p_host.is_null()), (hr_hook < 0, hr_host < 0), "output for {bad:?}"); + // The PC runtime refuses these; vkd3d-proton (under Wine) accepts some of them. + assert!(hr_host < 0 || xcl::util::under_wine(), "expected queue failure: host={hr_host:#x}"); + for p in [p_hook, p_host].into_iter().filter(|p| !p.is_null()) { + drop(ID3D12CommandQueue::from_raw(p)); + } } let q_console_iid = GUID::from_u128(0x11223344_5566_7788_99aa_bbccddeeff06); diff --git a/crates/xcl/tests/d3d12_create_committed_resource.rs b/crates/xcl/tests/d3d12_create_committed_resource.rs index 9f2d9694ec..c8c36f9a6c 100644 --- a/crates/xcl/tests/d3d12_create_committed_resource.rs +++ b/crates/xcl/tests/d3d12_create_committed_resource.rs @@ -167,8 +167,13 @@ fn committed_resources_match_host_driver_desc_and_status() { let (mut p_host, mut p_hook) = (std::ptr::null_mut(), std::ptr::null_mut()); let hr_host = host(dev, &props, D3D12_HEAP_FLAG_NONE, &desc.pc, D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), riid, &mut p_host); let hr_hook = hooked(dev, &props, D3D12_HEAP_FLAG_NONE, &desc.pc, D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), riid, &mut p_hook); - assert!(hr_host < 0 && p_host.is_null(), "{label}: expected host failure, got {hr_host:#x}"); - assert!(hr_hook < 0 && p_hook.is_null(), "{label}: expected hooked failure, got {hr_hook:#x}"); + assert_eq!(hr_hook < 0, hr_host < 0, "{label}: hooked {hr_hook:#x}, host {hr_host:#x}"); + assert_eq!((p_hook.is_null(), p_host.is_null()), (hr_hook < 0, hr_host < 0), "{label}: output"); + // The PC runtime refuses these; vkd3d-proton (under Wine) accepts some of them. + assert!(hr_host < 0 || xcl::util::under_wine(), "{label}: expected host failure, got {hr_host:#x}"); + for p in [p_hook, p_host].into_iter().filter(|p| !p.is_null()) { + drop(ID3D12Resource::from_raw(p)); + } } } } diff --git a/crates/xcl/tests/d3d12_create_placed_resource.rs b/crates/xcl/tests/d3d12_create_placed_resource.rs index 312c93b4ec..1947f31280 100644 --- a/crates/xcl/tests/d3d12_create_placed_resource.rs +++ b/crates/xcl/tests/d3d12_create_placed_resource.rs @@ -208,12 +208,15 @@ fn create_placed_errors_and_console_iid_fallback() { assert!(p_hook.is_null() && p_host.is_null()); } - // Null desc returns error without dereferencing. - let (mut p_hook, mut p_host) = (std::ptr::null_mut(), std::ptr::null_mut()); - let hr_hook = hooked(dev, heap.as_raw(), 0, std::ptr::null(), D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), &iid, &mut p_hook); - let hr_host = host(dev, heap.as_raw(), 0, std::ptr::null(), D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), &iid, &mut p_host); - assert!(hr_hook < 0 && hr_host < 0, "expected failure on null desc: hook={hr_hook:#x}, host={hr_host:#x}"); - assert!(p_hook.is_null() && p_host.is_null()); + // Null desc returns error without dereferencing. (vkd3d-proton, under Wine, dereferences it and + // the process ends.) + if !xcl::util::under_wine() { + let (mut p_hook, mut p_host) = (std::ptr::null_mut(), std::ptr::null_mut()); + let hr_hook = hooked(dev, heap.as_raw(), 0, std::ptr::null(), D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), &iid, &mut p_hook); + let hr_host = host(dev, heap.as_raw(), 0, std::ptr::null(), D3D12_RESOURCE_STATE_COMMON, std::ptr::null(), &iid, &mut p_host); + assert!(hr_hook < 0 && hr_host < 0, "expected failure on null desc: hook={hr_hook:#x}, host={hr_host:#x}"); + assert!(p_hook.is_null() && p_host.is_null()); + } // Unknown console IID fails on host with E_NOINTERFACE; XCL falls back to ID3D12Resource. let console_iid = GUID::from_u128(0x11223344_5566_7788_99aa_bbccddeeff03); diff --git a/crates/xcl/tests/d3d12_query_and_command_signature.rs b/crates/xcl/tests/d3d12_query_and_command_signature.rs index 6c6dd18b17..94eaab5c23 100644 --- a/crates/xcl/tests/d3d12_query_and_command_signature.rs +++ b/crates/xcl/tests/d3d12_query_and_command_signature.rs @@ -64,8 +64,13 @@ fn create_query_heap_matches_host_driver() { let (mut p_hook, mut p_host) = (std::ptr::null_mut(), std::ptr::null_mut()); let hr_hook = hooked(dev, &bad, &iid, &mut p_hook); let hr_host = host(dev, &bad, &iid, &mut p_host); - assert!(hr_hook < 0 && hr_host < 0, "expected failure for {bad:?}: hook={hr_hook:#x}, host={hr_host:#x}"); - assert!(p_hook.is_null() && p_host.is_null()); + assert_eq!(hr_hook, hr_host, "HRESULT mismatch for {bad:?}"); + assert_eq!((p_hook.is_null(), p_host.is_null()), (hr_hook < 0, hr_host < 0), "output for {bad:?}"); + // The PC runtime refuses these; vkd3d-proton (under Wine) accepts some of them. + assert!(hr_host < 0 || xcl::util::under_wine(), "expected failure for {bad:?}: host={hr_host:#x}"); + for p in [p_hook, p_host].into_iter().filter(|p| !p.is_null()) { + drop(ID3D12QueryHeap::from_raw(p)); + } } // Unknown console IID fails on host with E_NOINTERFACE; XCL falls back to ID3D12QueryHeap. @@ -123,8 +128,13 @@ fn create_command_signature_matches_host_driver() { let (mut p_hook, mut p_host) = (std::ptr::null_mut(), std::ptr::null_mut()); let hr_hook = hooked(dev, &desc, std::ptr::null_mut(), &iid, &mut p_hook); let hr_host = host(dev, &desc, std::ptr::null_mut(), &iid, &mut p_host); - assert!(hr_hook < 0 && hr_host < 0, "expected failure: hook={hr_hook:#x}, host={hr_host:#x}"); - assert!(p_hook.is_null() && p_host.is_null()); + assert_eq!(hr_hook, hr_host, "HRESULT mismatch for an invalid signature"); + assert_eq!((p_hook.is_null(), p_host.is_null()), (hr_hook < 0, hr_host < 0), "output for an invalid signature"); + // The PC runtime refuses these; vkd3d-proton (under Wine) accepts some of them. + assert!(hr_host < 0 || xcl::util::under_wine(), "expected failure: host={hr_host:#x}"); + for p in [p_hook, p_host].into_iter().filter(|p| !p.is_null()) { + drop(ID3D12CommandSignature::from_raw(p)); + } } // Unknown console IID fails on host with E_NOINTERFACE; XCL falls back to ID3D12CommandSignature.