D3D12.X: draws that test a depth buffer left in UAV get its twin first #3480
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3480"
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?
Imported from ivall/xcl. Originally posted by Foniass on 2026-11-30T00:01:01Z.
Draft: this needs raylitebull's check (it is his amd-dev commit
0e68d606, adapted to main), and a run that reaches the case.A depth buffer that shaders write keeps those writes in a twin.
depth_uavcopies the twin into the depth plane only when the title moves the buffer out of UNORDERED_ACCESS. A draw that tests against the buffer before that, while the title leaves it in UNORDERED_ACCESS, tests the plane as it was before the shaders wrote. In a retail title's mirrors on amd-dev, the mirror showed the sky because of this.For a stretch that begins with a transition of the whole buffer into UNORDERED_ACCESS on a DIRECT list, the list now follows which side was written last and copies it into the other before the work that uses it:
These are whole-plane copies between states XCL already knows, so nothing bound on the list changes. A stretch without such a draw copies exactly as before.
Port onto main
Main now has depth twins on by default, stencil twins and parked D24S8 buffers (#3290).
DrawInstanced/DrawIndexedInstancedhooks, plus the title'sDispatch/DispatchX,ExecuteIndirect,DispatchMeshand UAV clears.set_compute_pipeline. On amd-dev that was the only hook, and only XCL's own passes call it, so the title's dispatches were never seen. Combined with the "plane is newer" mark after a draw, that would have dropped a later dispatch's twin writes.The switch and trace that came with it (
XCL_DEPTH_PLANE_NOW,XCL_TWIN_TRACE) are in the stacked follow-up.What is in it
crates/xcl/src/hle/d3d12x/depth_uav.rs:Owed/before_work/step, the plan changes, 4 new tests (3 from the original, adapted, and one for a buffer leaving UNORDERED_ACCESS in parts)crates/xcl/src/hle/d3d12x/list_x.rs:depth_twins_before_work, per-listdepth_owedcrates/xcl/src/hle/d3d12x/real.rs,bind.rs: the calls before draws, dispatches and UAV clearsTested
cargo test -p xcl --lib depth_uav: 23 passed, 0 failed. Two of the new tests fail with theplan_withchanges taken out.cargo test --workspace --no-fail-fast -- --test-threads=4on4a6f61bf, rebased on main86e86fcb(5070 Ti): 2893 passed, 0 failed, 51 ignored. SKIPPED: 28 notices, almost allno wave64(the others: no D3D12 debug layer, heap windows off, driver cache needs Developer Mode). The narrower runs listed here are from before the rebase.depth UAV twin #lines), but the new copies did not fire (none of their log lines), so the run is only a regression check.Regression run
main:
this PR:
Not tested
XCL_TWIN_TRACE=736shows it in a world run.XCL_TWO_PASS_BATCH=2;AI use
0e68d606.🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T08:05:59Z.
Closing: the case this fixes (a draw testing a depth buffer left in UAV before its twin is copied back) has not been seen on main; the copies never fired in the smoke run. Reopen with #3481 if a title is found to take this path (
XCL_TWIN_TRACEon #3481 is the tool to show it).AI-assisted: Claude Code (Claude Opus 5.5), posted by Foniass.
Pull request closed