Repository navigation
D3D12.X: depth buffers that shaders write get a twin for their UAVs (#970) - #1063
IvyNotFound wants to merge 2 commits into
Conversation
|
Independent review and local GPU test of commit Confirmed code findings
Tested
Not tested
AI use
|
3ef1119 to
0322514
Compare
|
Thanks for the review. Points 1–3 were right; fixed in
Point 4 stays as it is in this PR: depth buffers from the other creation paths fall back to DEPTH_WRITE, listed under Not tested; the retail title's come through At AI use: Claude Code (Claude Opus 5.5) checked the findings against the code, wrote the fixes and this reply, and ran the tests. |
Hardware test report — commit
|
|
Independently tested 0322514 on an RTX 5060 Ti with NVIDIA driver 616.92. The existing depth_twin tests passed 5/5 on the clean PR head. With a local test-only D32 extension, all 6 passed with zero skips. After GPU fence completion, all 2,048 texels read back as 0.25 after the D32_FLOAT depth clear copied to the R32_FLOAT UAV twin, and as 0.75 after the UAV write copied back to the depth texture. I verified the actual D3D12 adapter by LUID. The debug-layer rerun matched both values, but the debug interface returned 0x887A002D, so debug-layer messages were unavailable. I can share the synthetic D32 fixture if you’d like to include it. Codex (GPT-6) assisted with testing and reporting. |
0322514 to
c1af15d
Compare
|
A regression run under Wine on Linux, on a retail title. Tested
Regression run main (first run): this PR: The last Not tested
AI use
|
…#970) A console depth buffer that shaders write too has no ALLOW_UNORDERED_ACCESS on the PC (pc_resource_desc drops it) and its UAVs are null views, so the writes are lost. The title's barriers that use such a resource as a UAV are now counted and logged (the first 8, then every power of two): - transitions from or to UNORDERED_ACCESS and UAV barriers naming it, both for PC-format lists (resource_barrier_x) and console-recorded ones (console_list replay); - enhanced texture barriers (xcl-dev#146, D3D12_BARRIER_GROUP) with the UNORDERED_ACCESS layout or access. XCL still turns xcl-dev#146 into one global UAV barrier; only the description is read here. The null-view warning gives its total instead of stopping at 4. Measured on the retail title of xcl-dev#505 (RTX 5080, 300 s runs, A at 15 s): no legacy barrier touches these resources; enhanced barriers move D16 shadow maps (768x768x6, 1024x1024, 512x512) into or out of the UNORDERED_ACCESS layout once the world starts loading (62-64 s; 12 in a run with every one logged). No behaviour change: every barrier goes to the PC as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cl-dev#970) A console depth buffer that is also a UAV has no ALLOW_UNORDERED_ACCESS on the PC and its UAVs were null views: what the title's shaders wrote there was lost (the retail title of xcl-dev#505 moves its D16 shadow maps into the UNORDERED_ACCESS layout before it renders depth into them). With XCL_DEPTH_UAV_TWINS=1, such a depth buffer of one plane (R16 / R32 typeless) gets a twin: a texture of the same format and size with unordered access and no depth, kept as the depth buffer's private data. Its UAVs are views of the twin, and at the title's enhanced barriers (xcl-dev#146) into the UNORDERED_ACCESS layout the depth buffer is copied to the twin, at those out of it the twin back (in console-recorded lists the copies are recorded in the stream). XCL applies none of the title's enhanced barriers, so the copies' transitions start from the PC state the depth buffer was made in (kept at CreatePlacedResourceX; DEPTH_WRITE when not known). Depth and stencil formats keep null views: the PC has no UAV format for them. Off by default: without the variable nothing changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
c1af15d to
21aa52c
Compare
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
|
Nothing has happened on this PR for 3 days, so it is marked |
|
This is stacked on #1027 (its first commit) and adds AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
Closing as superseded: this change is already on Two independent checks found this: Foniass's close list on #1607 and ours against current AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents. |
Stacked on #1027; only the top commit (
21aa52c) belongs here. Part of #970: the second step planned there, off by default.A console depth buffer that shaders write too has no
ALLOW_UNORDERED_ACCESSon the PC, and its UAVs were null views, so what the title's shaders wrote there was lost. WithXCL_DEPTH_UAV_TWINS=1, such a depth buffer of one plane (R16 / R32 typeless) gets a twin: a texture of the same format and size with unordered access and no depth, kept as the depth buffer's private data (released with it). Its UAVs are views of the twin, and at the title's enhanced barriers (#146) into theUNORDERED_ACCESSlayout the depth buffer is copied to the twin, at those out of it the twin back. Without the variable nothing changes.XCL applies none of the title's enhanced barriers, so on the PC such a depth buffer stays in the state it was made in: the copies' transitions start from that state (kept at
CreatePlacedResourceX, DEPTH_WRITE when not known). Depth + stencil formats keep null views: the PC has no UAV format for them.What is in it
crates/xcl/src/hle/d3d12x/depth_twin.rs(new):enabled,twin_desc,twin_for_uav/twin_of(private data),note_created/forget,twin_uav_desc(a typed view for a UAV made without a description),sync(transitions + CopyResource either way; no transition of the depth buffer when it is in the copy's state already). Tests:a_d16_or_d32_depth_buffer_gets_a_twin_with_unordered_access,a_depth_buffer_in_the_copys_state_is_not_moved_to_it,a_uav_without_a_description_is_a_typed_view_of_the_twin,a_released_depth_buffers_state_is_forgotten; GPU testgpu_a_uav_write_to_a_depth_buffer_goes_through_its_twin(a D16 depth buffer's clear reaches the twin at the barrier into UAV, a write through the twin's UAV reaches the depth buffer at the barrier out of it; fails without the twin).crates/xcl/src/hle/d3d12x/real.rs:dev_create_uav_xmakes the view on the twin instead of a null view (typed when the title gave no description);res_releaseforgets the state of a released depth buffer.crates/xcl/src/hle/d3d12x/list_x.rs:note_depth_uav_barrier_groupsreturns the copies a Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 call needs (twin_copy);uav_barrier_xruns them after its global UAV barrier. The barrier log says whether the UAVs are null views or views of the twin.crates/xcl/src/hle/d3d12x/console_list.rs: the same for console-recorded lists, recorded in the stream (TWIN_COPY_MARKER) and run at replay.crates/xcl/src/hle/d3d12x/device_x.rs:create_placed_resource_xkeeps the state such a depth buffer is made in.Tested
cargo test --workspace --no-fail-fast -- --test-threads=4at21aa52c(rebased ontomainb7aa9f3) withXCL_SAMPLE_RPF,_DLLS,_TTPF,_BVH4,_BK2,_AWCset: 777 passed, 0 failed, 41 ignored;SKIPPED(no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware. Before the rebases, at0322514, one run had the Tests: placed_title_textures_share_vram_and_preserve_pixels fails now and then at its cubemap reuse check (main 9ce2070) #718 flake (720 passed, 3 failed).scripts/smoke.ps1,XCL_PRESS_A_AT=15:mainb7aa9f3and this head21aa52c, after the rebase);XCL_DEPTH_UAV_TWINS=1at0322514(before the rebase, same code): 256+ D16 shadow maps get twins at ~9 s (the 4 depth + stencil views stay null); the enhanced barriers into and out ofUNORDERED_ACCESSfrom ~66 s copied depth → twin and back 1024+ times; no device removal, the run ends by itself (exit 0x0, 1320 frames); peak commit 32058 MB (main's 60 s run: 27340 MB, its 300 s run: 30308 MB).XCL_DEPTH_UAV_TWINS=1at3ef1119(before the review fixes): the same twins and copies, no device removal, it ends in the title's "GPU Loc Sig" abort at 95.5 s asmaindoes.Regression run
main:
this PR:
Not tested
CreatePlacedResourceX: their copies assume DEPTH_WRITE, the state D3D12.X: depth+UAV buffers on the PC fallback paths start as depth writes #1353 now gives them thereUNORDERED_ACCESS(D3D12.X & GPU: raytracing SRVs, 64-bit multi-window BVH traversal, and title-list BVH builder slots #26): counted by D3D12.X: count the barriers that use a depth buffer as a UAV (#970) #1027, not copied – the title of Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505 does not use them for these resourcesAI use
🤖 Generated with Claude Code