D3D12.X: translate list #146 Enhanced Barriers to legacy ResourceBarrier #1018
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1025"
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 raylitebull on 2026-11-24T10:27:42Z.
Translate console command list slot
#146(ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups)) into legacyResourceBarriercalls instead of emitting only a wildcard UAV barrier. Modern Scarlett titles that create resources with barrier layouts (device#127/#133) rely on#146for all render-target, depth, shader-resource, and copy layout transitions; dropping those transitions left targets stuck in their initial states.(The diff is ~950 lines as one self-contained module: ~520 lines for parsing, layout mapping, state tracking, and legacy barrier translation, plus ~395 lines of unit and GPU tests.)
What is in it
crates/xcl/src/hle/d3d12x/enhanced_barrier.rs: parsesD3D12_BARRIER_GROUP(GLOBAL,TEXTURE,BUFFER) withreadable()guards (falling back to the legacy global UAV barrier on unparseable calls), mapsD3D12_BARRIER_LAYOUT0..=31(including0x1F) plus access-bit fallback for console-only layouts> 0x1F, tracks whole-resource states forUNDEFINEDbefore layouts, emits aliasing barriers forUNDEFINEDplaced textures, skipsUNORDERED_ACCESSon non-UAV textures and states disallowed on compute/copy lists, forwards emitted transitions totitle_textures::note_transitions, and includes 13 unit + GPU tests.crates/xcl/src/hle/d3d12x/device_x.rs,real.rs,list_x.rs,mod.rs: wire slot#146toenhanced_barrier::barrier_x, align#127/#133initial layout states with texture-vs-buffer awareness, record initial/legacy barrier states, and clear tracked state onres_release.Tested
rustc 1.99.1 (58cf8f9c3 2026-10-13), release + test profilescargo test --workspace -- --test-threads=4: 741 passed, 0 failed, 41 ignored (0 SKIPPED GPU tests)Regression run
main:
PR:
Not tested
AI use
origin/main, cleaned up unused helper/constant warnings, ran the full GPU test suite and 60 s smoke regression check, and drafted this description.Imported from ivall/xcl. Originally posted by poucosaudavel on 2026-11-24T11:01:31Z.
Test report for the exact head
1ecefdda3b4627ab8160845942f27ab4e75ce0c5, since Not tested lists NVIDIA GPUs.Tested
main(6efdabcdaac93ce5cc123a85e85deba5d49cb294) as the baselinecargo build --workspace, thencargo test --workspace -- --test-threads=4:hle::d3d12x::enhanced_barrier::tests::*; no test present on the base is missing or failing on the PR.enhanced_barriers_move_a_render_target_on_the_gpuran on the NVIDIA adapter (the log shows backendrealon the RTX 5060 Ti) and passed.gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_maskandgpu::recomp::tests::gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
scripts/smoke.ps1regression run on a retail title: this covers the test suite only.AI use
Imported from ivall/xcl. Originally posted by itsonewi on 2026-11-24T11:06:51Z.
Review: COMMENTED
Global barriers with
AccessBefore = NO_ACCESSemit nothingAccess::orders_earlier_work()returns false whenaccess_before == NO_ACCESS, so theItem::Globalarm oftranslatecontributes no UAV barrier in that case. A global barrier is the enhanced-barrier form of a legacy NULL UAV barrier (D3D12 enhanced-barriers spec, "UAV Barriers": "Legacy Resource Barriers support NULL UAV barriers. These are equivalent to enhanced Barrier global barriers."), andSyncBefore = ALLwithAccessBefore = NO_ACCESSis valid: onlySyncBefore = NONErequiresAccessBefore = NO_ACCESS, not the reverse.The old
#146handler (list_x::uav_barrier_x) always emitted a NULL UAV barrier, so an XboxBvhBuilder global barrier that carries no access bits now emits nothing. The 60 s "Game Assets" smoke run does not reach the BVH builder, and the NVIDIA suite run in the thread covers the tests, not that path.Could you either emit a UAV barrier for a global barrier with
SyncBefore != SYNC_NONE(or for every global barrier, as before), or explain why a no-access global barrier needs no legacy barrier? The testunordered_access_gets_one_uav_barrier_for_all_resourcescoversAccessBefore = 0x10, and theNO_ACCESScase only withSyncBefore = NONE; a test withSyncBefore = ALL, AccessBefore = NO_ACCESSwould pin the answer.The rest of what I checked reads correctly: the struct offsets, the layout table, the subresource index formula, and the UAV-before/after rules match the spec.
Prepared with AI assistance; I checked each point against the code and the D3D12 enhanced-barriers spec.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T11:21:53Z.
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti + Radeon iGPU; Rust stable MSVC, debug.
cargo test -p xcl --lib enhanced: 14 passed, 0 failed — allenhanced_barrier::tests, including the GPU testenhanced_barriers_move_a_render_target_on_the_gpu(ran on the default adapter, RTX 3060 Ti).AI use: test runs by Devin (Cognition, SWE-2); no code changes.
Imported from ivall/xcl. Originally posted by IvyNotFound on 2026-11-24T14:30:50Z.
Retail run into world loading on an RTX 5080:
1ecefddmerged ontomain930e8b4– no crash or device removal, the barriers are translated, the frames after loading stay black as onmain, and the #505 GPU-wait stalls come at least as oftenTested
main930e8b4+ this PR's head1ecefdd(clean merge, local commitbbace0e).cargo test -p xcl --lib enhanced(debug): 14 passed, 0 failed (the GPU test ran on the RTX 5080).scripts/smoke.ps1 -Seconds 140,XCL_PRESS_A_AT=15,XCL_PSO_WAIT_MS=50(so it gets past the firstListX #101into world loading),XCL_FRAME_DUMP=2. Two runs of the PR, compared with one ofmainwith the same settings.main930e8b4GPU queue.Wait … did not complete within 5000 msBarrier: 1 groups, 2 barriers (2 texture) → 2 legacy barriersat 3.1 s.Barrier: N transitions a list of type 2 cannot make – left out(N = 1, 4, 7).main(#505).mainrun. My earliermainruns of the same title reached up to 43 GB peak commit and 13–34 timeouts (https://github.com/ivall/xcl/issues/505#issuecomment-7130913073), so two runs do not show that this PR causes it. Run 2's peak is 127 % of thismainrun's.Not tested
Note for whoever merges: #1063 (mine, stacked on #1027) also acts on this slot's calls, in
list_x::uav_barrier_x. It adds depth ↔ twin copies after the global UAV barrier. With this PR the slot goes toenhanced_barrier::barrier_xinstead, so whichever lands second needs the other's hook.AI use
Imported from ivall/xcl. Originally posted by deepdev237 on 2026-11-24T14:46:02Z.
Parser observation from a retail run on AMD RDNA4
Tested
32.0.32015.7029), Ryzen 9 5950X, Windows 11 build 26300, Rust 1.100.0 MSVC, release.930e8b49c1c2ec683d22c724a398b39111cd0e56(Git tree391b7fe28b4f99bce3d9183b99f794f50e592f1c) reused the slot #146 parser from1ecefdda3b4627ab8160845942f27ab4e75ce0c5. It retained the existing PC global UAV barrier forwarding.xcl.exe run "<retail-title>"withXCL_NETWORK=0,XCL_DRED=1,XCL_PSO_WAIT_MS=50andXCL_TRACE_INDIRECT_BARRIERS=1: all 80 traced indirect calls matched slot #146 BUFFER records on the same resource, with whole-buffer access0x10 → 0x290before and0x200 → 0x10afterward.DXGI_ERROR_DEVICE_HUNG. The only started, unfinished list was 11 of 17 operations complete, withEXECUTEINDIRECTnext and no usable page-fault address.Not tested — The full #1025 head or its native barrier translation. These are the title's declared access masks. The diagnostic did not read back the dispatch arguments from the GPU.
AI use — OpenAI Codex (
gpt-6.2-sol) ran the tests, checked the local receipts and wrote this report.Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-27T21:26:19Z.
Nothing has happened on this PR for 3 days, so it is marked
staleand will be closed in 4 days. A push or a comment takes the mark off: rebase it ontomainif it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-28T04:41:22Z.
A note from a separate translation of #146 on our side (not a run of this PR's head), about the read layouts of depth buffers.
What we saw (RTX 3090, the retail title, one run per setting, our own #146 translation, not this PR's code)
SHADER_RESOURCE→0xC0,GENERIC_READ/ direct-queue generic read →0x8C0), the frames lost detail: posters and wall details gone, mean luminance 21 against 35 for the same tree without the translation.DEPTH_READ(0x20) added to those states for depth buffers on a direct list (0xE0,0x8E0), the image matched the run without the translation (luminance 35.3 against 34.9, the same posters), with 0 failedCloseand the same frame pace (2.89 presents/s over 120 s of world).DEPTH_READfor a read-only DSV. (That is our reading, not something we measured separately.)In this PR (read in
enhanced_barrier.rs,layout_state): layouts 6 / 21 give0xC0and 1 / 19 / 31 give0x8C0for textures, with noDEPTH_READfor a depth buffer, and layout 5 (DEPTH_STENCIL_READ) gives0x20alone. So a depth buffer moved to a shader-resource or generic-read layout ends up withoutDEPTH_READ, as in our first runs. A compute or copy list cannot nameDEPTH_READ; there we kept the other read bits.Setup: our lab tree (merge base
b49be18ofmainplus 240 local commits that are not public; our own #146 translation behind a switch,XCL_BARRIERS=1), RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631.Not tested
AI use: Claude Code, model Claude Opus 5.5, wrote this note from our run logs and a reading of the diff. The person running these tests asked for this post.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:39:54Z.
Review (head
1ecefdda, diff read, not a merge-check; draft and conflicting, so not built or run):barrier_groups.rs(2b75212d, merged in #3287, plusbd5ee498), a port of this author's own amd-dev commitsa68f609f/fdd1ac2d, and emits a global UAV barrier on every #146 call (list_x.rs~5032).real.rs~1026) and call the PCResourceBarrierdirectly (enhanced_barrier.rs~501 / ~511), skippinglist_x::resource_barrier_xand with it capture,depth_uav::plan_barriers, the lut3d and placement notes andbarrier_groups::note_legacy_state, and dropping main's depth / stencil plane tracking. ItsSTATEStable tracks whole resources only (~358, ~401), so after a per-subresource transition a later barrier from UNDEFINED starts from a stale state.layout_state) and #3558 (UNDEFINED start state).Fine: the bounded
readable()parsing and the unit tests. Recommendation: close as superseded; if seeding the tracked state at #127 / #133 creation or the aliasing barrier for placed textures is still needed, a small PR on top ofbarrier_groups.rs.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.