From ca739fbf9440c888326805d2f5adef1a723d748b Mon Sep 17 00:00:00 2001 From: KOLESNiii <102358205+KOLESNiii@users.noreply.github.com> Date: Sat, 28 Nov 2026 14:02:50 +0000 Subject: [PATCH] D3D12.X: unmodelled console resource and counter-set creators fail visibly Device #45 and #77 (a resource whose planes and metadata sit at separate GPU addresses, with the PC or the console resource desc) and #82 (a performance-counter set) were logging stubs that returned S_OK without writing their out pointer, so a title went on with whatever its out variable held. They now return E_NOTIMPL with one log line each; #45 and #77 also null their out pointer (the last of their seven arguments). #82's out pointer position is not known, so nothing is written there. Co-Authored-By: Claude Opus 5.5 Assisted-by: Codex (exact model unavailable) --- crates/xcl/src/hle/d3d12x/device_x.rs | 54 +++++++++++++++++++++++++++ crates/xcl/src/hle/d3d12x/real.rs | 3 ++ 2 files changed, 57 insertions(+) diff --git a/crates/xcl/src/hle/d3d12x/device_x.rs b/crates/xcl/src/hle/d3d12x/device_x.rs index 4221fe40bf..3256cc0e11 100644 --- a/crates/xcl/src/hle/d3d12x/device_x.rs +++ b/crates/xcl/src/hle/d3d12x/device_x.rs @@ -570,6 +570,44 @@ pub(super) unsafe fn depth_bias_pso(dev: *mut c_void, base: usize, bias: DepthBi result } +/// Device methods XCL has no model for that create an object: a title sees E_NOTIMPL (and a null +/// object where the out pointer's place is known) instead of S_OK with nothing written. +fn not_implemented(slot: u32, what: &str) -> HRESULT { + static N: [AtomicU64; 3] = [const { AtomicU64::new(0) }; 3]; + let i = match slot { + 45 => 0, + 77 => 1, + _ => 2, + }; + if once(&N[i], 1) { + crate::xlog_warn!("D3D12.X: device #{slot} ({what}) is not implemented: E_NOTIMPL"); + } + E_NOTIMPL +} + +/// device #45: a resource whose planes / metadata sit at separate GPU addresses (addresses*, +/// resource desc*, state, clear value*, riid, out). +pub(super) unsafe extern "system" fn create_resource_at_planes_x(_this: *mut c_void, _addrs: usize, _desc: usize, _state: usize, _clear: usize, _riid: usize, out: *mut *mut c_void) -> HRESULT { + if !out.is_null() { + *out = std::ptr::null_mut(); + } + not_implemented(45, "resource at per-plane GPU addresses") +} + +/// device #77: as #45, with the console resource desc. +pub(super) unsafe extern "system" fn create_resource_at_planes_console_desc_x(_this: *mut c_void, _addrs: usize, _desc: usize, _state: usize, _clear: usize, _riid: usize, out: *mut *mut c_void) -> HRESULT { + if !out.is_null() { + *out = std::ptr::null_mut(); + } + not_implemented(77, "resource at per-plane GPU addresses, console desc") +} + +/// device #82: a performance-counter set (where its out pointer sits is not known, so nothing is +/// written). +pub(super) unsafe extern "system" fn create_counter_set_x(_this: *mut c_void) -> HRESULT { + not_implemented(82, "performance-counter set") +} + /// Apply one CreateDerivedPipelineStateX patch to a desc: part 0 = depth-stencil state, 1 = /// rasterizer state, 2 = blend state, 3 = sample mask. Ok(false): part 5 (seen on Fortnite, /// 0x30 bytes, meaning unknown) – not applied. Err: an unknown part. @@ -1662,6 +1700,22 @@ mod tests { assert_eq!(pc_initial_state_for_desc(0x6, 0x2, 0x8), 0x10); } + /// #45 / #77 / #82: the title sees a failure, and a null object where #45 / #77 put it, not + /// S_OK with its out pointer left as it was. + #[test] + fn unmodelled_object_creators_return_e_notimpl_and_a_null_object() { + unsafe { + let mut out = 0x1234usize as *mut c_void; + assert_eq!(create_resource_at_planes_x(std::ptr::null_mut(), 1, 2, 3, 4, 5, &mut out), E_NOTIMPL); + assert!(out.is_null()); + out = 0x1234usize as *mut c_void; + assert_eq!(create_resource_at_planes_console_desc_x(std::ptr::null_mut(), 1, 2, 3, 4, 5, &mut out), E_NOTIMPL); + assert!(out.is_null()); + assert_eq!(create_resource_at_planes_x(std::ptr::null_mut(), 0, 0, 0, 0, 0, std::ptr::null_mut()), E_NOTIMPL); + assert_eq!(create_counter_set_x(std::ptr::null_mut()), E_NOTIMPL); + } + } + #[test] fn derived_pipeline_patches_land_on_the_desc_parts() { use std::mem::{offset_of, size_of}; diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index fc78555403..fcbc33f157 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -1585,6 +1585,7 @@ fn console_slots(kind: Kind) -> Vec<(usize, usize)> { (38, x::get_copyable_footprints_x as usize), (41, x::create_command_signature_x as usize), (44, x::create_placed_resource_x as usize), + (45, x::create_resource_at_planes_x as usize), (48, x::create_command_queue_x as usize), (52, x::set_debug_flags_x as usize), (55, x::create_derived_pso_x as usize), @@ -1601,12 +1602,14 @@ fn console_slots(kind: Kind) -> Vec<(usize, usize)> { (74, x::register_page_pool_x as usize), (75, x::unregister_page_pool_x as usize), (76, dev_create_committed_resource_x as usize), + (77, x::create_resource_at_planes_console_desc_x as usize), // frame pacing (SetFrameIntervalX, ScheduleFrameEventX, WaitFrameEventX, // GetFrameStatisticsX) (78, super::frame::set_frame_interval_x as usize), (79, super::frame::schedule_frame_event_x as usize), (80, super::frame::wait_frame_event_x as usize), (81, super::frame::frame_statistics_x as usize), + (82, x::create_counter_set_x as usize), (86, x::create_pipeline_state_x as usize), (108, x::get_resource_allocation_info2_x as usize), (127, dev_create_committed_resource_layout_x as usize),