From c3d350a5729d7559d00554facc622c6d1c1b9bb6 Mon Sep 17 00:00:00 2001 From: 0x6461726B <82672662+0x6461726B@users.noreply.github.com> Date: Tue, 24 Nov 2026 04:14:26 +0200 Subject: [PATCH] D3D12.X: promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT PC D3D12 rejects ALLOW_RENDER_TARGET and ALLOW_UNORDERED_ACCESS on DXGI_FORMAT_R9G9B9E5_SHAREDEXP (67) with E_INVALIDARG (0x80070057). In Series S (Lockhart) mode, a retail title creates a 1920x1080 format-67 target with flags 0x300005 during startup and aborts on the error. Promote format-67 resources with RT/UAV flags and their RTV/UAV/SRV views to DXGI_FORMAT_R11G11B10_FLOAT (26, same 32 bpp unsigned HDR float with full PC RTV/UAV/SRV support), while keeping sampled-only format-67 textures unchanged. --- crates/xcl/src/hle/d3d12x/device_x.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/xcl/src/hle/d3d12x/device_x.rs b/crates/xcl/src/hle/d3d12x/device_x.rs index 2af03a02d..1c94a9439 100644 --- a/crates/xcl/src/hle/d3d12x/device_x.rs +++ b/crates/xcl/src/hle/d3d12x/device_x.rs @@ -674,6 +674,13 @@ pub fn pc_resource_desc(x: &[u8; 0x38]) -> [u8; 0x38] { if matches!(format, 86 | 115) && flags & 5 != 0 { d[0x20..0x24].copy_from_slice(&28u32.to_le_bytes()); } + // R9G9B9E5_SHAREDEXP targets / UAVs: PC D3D12 forbids ALLOW_RENDER_TARGET and + // ALLOW_UNORDERED_ACCESS on format 67 (Series S 1920x1080 target, flags 0x300005: + // E_INVALIDARG) – R11G11B10_FLOAT is the same 32 bpp unsigned HDR float format with full + // PC RTV/UAV/SRV support. Sampled-only R9G9B9E5 textures stay format 67. + if format == 67 && flags & 5 != 0 { + d[0x20..0x24].copy_from_slice(&26u32.to_le_bytes()); + } // a depth buffer the console also lets shaders write (a retail game's: ALLOW_DEPTH_STENCIL | // ALLOW_UNORDERED_ACCESS): the PC refuses the pair – the depth buffer stays if flags & 2 != 0 { @@ -711,10 +718,11 @@ fn depth_typeless(f: u32) -> Option { } /// The format of a render target / depth view or pipeline on the PC: `pc_view_format`, and a -/// B5G5R5A1 / B4G4R4A4 target is R8G8B8A8 (`pc_resource_desc`). +/// B5G5R5A1 / B4G4R4A4 target is R8G8B8A8, an R9G9B9E5 target is R11G11B10_FLOAT (`pc_resource_desc`). pub fn pc_target_format(f: u32) -> u32 { match f { 86 | 115 => 28, + 67 => 26, f => pc_view_format(f), } } @@ -737,6 +745,8 @@ pub fn pc_shader_view_format(resource: u32, view: u32) -> u32 { (53 | 55, 0 | 53 | 55) => 56, // a target made R8G8B8A8 (`pc_resource_desc`) (28, 86 | 115) => 28, + // a target made R11G11B10_FLOAT (`pc_resource_desc`) + (26, 67) => 26, (_, v) => v, } } @@ -1063,6 +1073,11 @@ mod tests { x[0x20] = 86; // B5G5R5A1 target that is also a UAV x[0x30..0x34].copy_from_slice(&0x5u32.to_le_bytes()); assert_eq!(desc(&x), (28, 0x5)); + x[0x20] = 67; // R9G9B9E5_SHAREDEXP target + UAV + x[0x30..0x34].copy_from_slice(&0x30_0005u32.to_le_bytes()); + assert_eq!(desc(&x), (26, 0x5)); + x[0x30..0x34].copy_from_slice(&0x0u32.to_le_bytes()); // sampled-only R9G9B9E5 stays format 67 + assert_eq!(desc(&x), (67, 0)); // views: a D24S8 format or R16_UNORM of the D16S8 buffer read depth; stencil formats plane 1 assert_eq!(pc_shader_view_format(44, 45), 46); assert_eq!(pc_shader_view_format(44, 56), 46); @@ -1073,7 +1088,9 @@ mod tests { assert_eq!(pc_shader_view_format(19, 62), 22); assert_eq!(pc_shader_view_format(28, 86), 28); assert_eq!(pc_shader_view_format(86, 86), 86, "a B5G5R5A1 texture that stayed one"); - assert_eq!((pc_target_format(86), pc_target_format(118), pc_view_format(117)), (28, 45, 10)); + assert_eq!(pc_shader_view_format(26, 67), 26); + assert_eq!(pc_shader_view_format(67, 67), 67, "a sampled-only R9G9B9E5 texture that stayed one"); + assert_eq!((pc_target_format(86), pc_target_format(67), pc_target_format(118), pc_view_format(117)), (28, 26, 45, 10)); } #[test]