D3D12.X: map full D3D12_BARRIER_LAYOUT set and mask console modifiers in layout_state #3238

Closed
Kalmarv wants to merge 1 commit from upstream-pr/3238 into main
Kalmarv commented 2026-11-28 23:42:09 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-28T23:42:09Z.


device_x::layout_state (crates/xcl/src/hle/d3d12x/device_x.rs) previously matched only base D3D12_BARRIER_LAYOUT values 1..=10 without stripping console layout-modifier bits in [30:22] (0x7FC0_0000). On CreatePlacedResourceX (#133) and CreateCommittedResourceLayoutX (#127), SHADING_RATE_SOURCE (11), video layouts (12..=17), queue-specific layouts (18..=30), console cross-queue generic read (32), and any layout carrying console modifier bits silently fell back to COMMON (0).

What is in it

  • crates/xcl/src/hle/d3d12x/device_x.rs: check D3D12_BARRIER_LAYOUT_UNDEFINED (u32::MAX) -> COMMON (0), mask off console modifier bits (layout & !0x7FC0_0000), and map 11 (SHADING_RATE_SOURCE -> 0x100_0000), 12..=17 (video decode/process/encode read/write), queue-specific direct/compute layouts (19..=23, 25..=29), and 32 (cross-queue generic read -> 0xAC3) to their corresponding D3D12_RESOURCE_STATES values.
  • crates/xcl/src/hle/d3d12x/device_x.rs (mod tests): add layout_state_maps_queue_specific_shading_rate_video_and_console_modifiers.

Tested

  • Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), rustc 1.99.0 (b940084d7), DXC 1.9.2609.5, debug tests / release smoke.
  • cargo test --workspace -- --test-threads=4: 2596 passed, 0 failed, 49 ignored.
  • SKIPPED GPU tests on RTX 5070 Ti (26 total): 21 no wave64 (wave32-only adapter), 3 #1426 per-lane f16 refusals (V_MUL_F16, V_PK_MUL_F16, V_CVT_F16_F32), 2 no heap windows (default XCL_HEAP_WINDOWS off). Zero no GPU or no DXC skips.
  • Targeted failing-before (left: 0, right: 16777216) -> passing-after verification on device_x::tests::layout_state_maps_queue_specific_shading_rate_video_and_console_modifiers (20/20 device_x::tests).
  • Real title smoke run executed with XCL_DIRECT_DXIL=all (1676 frames vs 1695 on main, 0 device removals, 0 crashes), plus combined steady-world validation run (LIGHT_NO_FLUSH: exit 0x0, 1.94 steady FPS, 0 removals).

Regression run

xcl-smoke v1
commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1695 (PresentX 1695)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 31546 MB
xcl-smoke v1
commit: 59f6dc225edef0a3292b520aa2f1028aeaa6f836
gpu: NVIDIA GeForce RTX 5070 Ti
title: ea3b5e4d
seconds: 150
exit: 0x0
frames shown: 1676 (PresentX 1676)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 32688 MB

Not tested

  • AMD GPUs (RDNA2/3/4) and wave64-native hardware (no wave64 tests skipped on RTX 5070 Ti).
  • Video decode/process/encode command lists using layouts 12..=17 on a real title.

AI use

  • Antigravity (Google Gemini): implemented the layout_state mapping and unit test, ran the workspace test suite and title regression run on hardware, and drafted the PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5545719299 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3238). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-28T23:42:09Z. --- `device_x::layout_state` (`crates/xcl/src/hle/d3d12x/device_x.rs`) previously matched only base `D3D12_BARRIER_LAYOUT` values `1..=10` without stripping console layout-modifier bits in `[30:22]` (`0x7FC0_0000`). On `CreatePlacedResourceX` (`#133`) and `CreateCommittedResourceLayoutX` (`#127`), `SHADING_RATE_SOURCE` (`11`), video layouts (`12..=17`), queue-specific layouts (`18..=30`), console cross-queue generic read (`32`), and any layout carrying console modifier bits silently fell back to `COMMON` (`0`). **What is in it** - `crates/xcl/src/hle/d3d12x/device_x.rs`: check `D3D12_BARRIER_LAYOUT_UNDEFINED` (`u32::MAX`) -> `COMMON` (`0`), mask off console modifier bits (`layout & !0x7FC0_0000`), and map `11` (`SHADING_RATE_SOURCE` -> `0x100_0000`), `12..=17` (video decode/process/encode read/write), queue-specific direct/compute layouts (`19..=23`, `25..=29`), and `32` (cross-queue generic read -> `0xAC3`) to their corresponding `D3D12_RESOURCE_STATES` values. - `crates/xcl/src/hle/d3d12x/device_x.rs` (`mod tests`): add `layout_state_maps_queue_specific_shading_rate_video_and_console_modifiers`. **Tested** - Hardware / toolchain: NVIDIA GeForce RTX 5070 Ti (driver 32.0.16.1074), AMD Ryzen 9 9950X, Windows 11 Pro (Build 26200), rustc 1.99.0 (b940084d7), DXC 1.9.2609.5, debug tests / release smoke. - `cargo test --workspace -- --test-threads=4`: 2596 passed, 0 failed, 49 ignored. - `SKIPPED` GPU tests on RTX 5070 Ti (26 total): 21 `no wave64` (wave32-only adapter), 3 `#1426` per-lane f16 refusals (`V_MUL_F16`, `V_PK_MUL_F16`, `V_CVT_F16_F32`), 2 `no heap windows` (default `XCL_HEAP_WINDOWS` off). Zero `no GPU` or `no DXC` skips. - Targeted failing-before (`left: 0, right: 16777216`) -> passing-after verification on `device_x::tests::layout_state_maps_queue_specific_shading_rate_video_and_console_modifiers` (20/20 `device_x::tests`). - Real title smoke run executed with `XCL_DIRECT_DXIL=all` (`1676` frames vs `1695` on main, `0` device removals, `0` crashes), plus combined steady-world validation run (`LIGHT_NO_FLUSH`: exit `0x0`, `1.94` steady FPS, `0` removals). **Regression run** ``` xcl-smoke v1 commit: f0e8fdd5c3942ddd399d5ee11384c8595c5aacff gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1695 (PresentX 1695) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 31546 MB ``` ``` xcl-smoke v1 commit: 59f6dc225edef0a3292b520aa2f1028aeaa6f836 gpu: NVIDIA GeForce RTX 5070 Ti title: ea3b5e4d seconds: 150 exit: 0x0 frames shown: 1676 (PresentX 1676) presents per 2 s (last 3): 0 0 0 device removals: 0 crashes: 0 peak commit: 32688 MB ``` **Not tested** - AMD GPUs (RDNA2/3/4) and wave64-native hardware (`no wave64` tests skipped on RTX 5070 Ti). - Video decode/process/encode command lists using layouts `12..=17` on a real title. **AI use** - Antigravity (Google Gemini): implemented the `layout_state` mapping and unit test, ran the workspace test suite and title regression run on hardware, and drafted the PR description.
Foniass commented 2026-12-01 05:01:58 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:01:58Z.


Review (head 59f6dc22, diff read, not a merge-check; it conflicts with main, so not built or run):

  • Layout 31 is mapped to COMMON as "console PRESENT" (device_x.rs ~1305). On PC, 31 is DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE, and main's barrier_groups::state_of maps it to SHADER_RESOURCE | COPY_SOURCE. So a resource created in layout 31 starts in COMMON while the next barrier out of 31 assumes 0x8C0, and the PC gets a wrong StateBefore.
  • Two tables instead of one. Since #146 main has barrier_groups::state_of (2b75212d, after this PR's base); using it in layout_state would keep creation and barriers consistent. The two already differ on generic read (0xAC3 vs 0x8C0) and depth read, and state_of doesn't apply the new 0x7FC0_0000 "modifier" mask. Where do that mask and layout 32 come from? Nothing in the repo records a title passing them. #839 (open) also maps 11 and 19-29 in layout_state.
  • The conflict is only the test appended at the end of device_x's mod tests (7e242379 added one there); layout_state itself is unchanged on main, so not superseded. The CI failures are in pipeline_library / warm_library, outside this diff.
  • AI use says "Antigravity (Gemini)", not an exact model.

Fine: the video and shading-rate state constants are right, UNDEFINED maps to COMMON, and the test fails without the change.

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

<!-- greyfinch-sync:ivall/xcl:comment:7301352634 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3238#issuecomment-7301352634). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T05:01:58Z. --- Review (head 59f6dc22, diff read, not a merge-check; it conflicts with main, so not built or run): - **Layout 31 is mapped to COMMON as "console PRESENT"** (`device_x.rs` ~1305). On PC, 31 is `DIRECT_QUEUE_GENERIC_READ_COMPUTE_QUEUE_ACCESSIBLE`, and main's `barrier_groups::state_of` maps it to SHADER_RESOURCE | COPY_SOURCE. So a resource created in layout 31 starts in COMMON while the next barrier out of 31 assumes 0x8C0, and the PC gets a wrong StateBefore. - **Two tables instead of one.** Since #146 main has `barrier_groups::state_of` (2b75212d, after this PR's base); using it in `layout_state` would keep creation and barriers consistent. The two already differ on generic read (0xAC3 vs 0x8C0) and depth read, and `state_of` doesn't apply the new `0x7FC0_0000` "modifier" mask. Where do that mask and layout 32 come from? Nothing in the repo records a title passing them. #839 (open) also maps 11 and 19-29 in `layout_state`. - The conflict is only the test appended at the end of `device_x`'s `mod tests` (7e242379 added one there); `layout_state` itself is unchanged on main, so not superseded. The CI failures are in `pipeline_library` / `warm_library`, outside this diff. - AI use says "Antigravity (Gemini)", not an exact model. Fine: the video and shading-rate state constants are right, UNDEFINED maps to COMMON, and the test fails without the change. AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Kalmarv commented 2026-12-02 19:38:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T19:38:22Z.


Closing: conflicts in device_x.rs, overlaps earlier #839 (#1607 D190), and duplicates barrier_groups::state_of with unsourced layout/modifier mappings.

<!-- greyfinch-sync:ivall/xcl:comment:7356490723 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3238#issuecomment-7356490723). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T19:38:22Z. --- Closing: conflicts in `device_x.rs`, overlaps earlier #839 (#1607 D190), and duplicates `barrier_groups::state_of` with unsourced layout/modifier mappings.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3238
No description provided.