D3D12.X: Xbox D16S8 depth formats and depth buffers that are also UAVs #163
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!163
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/163/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Sr-0w on GitHub · 2026-11-23 18:03 UTC · original
Sr-0w:xbox-depth-uav→main· +180 −4 · 2 files · 3 commits · closed without mergingProblem
The retail title (retail, GDK) stops on two assertions while creating its render targets:
+0x344196: its 2560x1440 depth buffer isDXGI_FORMAT_D16_UNORM_S8_UINT(118, console only) withALLOW_DEPTH_STENCIL | ALLOW_UNORDERED_ACCESS.GetResourceAllocationInforeturned no size, because the PC driver refuses both the format and the depth + UAV pair.+0x14a6390: its 768x768x6 shadow maps (D16, depth + UAV) are placed with theUNORDERED_ACCESSinitial state, and the PC refuses that state (0x80070057).Change
pc_format: 118 / 119 / 120 (D16S8 family) → 45 / 46 / 47 (D24S8 family). Applied inpc_resource_descand inpc_topology_type(pipelines' DSV/RTV formats; the driver refused the retail title's pipelines with DSV 118).pc_resource_desc: a depth-stencil resource dropsALLOW_UNORDERED_ACCESS(a plain UAV texture keeps it).create_placed_resource_x: such a depth buffer'sUNORDERED_ACCESSinitial state becomesDEPTH_WRITE.Overlaps with the format part of #150 (D16S8 → D24S8). Whichever lands first, I'll rebase the other.
Result
The retail title goes past both assertions. On top of
956a476it then runs at 30 fps likemain(checked:main+ this PR, 600 frames at 29.4 fps after 36 s).Test plan
cargo test --release -p xcl --lib: newconsole_depth_buffers_become_pc_onespasses; onlygpu_wave64_ps_whole_wave_reductionsfails, as onmain+0x344196/+0x14a6390🤖 Generated with Claude Code
@Sr-0w on GitHub · 2026-11-23 19:19 UTC · original
New commit
634c423: a null UAV for a resource the PC has without unordered access. GTA VI still creates UAVs of its 768x768 D16 shadow maps (whose UAV flag this PR drops). The driver was handed an invalid view (debug layer:CreateUnorderedAccessView … did not specify ALLOW_UNORDERED_ACCESS, id 340), and the device was removed (0x887a0001) once a dispatch used it. The console descriptor XCL writes for translated shaders is unchanged; only the PC descriptor becomes a null view of the same dimension.🤖 Generated with Claude Code
@YeetSkillet on GitHub · 2026-11-23 19:48 UTC · original
At
634c423, a non-null optimized clear can still make depth-buffer creation fail. The resource description maps Xbox D16S8 (118) to PC D24S8 (45), but the address-based placement and its committed fallback both pass the originalD3D12_CLEAR_VALUE.Format. Call sitesI tested a synthetic 16×16 texture with both
CreatePlacedResourceandCreateCommittedResourceon an RTX 3060 Ti and on WARP. Both APIs and both adapters gave the same results. The depth and stencil values were 0.625 and 0x5a throughout the depth tests.The downstream fork already maps the clear on its address-based and committed paths. The attached patch for this PR also covers the heap-and-offset placement retry and its committed fallback. It maps the clear’s own view format, which preserves valid typed clears on typeless resources. Downstream change · D3D12 clear format rules
The patch applies cleanly to
634c423and includes a Rust regression test. The Python probe ran all 24 native checks using the Windows system libraries. The Rust test and the effect on in-game rendering still need verification.git apply xcl-163-optimized-clear.patch.txt. xcl-163-optimized-clear.patch.txtpython check-d3d12-clear.py.txt. check-d3d12-clear.py.txt@Sr-0w on GitHub · 2026-11-23 20:00 UTC · original
New commit: the PC's formats for everything that refers to a console depth buffer, not only the resource. With the D3D12 debug layer, GTA VI showed each of these, each followed by a device removal:
E_INVALIDARG, then the title's assertion;CreateDepthStencilViewwith format 118 (now hooked) → removal ~55 s in;R32G8X24_TYPELESS) as R32_FLOAT, including the SRV XCL makes next to a texture UAV → now R24_UNORM_X8 / X24_G8_UINT / R32_FLOAT_X8X24 / X32_G8X24_UINT with the right plane slice (depth_srv_format, unit test added);Overlap note: #169 also remaps DSV format 118 → 45. The two can be combined; #169's version covers PSOs, this one covers resources, clear values and views.
🤖 Generated with Claude Code
@gw1337x on GitHub · 2026-11-23 20:20 UTC · original
Setup: AMD Radeon RX 7800 XT (RDNA3, 16 GB), driver 32.0.32015.7029, 32 GB RAM, Windows 11 Pro 26200, GTA VI retail,
XCL_NETWORK=0, release build.Test branch:
main956a476+ #170 (incl. #163 @634c423) + #162 @641f551+ #168 @070a737+xg.rsof #169 + #176 + #164.Tested
634c423with the D3D12 debug layer (Agility SDK 1.620.2,XCL_D3D12_DEBUG=1). The resources become D24S8, but views of them still carry the console formats, and that is what removed the device on this machine (0x887a0001, ~33–50 s):What fixed each (all only on the copy handed to the PC driver; the console descriptor XCL writes is unchanged):
CreateDepthStencilViewisn't overridden, so the game's DSV in 118 goes straight to the driver. Added aCreateDepthStencilViewoverride, and pass SRV / UAV / RTV / DSV descs throughpc_format(the DXGI format is the first field of all four).R24_UNORM_X8_TYPELESS/R32_FLOAT_X8X24_TYPELESS(plane 0), stencil (R8_UINT) →X24_TYPELESS_G8_UINT/X32_TYPELESS_G8X24_UINT(plane 1). Needed indev_create_srv_xand in the SRV thatdev_create_uav_xwrites fordim == 4.634c423copies the game's desc,PlaneSlice: 1included (a stencil-plane UAV). A null view has one plane, so plane 0.Also confirming @YeetSkillet's finding: the clear value has to go through
pc_formattoo. Here a 1024x1024 D16S8 placed resource with an optimized clear in 118 came backE_INVALIDARGand the game stopped on its assertion at+0x131a2ad. Fixed by mapping the clear value's format at the top ofcreate_placed_resource_x.With 1–3 the debug layer shows none of these, and the "invalid call" removal is gone.
Patch (real.rs, ~100 lines)
🤖 Generated with Claude Code
@Kalmarv on GitHub · 2026-11-23 20:28 UTC · original
The stencil-plane alias still reaches the PC with plane 0. I tested PR head
595b2b7a8446d9bf912ae602547476adcb21ef50directly againstmainat956a476bf738a098f39df4f4c8acef682e43030f. Windows x64 MSVC, Rust 1.99.0, RTX 5070 Ti, driver 610.74, debug-profile lib tests, synthetic inputs.hle::d3d12x::tests, including PR tests where presentpc_resource_descon format 118 with flags 6The SRV probe creates a real 16×16
R24G8_TYPELESSdepth resource, callsdev_create_srv_xwith an explicit Texture2D view (format 120, PlaneSlice 0), and captures the descriptor at the native call boundary. Atcrates/xcl/src/hle/d3d12x/real.rs:1631,pc_view_deschas already changed 120 to 47. At line 3898,depth_srv_format(44, 47)returnsNone, so the caller skips the plane assignment. Deriving format and plane from the original descriptor, or assigning the plane even when the format already matches, would cover this case.The two tests copied verbatim from the PR cannot compile on main because their new helpers are absent. The last two rows use the same independently compiled probes on both revisions. The SRV probe captures arguments only. GPU sampling, retail content and merge-onto-main were outside this run. AI-assisted review.
@ivall on GitHub · 2026-11-23 20:57 UTC · original
Closing as covered on main - thanks, this chain is what got the title to its menu. On main (
38b05b7,eaa36b6) the retail game now reaches its first menu at 30 fps with ~19 GB of commit, checked on an RX 9070;cargo test --workspaceis green (548 unit tests). What main has: the D16S8 family (118-120) as R24G8_TYPELESS resources with the console's XG layouts; depth buffers in a typed depth format made typeless; no UAV flag on depth buffers (UAV initial state -> DEPTH_WRITE) and a null UAV for a resource without ALLOW_UNORDERED_ACCESS; clear values, DSVs and pipeline DSV formats mapped. The open point from the review is fixed there too: a stencil SRV gets plane 1 (device_x::pc_shader_view_format/stencil_view, unit testconsole_depth_buffers_and_their_views_are_the_pcs). Also, a D24S8 format in an SRV, or R16_UNORM of the D16S8 buffer, removed the device too, and so did a B5G5R5A1 UAV of a target the PC makes R8G8B8A8 (found with the debug layer).Pull request closed