From 68455269a8462ad0ee5e9f86b54e5f1bcc8387ae Mon Sep 17 00:00:00 2001 From: amazedturnip Date: Wed, 25 Nov 2026 13:38:49 -0600 Subject: [PATCH] Tests: pin the IDXGIDevice answers() contract The console IDXGIDevice object is the title's way to reach DXGI; pin its answers() contract: exactly the four DXGI GUIDs (IDXGIObject / IDXGIDevice / IDXGIDevice1 / IDXGIDevice2) are answered, ID3D12Device, IDXGIFactory4, ID3D12Resource and a zero GUID are not. The vtable contract is not reachable from an integration test without touching the runtime source (out of scope in this non_runtime_only mode), so only answers() is pinned. --- crates/xcl/tests/dxgi_device.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 crates/xcl/tests/dxgi_device.rs diff --git a/crates/xcl/tests/dxgi_device.rs b/crates/xcl/tests/dxgi_device.rs new file mode 100644 index 0000000000..7bf8596fa3 --- /dev/null +++ b/crates/xcl/tests/dxgi_device.rs @@ -0,0 +1,25 @@ +//! Pure, no-GPU contract test for the console IDXGIDevice object (`dxgi_device::answers`). +//! The object answers IDXGIObject / IDXGIDevice / IDXGIDevice1 / IDXGIDevice2 and nothing +//! else — the D3D12 interfaces, the DXGI factory, and a zero GUID all stay false. + +use windows::core::{GUID, Interface}; +use windows::Win32::Graphics::Direct3D12::{ID3D12Device, ID3D12Resource}; +use windows::Win32::Graphics::Dxgi::{IDXGIDevice, IDXGIDevice1, IDXGIDevice2, IDXGIFactory4, IDXGIObject}; + +use xcl::hle::d3d12x::dxgi_device::answers; + +#[test] +fn answers_true_for_the_four_dxgi_guids() { + assert!(answers(&IDXGIObject::IID), "IDXGIObject must be answered"); + assert!(answers(&IDXGIDevice::IID), "IDXGIDevice must be answered"); + assert!(answers(&IDXGIDevice1::IID), "IDXGIDevice1 must be answered"); + assert!(answers(&IDXGIDevice2::IID), "IDXGIDevice2 must be answered"); +} + +#[test] +fn answers_false_for_other_interfaces_and_zero_guid() { + assert!(!answers(&ID3D12Device::IID), "ID3D12Device must not be answered"); + assert!(!answers(&IDXGIFactory4::IID), "IDXGIFactory4 must not be answered"); + assert!(!answers(&ID3D12Resource::IID), "ID3D12Resource must not be answered"); + assert!(!answers(&GUID::from_u128(0)), "a zero GUID must not be answered"); +}