Skip to content

D3D12.X: a title's barrier groups (#146) move its textures between states - #3299

Closed
Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:d3d12x-barrier-groups
Closed

Foniass wants to merge 1 commit into
xcl-dev:mainfrom
Foniass:d3d12x-barrier-groups

Conversation

@Foniass

@Foniass Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

A title that uses enhanced barriers makes all its texture state changes
through command list #146, Barrier(groups). XCL answered #146 with a
global UAV barrier only, so no PC texture left the state it was created
in: render targets were sampled while still compressed, depth buffers
read as textures were never expanded, and a depth buffer the title moved
into unordered access never reached depth_uav. On the retail title this
left the world dark.

New hle/d3d12x/barrier_groups.rs turns each texture barrier of the
groups into a legacy transition between the states its layouts stand
for (state_of), on the subresources its range names (depth and stencil
planes tracked separately), and sends them the way a title's own
ResourceBarrier calls go (list_x::resource_barrier_x), after the UAV
barrier that still stands for buffer and global barriers. legal() drops
what the PC would refuse: an illegal barrier fails Close with
E_INVALIDARG. A barrier from the undefined layout starts at the state
the texture was last moved to; resource_barrier_x notes legacy
transitions for that (note_legacy_state), and a released texture is
forgotten. XCL_BARRIER_GROUPS=0 turns the transitions off.

Ported from amd-dev: barrier_groups.rs as of fdd1ac2 (which added the
per-plane depth / stencil tracking) and the #146 wiring of a68f609
(raylitebull, written with Claude Code), with depth_uav::kept made available
outside tests as on amd-dev (barrier_groups asks it), without that commit's other
work (depth twins on by default, ambient, kernelx sections, RAM budget,
memory map), its XCL_BARRIER_LOG diagnostics, or the format_alias hooks
main does not have.

What is in it

  • crates/xcl/src/hle/d3d12x/barrier_groups.rs (new, about 630 lines of which about 160 are tests): state_of (layout to PC state), subresources / per-plane tracking, legal, transitions, note_legacy_state, forget; tests for the layout mapping, ranges, planes and illegal states
  • crates/xcl/src/hle/d3d12x/list_x.rs: Compute dispatches: a shader takes no more arguments from user SGPRs than it has (XboxBvhBuilder builds empty BLAS / TLAS) #146 uav_barrier_x sends the transitions after its UAV barrier; resource_barrier_x notes each legacy transition
  • crates/xcl/src/hle/d3d12x/real.rs: a released resource is forgotten; depth_uav.rs: kept available outside tests
  • new here: transitions refuses a misaligned resource pointer from a title's barrier (windows-core aborts the process on one)

Over the 400-line target because the module comes with its tests; the hooks without the module do nothing, and the module without the hooks is dead code.

Tested

  • NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.2114), AMD Ryzen 7 7800X3D, Windows 11 build 26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), debug tests, release smoke
  • cargo test --workspace --no-fail-fast -- --test-threads=4 on fb72af5: 2612 passed, 4 failed, 49 ignored. The 4 failures are gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3 (E_OUTOFMEMORY from CreateComputePipelineState, seeds 70 / 545 / 1019 / 1507), the same as on main on this machine; they pass on another RTX 5070 Ti. SKIPPED GPU tests: 44 notices, almost all no wave64.
  • The first full run of this branch (head 014fba85, without the alignment check) aborted once in the lib tests, in a background pipeline-builder thread (xcl-pso-ahead-2, a misaligned COM pointer in windows-core); two reruns of cargo test -p xcl --lib there and the full run on this head were clean, and no other branch's run hit it.
  • Retail title: 60 s smoke run below (no device removal or crash, frames and peak commit within the limits).

Regression run

main:

xcl-smoke v1
commit: b10cc4c6766adc947c2054ada4a2af98be15108d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1565 (PresentX 1565)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16026 MB

this PR:

xcl-smoke v1
commit: fb72af55960d621dbf6c93e73d18200fb1bbe4cd
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3cb1d8e0
seconds: 60
exit: 0x0
frames shown: 1670 (PresentX 1670)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16814 MB

Not tested

AI use

  • Claude Code with Claude Opus 5.5: ported this part of the amd-dev commit named above to main, wrote the commit message and this description, ran the tests and the smoke run.

🤖 Generated with Claude Code

…ween states

A title that uses enhanced barriers makes all its texture state changes
through command list xcl-dev#146, Barrier(groups). XCL answered xcl-dev#146 with a
global UAV barrier only, so no PC texture left the state it was created
in: render targets were sampled while still compressed, depth buffers
read as textures were never expanded, and a depth buffer the title moved
into unordered access never reached depth_uav. On the retail title this
left the world dark.

New hle/d3d12x/barrier_groups.rs turns each texture barrier of the
groups into a legacy transition between the states its layouts stand
for (state_of), on the subresources its range names (depth and stencil
planes tracked separately), and sends them the way a title's own
ResourceBarrier calls go (list_x::resource_barrier_x), after the UAV
barrier that still stands for buffer and global barriers. legal() drops
what the PC would refuse: an illegal barrier fails Close with
E_INVALIDARG. A barrier from the undefined layout starts at the state
the texture was last moved to; resource_barrier_x notes legacy
transitions for that (note_legacy_state), and a released texture is
forgotten. XCL_BARRIER_GROUPS=0 turns the transitions off.

Ported from amd-dev: barrier_groups.rs as of fdd1ac2 (which added the
per-plane depth / stencil tracking) and the xcl-dev#146 wiring of a68f609
(raylitebull, written with Claude Code), with depth_uav::kept made available
outside tests as on amd-dev (barrier_groups asks it), without that commit's other
work (depth twins on by default, ambient, kernelx sections, RAM budget,
memory map), its XCL_BARRIER_LOG diagnostics, or the format_alias hooks
main does not have.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test) labels Nov 29, 2026
@Foniass

Foniass commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Closing: Kalmarv's #3287, which came first, is merged and does the same. Anything still missing from it can go in a small follow-up PR.

(Claude Code, Claude Opus 5.5, for Foniass)

@Foniass Foniass closed this Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory gpu:amd Code is specific to AMD / RDNA / wave64 GPUs (scope tag; see needs:amd-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant