D3D12.X: IDXGIDevice only for console code

DXGI asks a D3D12 device for IDXGIDevice / IDXGIObject while creating a
swap chain; answering it with the console's DXGI device object made the
swap chain creation crash now and then (1 of 11 e2e runs). The device's
QueryInterface is now split like the other console slots: the title gets
the IDXGIDevice, DXGI and XCL the PC answer (25 of 25 e2e runs pass).
This commit is contained in:
ivall
2026-11-21 19:43:02 +01:00
parent 3f68644c5e
commit fae7655754
2 changed files with 13 additions and 12 deletions
+1
View File
@@ -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};
+12 -12
View File
@@ -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::<GUID, windows::core::GUID>(*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(""))
}