Skip to content

D3D12.X: give the queue-specific barrier layouts their resource states - #839

Open
mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/d3d12x-barrier-layout-states
Open

mastrr9 wants to merge 1 commit into
xcl-dev:mainfrom
mastrr9:fix/d3d12x-barrier-layout-states

Conversation

@mastrr9

@mastrr9 mastrr9 commented Nov 24, 2026 •

Copy link
Copy Markdown

Extends device_x::layout_state() (used by CreateCommittedResource #127 and CreatePlacedResourceX #133 when creating resources with a D3D12_BARRIER_LAYOUT) to map SHADING_RATE_SOURCE (11) and all DIRECT_QUEUE_* / COMPUTE_QUEUE_* layouts (18–29) to their legacy D3D12_RESOURCE_STATES equivalents instead of falling back to COMMON.

  • Maps COMPUTE_QUEUE_SHADER_RESOURCE (27) to NON_PIXEL_SHADER_RESOURCE (0x40), DIRECT_QUEUE_SHADER_RESOURCE (21) to ALL_SHADER_RESOURCE (0xC0), SHADING_RATE_SOURCE (11) to 0x100_0000, and the remaining direct/compute queue layouts (GENERIC_READ, UNORDERED_ACCESS, COPY_SOURCE, COPY_DEST) to their corresponding states.
  • Adds unit test barrier_layouts_become_resource_states verifying every layout constant by name against the windows crate definitions.

Tested

  • Hardware/OS: NVIDIA RTX 5080 (driver 617.42 / 32.0.16.1742), Windows 11 Pro 25H2 (26200.9974), rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC debug, DXC Windows SDK 10.0.26100.0, d3d12SDKLayers.dll installed
  • Commit tested: ba90058f7c5017469e2acd411aa0dd61ae6fc343
  • cargo build --workspace: clean (only pre-existing fetch_update deprecation warning)
  • cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored (new test hle::d3d12x::device_x::tests::barrier_layouts_become_resource_states passed)
  • SKIPPED GPU tests: gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask: no wave64, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware: no wave64

Regression run
Smoke run by @CuteBooty in comment below: #839 (comment)
Contributed by a community tester; the PR author did not run it. Both blocks are pasted as posted.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1466)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15248 MB

PR:

xcl-smoke v1
commit: b904fda4535b225f2feabe62fd41cbc68d489680
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15535 MB

Tester's setup: RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.

Tester's method: scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main beaa245, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with the tester's reports on other PRs of the same base.

Tester's AI use: Claude Code (Claude Opus 5.5) made the runs with the tester present and wrote the report from the script's output.

Not tested

  • No retail title was available to the author; whether the community regression run above reaches the code this PR changes is not known.

AI use

  • Authored with Claude Code (Claude Opus 5.5); reviewed, audited, and verified on native Windows/RTX 5080 hardware with Antigravity (Gemini 4 Neon + Claude Sonnet 5.5).
  • Claude Code (Claude Sonnet 5.5) added the community regression run to this description and updated the lines that it made out of date or that the PR check requires.

@futurepro62

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head ba90058 (on its base beaa245).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 714 passed, 0 failed, 41 ignored. SKIPPED (no wave64): gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware.
  • The new tests ran and passed: barrier_layouts_become_resource_states.

Not tested

  • AMD, a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head ba90058 onto main a1672ef, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 709 passed, 7 failed, 41 ignored. Failures are the known Wine-lane set from my #42 rows plus #718 trio members; nothing here fails because of your change. Queue-specific barrier layout tests green; no new failures.

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. Linux rows: #42 / #718.

AI use: Hermes agent (local Qwen-class) ran the suite and drafted this; I checked it before posting.

gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#851, xcl-dev#864, xcl-dev#875-xcl-dev#876 and Wine raw fences

Integrate clean upstream PRs on top of upstream/main (1ec4c98):
- xcl-dev#849: direct move_away for remapped physical pages (avoids 4x sparse tile-mapping round-trips)
- xcl-dev#838: FillMemoryWith*BitValueX uses list upload arena instead of leaked pattern buffers
- xcl-dev#840: merge released ranges of the shared descriptor heap
- xcl-dev#839: map queue-specific D3D12_BARRIER_LAYOUT values to legacy resource states
- xcl-dev#841: preserve due frame-clock events when schedule changes at deadline
- xcl-dev#851: split wrapped command lists before Wait64 GE after ordinary GPU work
- xcl-dev#864: export XMemIsToolsMemAvailable returning 0 on retail
- xcl-dev#875: tbuffer_load_format_* uses identity DST_SEL instead of V# DST_SEL
- xcl-dev#876: implement IDXGIDevice2::EnqueueSetEvent

Also add real::create_raw_fence for internal fences (late_release and EnqueueSetEvent) so Wine/vkd3d-proton never receives a FenceProxy on unadopted internal queues or SetEventOnMultipleFenceCompletion, and wrap list_x test exec with UnadoptGuard.

Assisted-by: Antigravity (Google DeepMind)
CreateCommittedResource (xcl-dev#127) and CreatePlacedResourceX (xcl-dev#133) of the
newer device layout take a D3D12_BARRIER_LAYOUT for the initial state,
which layout_state() turns into a legacy resource state. It knew layouts
0 to 10 only, so the DIRECT_QUEUE_* and COMPUTE_QUEUE_* layouts (18 to 29)
and SHADING_RATE_SOURCE (11) all became COMMON: a texture made in
DIRECT_QUEUE_SHADER_RESOURCE or COMPUTE_QUEUE_UNORDERED_ACCESS started in
COMMON on the PC while the title treats it as already in that layout.

Assisted-by: Claude Code (Claude Opus 5.5)
@mastrr9
mastrr9 force-pushed the fix/d3d12x-barrier-layout-states branch from ba90058 to b904fda Compare November 24, 2026 07:58
gustavsi added a commit to gustavsi/xcl that referenced this pull request Nov 24, 2026
…cl-dev#864, xcl-dev#875-xcl-dev#876

Re-apply the 8 non-merged upstream PRs from our previous fork main onto upstream/main (930e8b4): xcl-dev#838 (upload-arena fills), xcl-dev#839 (queue-specific barrier layouts), xcl-dev#840 (coalesced shared descriptor heap), xcl-dev#841 (frame clock deadline reschedule), xcl-dev#851 (split before Wait64 GE after ordinary work), xcl-dev#864 (XMemIsToolsMemAvailable), xcl-dev#875 (tbuffer_load_format identity DST_SEL), and xcl-dev#876 (IDXGIDevice2::EnqueueSetEvent with create_raw_fence).

Assisted-by: Antigravity (Google DeepMind)
@mastrr9
mastrr9 marked this pull request as ready for review November 24, 2026 16:42
@CuteBooty

Copy link
Copy Markdown

Regression run on a retail title for b904fda: pass (no device removal, no crash, frames and peak commit within the check's limits).

Tested

  • RTX 3070 8 GB (32-lane waves), NVIDIA 621.24; Ryzen 5 3600, 32 GB; Windows 11 Pro 26200; rustc 1.100.0 MSVC; release build.
  • scripts\smoke.ps1 -Game <folder> -Seconds 60, no input, on this PR's head as it is and on main beaa245, the commit it branches from, each from a clean checkout. Each build ran twice back to back; the blocks are the second runs. The main block is shared with my reports on other PRs of the same base.

main:

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1466 (PresentX 1466)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15248 MB

this PR:

xcl-smoke v1
commit: b904fda4535b225f2feabe62fd41cbc68d489680
gpu: NVIDIA GeForce RTX 3070
title: game
seconds: 60
exit: 0x0
frames shown: 1536 (PresentX 1536)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15535 MB

Not tested

  • Whether the 60 s reach the code this PR changes, the world load, the test suite, current main merged in, AMD and Intel GPUs.

AI use

  • Claude Code (Claude Opus 5.5) made the runs with me present and wrote this from the script's output.

@JJAutoCompare

Copy link
Copy Markdown

Empirical test report (b904fda)

Verified PR #839 at commit b904fda4535b225f2feabe62fd41cbc68d489680.

Hardware / environment

  • Windows x64, build 26200, on AuthenticAMD family 23, model 113, stepping 0.
  • Rust 1.100.0 (0ef1bc386 2026-11-09). DXC 1.9.2609.5 (01b62ad47).
  • Cargo's unoptimized test profile with debug info and incremental compilation disabled. The focused run used XCL_ADAPTER=NONE_CPU_ONLY and RUST_TEST_NOCAPTURE=1, outside the Arc test wrapper.

Commands and results

  • cargo test --workspace --no-run exited 0 and built the workspace test executables. The compiler emitted a deprecation warning for AtomicU32::fetch_update in XGameRuntime.
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests::barrier_layouts_become_resource_states -- --exact exited 0. The fixture log recorded 1 passed, 0 failed, 0 ignored, 0 SKIPPED lines, and 693 filtered out.

Observed behavior

The fixture called layout_state directly and all assertions against D3D12 resource state constants passed. Direct-queue shader resources mapped to all shader stages and compute-queue shader resources mapped to non-pixel shader access. Both queues' generic-read, unordered-access, copy-source and copy-destination layouts mapped to their corresponding legacy states. The shading-rate-source layout mapped to its dedicated state. Undefined and the queue-common cases covered by the fixture mapped to COMMON. The fixture requires no D3D12 device.

Not tested

The full GPU workspace suite and game smoke runs were omitted. The focused run exercised the translation function only. Resource creation and runtime barrier behavior on a D3D12 device remain unverified.

AI use

Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr839-focused.log and published.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants