Skip to content

D3D12.X: translate list #146 Enhanced Barriers to legacy ResourceBarrier - #1025

Draft
raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:pr/enhanced-barriers-146
Draft

raylitebull wants to merge 1 commit into
xcl-dev:mainfrom
raylitebull:pr/enhanced-barriers-146

Conversation

@raylitebull

Copy link
Copy Markdown
Member

Translate console command list slot #146 (ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups)) into legacy ResourceBarrier calls instead of emitting only a wildcard UAV barrier. Modern Scarlett titles that create resources with barrier layouts (device #127 / #133) rely on #146 for 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: parses D3D12_BARRIER_GROUP (GLOBAL, TEXTURE, BUFFER) with readable() guards (falling back to the legacy global UAV barrier on unparseable calls), maps D3D12_BARRIER_LAYOUT 0..=31 (including 0x1F) plus access-bit fallback for console-only layouts > 0x1F, tracks whole-resource states for UNDEFINED before layouts, emits aliasing barriers for UNDEFINED placed textures, skips UNORDERED_ACCESS on non-UAV textures and states disallowed on compute/copy lists, forwards emitted transitions to title_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 #146 to enhanced_barrier::barrier_x, align #127/#133 initial layout states with texture-vs-buffer awareness, record initial/legacy barrier states, and clear tracked state on res_release.

Tested

  • AMD Radeon RX 9070 XT (driver 32.0.32015.2008), Intel Core i5-13600KF, Windows 11 Pro 22631, rustc 1.99.1 (58cf8f9c3 2026-10-13), release + test profiles
  • cargo test --workspace -- --test-threads=4: 741 passed, 0 failed, 41 ignored (0 SKIPPED GPU tests)

Regression run

main:

xcl-smoke v1
commit: 6efdabcdaac93ce5cc123a85e85deba5d49cb294
gpu: AMD Radeon RX 9070 XT
title: Game Assets
seconds: 60
exit: 0x0
frames shown: 1512 (PresentX 1512)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14852 MB

PR:

xcl-smoke v1
commit: 1ecefdda3b4627ab8160845942f27ab4e75ce0c5
gpu: AMD Radeon RX 9070 XT
title: Game Assets
seconds: 60
exit: 0x0
frames shown: 1609 (PresentX 1609)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14876 MB

Not tested

  • NVIDIA GPUs, Intel Arc GPUs, Linux / Wine, other retail titles beyond the 60 s smoke run and unit/GPU test suite.

AI use

  • Antigravity (Gemini 4 Neon): rebased the local Enhanced Barriers implementation onto origin/main, cleaned up unused helper/constant warnings, ran the full GPU test suite and 60 s smoke regression check, and drafted this description.

…rceBarrier

Console command list slot xcl-dev#146 is ID3D12GraphicsCommandList7::Barrier(NumBarrierGroups, pBarrierGroups) on both older and newer layouts; previously it emitted only a wildcard UAV barrier, dropping every texture layout transition.

- Parse D3D12_BARRIER_GROUP (GLOBAL, TEXTURE, BUFFER) safely with readable() checks; unparseable calls fall back to the legacy global UAV barrier.
- Map D3D12_BARRIER_LAYOUT 0..=31 including 0x1F (DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE) and fall back to access bits for console-only layouts > 0x1F; align device xcl-dev#127/xcl-dev#133 initial layout states with texture-vs-buffer awareness.
- Track whole-resource states across xcl-dev#127/xcl-dev#133 creation, legacy xcl-dev#26, and enhanced xcl-dev#146 (cleared on res_release) for UNDEFINED Before layouts, forward emitted transitions to title_textures::note_transitions, emit wildcard aliasing barriers for UNDEFINED placed textures, keep non-UAV textures out of UNORDERED_ACCESS, and skip states disallowed on compute/copy lists.
@poucosaudavel

Copy link
Copy Markdown

Test report for the exact head 1ecefdda3b4627ab8160845942f27ab4e75ce0c5, since Not tested lists NVIDIA GPUs.

Tested

  • NVIDIA GeForce RTX 5060 Ti (8 GB, 32-lane waves), driver 610.88; Intel Core Ultra 7 265KF; Windows 11 (build 26200)
  • Rust 1.100.0 (stable-x86_64-pc-windows-msvc), MSVC 14.44, Windows SDK 10.0.26100, debug build
  • Clean worktrees, no local changes: the PR head, and its merge base on main (6efdabcdaac93ce5cc123a85e85deba5d49cb294) as the baseline
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4:
    • PR head: 741 passed, 0 failed, 41 ignored
    • merge base: 727 passed, 0 failed, 41 ignored
  • The 14 extra passes are the new 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_gpu ran on the NVIDIA adapter (the log shows backend real on the RTX 5060 Ti) and passed.
  • SKIPPED on both, same reason: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask and gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware (no wave64)

Not tested

  • No scripts/smoke.ps1 regression run on a retail title: this covers the test suite only.
  • Release build of the PR head; AMD, Intel; Linux / Wine.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds and tests and wrote this report from their output.

@itsonewi itsonewi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Global barriers with AccessBefore = NO_ACCESS emit nothing

Access::orders_earlier_work() returns false when access_before == NO_ACCESS, so the Item::Global arm of translate contributes 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."), and SyncBefore = ALL with AccessBefore = NO_ACCESS is valid: only SyncBefore = NONE requires AccessBefore = NO_ACCESS, not the reverse.

The old #146 handler (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 test unordered_access_gets_one_uav_barrier_for_all_resources covers AccessBefore = 0x10, and the NO_ACCESS case only with SyncBefore = NONE; a test with SyncBefore = ALL, AccessBefore = NO_ACCESS would 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.

@raylitebull
raylitebull marked this pull request as draft November 24, 2026 11:12
@DavidM1911

Copy link
Copy Markdown
Contributor

Independent verification, merged onto current main 384f7f7 locally (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 — all enhanced_barrier::tests, including the GPU test enhanced_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.

@IvyNotFound

Copy link
Copy Markdown

Retail run into world loading on an RTX 5080: 1ecefdd merged onto main 930e8b4 – no crash or device removal, the barriers are translated, the frames after loading stay black as on main, and the #505 GPU-wait stalls come at least as often

Tested

  • NVIDIA GeForce RTX 5080 16 GB, driver 621.24; Ryzen 7 7800X3D; Windows 11 25H2 (26200.9974); rustc 1.100.0 MSVC; DXC 1.9.2602.17.
  • main 930e8b4 + this PR's head 1ecefdd (clean merge, local commit bbace0e).
  • cargo test -p xcl --lib enhanced (debug): 14 passed, 0 failed (the GPU test ran on the RTX 5080).
  • Retail title of Newer retail title (TitleID 7952987A): reaches world loading, then the title's GPU watchdog ("GPU Loc Sig") after ListX #101 stub #505, release, scripts/smoke.ps1 -Seconds 140, XCL_PRESS_A_AT=15, XCL_PSO_WAIT_MS=50 (so it gets past the first ListX #101 into world loading), XCL_FRAME_DUMP=2. Two runs of the PR, compared with one of main with the same settings.
main 930e8b4 PR, run 1 PR, run 2
exit / device removals / crashes 0x0 / 0 / 0 0x0 / 0 / 0 0x0 / 0 / 0
frames shown 1434 1392 1395
peak commit 33 004 MB 37 236 MB 41 830 MB
GPU queue.Wait … did not complete within 5000 ms 19, first at 118.6 s 27, first at 109.8 s 55, first at 120.6 s
Write64 cycle breaks 13 17 32

Not tested

  • the whole suite at this merge
  • whether the left-out compute-list transitions matter (they are skipped by design here)

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 to enhanced_barrier::barrier_x instead, so whichever lands second needs the other's hook.

AI use

  • Claude Code, Claude Opus 5.5: merged and built the PR, ran the tests and the runs, read the logs and frame dumps, and wrote this report.

@deepdev237

Copy link
Copy Markdown

Parser observation from a retail run on AMD RDNA4

Tested

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.

@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 27, 2026
@CharlyRien

Copy link
Copy Markdown
Contributor

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)

  • With a depth buffer's read layouts mapped like this PR does (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.
  • With 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 failed Close and the same frame pace (2.89 presents/s over 120 s of world).
  • The title reads its depth through a read-only depth view while it writes stencil; the PC wants DEPTH_READ for 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 give 0xC0 and 1 / 19 / 31 give 0x8C0 for textures, with no DEPTH_READ for a depth buffer, and layout 5 (DEPTH_STENCIL_READ) gives 0x20 alone. So a depth buffer moved to a shader-resource or generic-read layout ends up without DEPTH_READ, as in our first runs. A compute or copy list cannot name DEPTH_READ; there we kept the other read bits.

Setup: our lab tree (merge base b49be18 of main plus 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

  • This PR's head itself on our title: the numbers above come from our translation with and without the extra bit.
  • AMD, Intel.

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.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Review (head 1ecefdd, diff read, not a merge-check; draft and conflicting, so not built or run):

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 of barrier_groups.rs.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No activity for 3 days; closed 4 days later unless something happens

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants