diff --git a/crates/xcl/src/hle/d3d12x/dxgi_device.rs b/crates/xcl/src/hle/d3d12x/dxgi_device.rs index cc2457e..9cafaf3 100644 --- a/crates/xcl/src/hle/d3d12x/dxgi_device.rs +++ b/crates/xcl/src/hle/d3d12x/dxgi_device.rs @@ -2,6 +2,7 @@ //! (device → IDXGIDevice1 → GetAdapter → EnumOutputs, the output SetFrameIntervalX takes – //! as Microsoft's public GDK samples do). A PC D3D12 device is not, so a small object answers //! IDXGIDevice / 1 / 2 with the device's real adapter; every other interface is the device's. +//! Console code only (`real::dev_qi_x`): DXGI asks the device the same and needs the PC answer. use std::ffi::c_void; use std::sync::atomic::{AtomicI32, AtomicU32, AtomicU64, Ordering}; diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index d783261..6e6a6ed 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -581,6 +581,7 @@ fn console_slots(kind: Kind) -> Vec<(usize, usize)> { match kind { Kind::Device => { vec![ + (0, dev_qi_x as usize), (8, x::create_command_queue_x as usize), (9, x::create_command_allocator_x as usize), (10, x::create_graphics_pso_pc as usize), @@ -1225,18 +1226,6 @@ unsafe extern "system" fn qi_override(this: *mut c_void, riid: *const GUID, ppv: let f: QiFn = std::mem::transmute(orig_fn(this, 0)); let hr = f(this, riid, ppv); if hr == E_NOINTERFACE && !riid.is_null() { - // the console device is also an IDXGIDevice (`dxgi_device`) - let iid: windows::core::GUID = std::mem::transmute(*riid); - if super::dxgi_device::answers(&iid) && !ppv.is_null() { - let device: GUID = std::mem::transmute(ID3D12Device::IID); - let mut d = std::ptr::null_mut(); - if f(this, &device, &mut d) >= 0 && !d.is_null() { - let release: RefFn = std::mem::transmute(orig_fn(d, 2)); - release(d); - *ppv = super::dxgi_device::create(this); - return S_OK; - } - } let s = layout::guid_string(&*riid); if UNKNOWN_IIDS.lock().unwrap().insert(s.clone()) { crate::xlog_warn!("D3D12.X: QueryInterface({s}) – interface unknown on the PC (console-only?)"); @@ -1245,6 +1234,17 @@ unsafe extern "system" fn qi_override(this: *mut c_void, riid: *const GUID, ppv: hr } +/// device #0 QueryInterface for console code: the console device is also an IDXGIDevice +/// (`dxgi_device`). Only the title gets it – DXGI asks a D3D12 device the same while creating +/// a swap chain and must keep getting the PC answer. +unsafe extern "system" fn dev_qi_x(this: *mut c_void, riid: *const GUID, ppv: *mut *mut c_void) -> HRESULT { + if !riid.is_null() && !ppv.is_null() && super::dxgi_device::answers(&std::mem::transmute::(*riid)) { + *ppv = super::dxgi_device::create(this); + return S_OK; + } + qi_override(this, riid, ppv) +} + fn pc_iid(kind: Kind) -> GUID { layout::parse_guid(layout::find(kind.base()).map(|i| i.iid).unwrap_or("")) }