d3d12-gpu: record enhanced barriers as the legacy ones they stand for #2906

Closed
aznohonza wants to merge 5 commits from upstream-pr/2906 into main
aznohonza commented 2026-12-01 17:12:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T17:12:10Z.


replay/record.rs listed ID3D12GraphicsCommandList7::Barrier as not recorded, so a stream that used enhanced barriers lost those ordering points when it was replayed. This hooks the method and records each group as the legacy barriers the runtime itself uses for the same wait:

  • Global → the alias + UAV pair play::wait_for_all falls back to on a device without enhanced barriers.
  • Texture → a transition between the D3D12_RESOURCE_STATES its layouts stand for (layout_state), with the subresource the range names when it names one. A same-state barrier becomes the UAV barrier it stands for, or nothing at all: a real device rejects a transition to the state it is already in (E_INVALIDARG).
  • Buffer → a UAV barrier when the access after is UAV, else the alias + UAV pair (a legacy barrier cannot name another buffer access).

The wire already carries Cmd::Barriers, and playback already issues those legacy barriers, so nothing changes in play.rs or wire.rs. The enhanced sync/access masks order the same accesses with less; the recorded legacy barriers are the same waits, never fewer.

One stated shortcut: a texture range naming more than one subresource is recorded as the whole resource, since a legacy transition carries one subresource. That is conservative; a title that keeps two subresources of one texture in different layouts at once would need the wire extended. The code says so where it happens.

Verification: layout_state covers every layout and both queue-specific forms; enhanced_records_its_texture_and_buffer_barriers drives enhanced() itself with texture and buffer groups, same_state_texture_barriers_are_a_wait_or_nothing covers the same-state forms, and one_subresource_ranges_flatten_to_that_subresource the range forms.

cargo xwin build --target x86_64-pc-windows-msvc -p leonida-gpu --lib --tests --features diagnostics
wine .../leonida_gpu-<hash>.exe enhanced_layouts_record
# test replay::record::tests::enhanced_layouts_record_as_the_states_they_stand_for ... ok

The workspace also checks with the default features (cargo xwin check --target x86_64-pc-windows-msvc --workspace --all-targets --locked). Replay is behind the diagnostics feature, so that unit test runs with cargo test -p leonida-gpu --features diagnostics --lib; there is no D3D12 device on this Linux host, so the recorded-and-replayed path itself is compile/read-verified here and exercised by the crate's device tests on Windows. No game data, no new switch.

Claimed in #2570 (RS-RECORD-ENHANCED-BARRIERS). AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5590659015 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T17:12:10Z. --- `replay/record.rs` listed `ID3D12GraphicsCommandList7::Barrier` as not recorded, so a stream that used enhanced barriers lost those ordering points when it was replayed. This hooks the method and records each group as the legacy barriers the runtime itself uses for the same wait: - **Global** → the alias + UAV pair `play::wait_for_all` falls back to on a device without enhanced barriers. - **Texture** → a transition between the `D3D12_RESOURCE_STATES` its layouts stand for (`layout_state`), with the subresource the range names when it names one. A same-state barrier becomes the UAV barrier it stands for, or nothing at all: a real device rejects a transition to the state it is already in (`E_INVALIDARG`). - **Buffer** → a UAV barrier when the access after is UAV, else the alias + UAV pair (a legacy barrier cannot name another buffer access). The wire already carries `Cmd::Barriers`, and playback already issues those legacy barriers, so nothing changes in `play.rs` or `wire.rs`. The enhanced sync/access masks order the same accesses with less; the recorded legacy barriers are the same waits, never fewer. **One stated shortcut:** a texture range naming more than one subresource is recorded as the whole resource, since a legacy transition carries one subresource. That is conservative; a title that keeps two subresources of one texture in different layouts at once would need the wire extended. The code says so where it happens. **Verification:** `layout_state` covers every layout and both queue-specific forms; `enhanced_records_its_texture_and_buffer_barriers` drives `enhanced()` itself with texture and buffer groups, `same_state_texture_barriers_are_a_wait_or_nothing` covers the same-state forms, and `one_subresource_ranges_flatten_to_that_subresource` the range forms. ``` cargo xwin build --target x86_64-pc-windows-msvc -p leonida-gpu --lib --tests --features diagnostics wine .../leonida_gpu-<hash>.exe enhanced_layouts_record # test replay::record::tests::enhanced_layouts_record_as_the_states_they_stand_for ... ok ``` The workspace also checks with the default features (`cargo xwin check --target x86_64-pc-windows-msvc --workspace --all-targets --locked`). Replay is behind the `diagnostics` feature, so that unit test runs with `cargo test -p leonida-gpu --features diagnostics --lib`; there is no D3D12 device on this Linux host, so the recorded-and-replayed path itself is compile/read-verified here and exercised by the crate's device tests on Windows. No game data, no new switch. Claimed in #2570 (RS-RECORD-ENHANCED-BARRIERS). AI-assisted.
Kal0s-design commented 2026-12-01 17:30:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-01T17:30:34Z.


Checked on native Windows 11 with a real D3D12 device (rustc 1.98.1, MSVC target), since the run in the description is under Wine.

Head e18eeaf6e merged with main d2a564b66 (clean merge):

  • cargo test -p leonida-gpu --features diagnostics --lib replay::: 25 passed, 0 failed. enhanced_layouts_record_as_the_states_they_stand_for passes.
  • The test catches a wrong mapping. With 21 => 6 changed to 21 => 1 (direct-queue shader resource mapped as generic read), it fails with left: 2755, right: 192.

One case that would break playback: a texture barrier whose two layouts map to the same state.

Enhanced barriers often keep the layout and change only sync/access. Two UAV dispatches on one texture are the usual case: LayoutBefore == LayoutAfter == UNORDERED_ACCESS. Other pairs map to the same state too: UNDEFINED -> COMMON (both 0) and DIRECT_QUEUE_SHADER_RESOURCE -> SHADER_RESOURCE (both 0xC0). enhanced() records each of these as Barrier::Transition with before == after, and playback issues it through gpu::transition.

I issued that legacy barrier on a real device: a 64x64 RGBA8 texture, then one ResourceBarrier transition and Close().

transition Close() debug layer
UAV -> SRV (control) Ok no message
UAV -> UAV E_INVALIDARG ResourceBarrier: Before and after states must be different.
RT -> RT E_INVALIDARG same message
COMMON -> COMMON E_INVALIDARG same message
UAV -> UAV, debug layer off E_INVALIDARG (none)

So the replayed list fails to close even without the debug layer. edit.rs join only folds a transition into an earlier one on the same resource; a lone same-state transition goes through unchanged.

A possible fix: when layout_state(before) == layout_state(after), record no transition, and record Barrier::Uav { res } when the layout is UNORDERED_ACCESS (the wait the barrier stands for). That matches what join already does when two transitions cancel out on UNORDERED_ACCESS. A test that runs enhanced() on a UAV -> UAV texture group would cover it.

Context: on main I found no host code that calls Barrier / sets LayoutBefore, so this only matters once a recorded stream contains enhanced barriers. That is the case this pull request is for, though.

Not checked: a full record/replay round trip, and the game.

GPUs tested: the default hardware adapter (device-level ResourceBarrier / Close check only).

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319410635 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7319410635). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-01T17:30:34Z. --- Checked on native Windows 11 with a real D3D12 device (rustc 1.98.1, MSVC target), since the run in the description is under Wine. Head `e18eeaf6e` merged with `main` `d2a564b66` (clean merge): - `cargo test -p leonida-gpu --features diagnostics --lib replay::`: 25 passed, 0 failed. `enhanced_layouts_record_as_the_states_they_stand_for` passes. - The test catches a wrong mapping. With `21 => 6` changed to `21 => 1` (direct-queue shader resource mapped as generic read), it fails with `left: 2755, right: 192`. **One case that would break playback: a texture barrier whose two layouts map to the same state.** Enhanced barriers often keep the layout and change only sync/access. Two UAV dispatches on one texture are the usual case: `LayoutBefore == LayoutAfter == UNORDERED_ACCESS`. Other pairs map to the same state too: `UNDEFINED -> COMMON` (both `0`) and `DIRECT_QUEUE_SHADER_RESOURCE -> SHADER_RESOURCE` (both `0xC0`). `enhanced()` records each of these as `Barrier::Transition` with `before == after`, and playback issues it through `gpu::transition`. I issued that legacy barrier on a real device: a 64x64 RGBA8 texture, then one `ResourceBarrier` transition and `Close()`. | transition | `Close()` | debug layer | |---|---|---| | UAV -> SRV (control) | `Ok` | no message | | UAV -> UAV | `E_INVALIDARG` | `ResourceBarrier: Before and after states must be different.` | | RT -> RT | `E_INVALIDARG` | same message | | COMMON -> COMMON | `E_INVALIDARG` | same message | | UAV -> UAV, debug layer off | `E_INVALIDARG` | (none) | So the replayed list fails to close even without the debug layer. `edit.rs` `join` only folds a transition into an earlier one on the same resource; a lone same-state transition goes through unchanged. A possible fix: when `layout_state(before) == layout_state(after)`, record no transition, and record `Barrier::Uav { res }` when the layout is `UNORDERED_ACCESS` (the wait the barrier stands for). That matches what `join` already does when two transitions cancel out on `UNORDERED_ACCESS`. A test that runs `enhanced()` on a UAV -> UAV texture group would cover it. Context: on `main` I found no host code that calls `Barrier` / sets `LayoutBefore`, so this only matters once a recorded stream contains enhanced barriers. That is the case this pull request is for, though. Not checked: a full record/replay round trip, and the game. GPUs tested: the default hardware adapter (device-level `ResourceBarrier` / `Close` check only). AI-assisted: yes (Claude Code).
merzleckeier commented 2026-12-01 17:44:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T17:44:27Z.


Recorder check for equivalent single-subresource barriers at e18eeaf6e + d2a564b66 (Win64, Wine 11.22 / VKD3D-Proton 3.1.0). The 25 existing replay:: tests passed in both adapter configurations.

A separate test calls ID3D12GraphicsCommandList7::Barrier, closes the list and decodes the captured commands. The synthetic RGBA8 texture has two mips and two array slices. It specifies mip 1, slice 1, plane 0 in two equivalent ways. With NumMipLevels = 0, the flattened index 3 records transition subresource 3. With all three counts set to 1, the explicit range records 0xffffffff (all subresources). Main emits no recorded barrier in either case. The results match on AMD Radeon (RADV 26.3.1) and GeForce RTX 4070 SUPER (620.73.4 as reported by Wine).

NumMipLevels > 0 selects the range form even when that range contains only one subresource. A local trial flattened the 1×1×1 range using the texture descriptor and recorded subresource 3 in both forms on both adapters. The test checks the captured commands before queue submission.

MEASURED with a synthetic texture. AI-assisted (Codex). D3D12 subresource-range documentation

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7319775690 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7319775690). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T17:44:27Z. --- Recorder check for equivalent single-subresource barriers at `e18eeaf6e` + `d2a564b66` (Win64, Wine 11.22 / VKD3D-Proton 3.1.0). The 25 existing `replay::` tests passed in both adapter configurations. A separate test calls `ID3D12GraphicsCommandList7::Barrier`, closes the list and decodes the captured commands. The synthetic RGBA8 texture has two mips and two array slices. It specifies mip 1, slice 1, plane 0 in two equivalent ways. With `NumMipLevels = 0`, the flattened index 3 records transition subresource 3. With all three counts set to 1, the explicit range records `0xffffffff` (all subresources). Main emits no recorded barrier in either case. The results match on AMD Radeon (RADV 26.3.1) and GeForce RTX 4070 SUPER (620.73.4 as reported by Wine). `NumMipLevels > 0` selects the range form even when that range contains only one subresource. A local trial flattened the 1×1×1 range using the texture descriptor and recorded subresource 3 in both forms on both adapters. The test checks the captured commands before queue submission. MEASURED with a synthetic texture. AI-assisted (Codex). [D3D12 subresource-range documentation](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_barrier_subresource_range)
KelboLive commented 2026-12-01 17:52:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T17:52:58Z.

Review: CHANGES_REQUESTED


Blocking: the texture path records a transition even when both layouts stand for the same state, and D3D12 rejects that at Close().

layout_state collapses UAV→UAV to 0x8→0x8, UNDEFINED→COMMON to 0x0→0x0, and DIRECT/QUEUE SHADER_RESOURCE→SHADER_RESOURCE to 0xC0→0xC0 (record.rs:2359-2365), and enhanced() emits a Transition unconditionally (:2420-2431). On a 4070 Ti SUPER I get E_INVALIDARG (0x80070057) for 0x8→0x8, 0x4→0x4, 0x0→0x0 and 0xC0→0xC0, with and without the debug layer (debug says "Before and after states must be different"), while the enhanced COMMON→UAV / UAV→UAV pair closes Ok and a control 0x8→0xC0 is fine. play.rs's close propagates the error (:2402-2414, "a list of the frame could not be recorded again"), so one such barrier aborts the whole frame's replay. Before this PR the call was merely skipped (noted_entry, hook.rs:231) and the capture still replayed — so this regresses the UAV→UAV case the PR exists for.

edit::join only folds a pair of matching transitions (edit.rs:126-155), so a lone same-state barrier survives, and merge_barriers is off by default anyway.

Fix: emit no transition when before == after, plus Barrier::Uav when the layout is UAV. And test enhanced() itself — replacing after: layout_state(b.LayoutAfter) with b.LayoutBefore still passes all 25 replay:: tests, which is exactly why CI cannot see this.

Second, smaller issue: a buffer barrier becomes a UAV barrier even when its access masks are copy/vertex/index/…, and a legacy UAV barrier only orders UAV accesses — so "never fewer" does not hold there. A global alias+UAV flush would be the conservative legacy stand-in.

Minor: from_raw_parts(ptr, 0) per group (:2403, :2418, :2436) is UB if NumBarriers == 0 with a null pointer; the new test only asserts layout_state values (no PRESENT/SHADING_RATE_SOURCE/video); and the "tested via cargo test --test replay" claim does not exercise enhanced() at all — tests/replay.rs builds frames directly.

The GLOBAL mapping is right: Alias(NONE,NONE)+Uav(NONE) matches the non-enhanced fallback in wait_for_all (play.rs:2342-2370, :3392, :3376). Merge is clean against current main, and no other open PR touches replay/record.rs.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6136870808 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#pullrequestreview-6136870808). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T17:52:58Z. **Review:** CHANGES_REQUESTED --- Blocking: the texture path records a transition even when both layouts stand for the same state, and D3D12 rejects that at `Close()`. `layout_state` collapses UAV→UAV to `0x8→0x8`, UNDEFINED→COMMON to `0x0→0x0`, and DIRECT/QUEUE SHADER_RESOURCE→SHADER_RESOURCE to `0xC0→0xC0` (`record.rs:2359-2365`), and `enhanced()` emits a `Transition` unconditionally (`:2420-2431`). On a 4070 Ti SUPER I get `E_INVALIDARG (0x80070057)` for `0x8→0x8`, `0x4→0x4`, `0x0→0x0` and `0xC0→0xC0`, with and without the debug layer (debug says "Before and after states must be different"), while the enhanced COMMON→UAV / UAV→UAV pair closes Ok and a control `0x8→0xC0` is fine. `play.rs`'s `close` propagates the error (`:2402-2414`, "a list of the frame could not be recorded again"), so **one such barrier aborts the whole frame's replay**. Before this PR the call was merely skipped (`noted_entry`, `hook.rs:231`) and the capture still replayed — so this regresses the UAV→UAV case the PR exists for. `edit::join` only folds a *pair* of matching transitions (`edit.rs:126-155`), so a lone same-state barrier survives, and `merge_barriers` is off by default anyway. Fix: emit no transition when `before == after`, plus `Barrier::Uav` when the layout is UAV. And test `enhanced()` itself — replacing `after: layout_state(b.LayoutAfter)` with `b.LayoutBefore` still passes all 25 `replay::` tests, which is exactly why CI cannot see this. Second, smaller issue: a **buffer** barrier becomes a UAV barrier even when its access masks are copy/vertex/index/…, and a legacy UAV barrier only orders UAV accesses — so "never fewer" does not hold there. A global alias+UAV flush would be the conservative legacy stand-in. Minor: `from_raw_parts(ptr, 0)` per group (`:2403`, `:2418`, `:2436`) is UB if `NumBarriers == 0` with a null pointer; the new test only asserts `layout_state` values (no PRESENT/SHADING_RATE_SOURCE/video); and the "tested via `cargo test --test replay`" claim does not exercise `enhanced()` at all — `tests/replay.rs` builds frames directly. The GLOBAL mapping is right: `Alias(NONE,NONE)+Uav(NONE)` matches the non-enhanced fallback in `wait_for_all` (`play.rs:2342-2370`, `:3392`, `:3376`). Merge is clean against current main, and no other open PR touches `replay/record.rs`.
aznohonza commented 2026-12-01 18:18:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T18:18:56Z.


Thanks for the device check — you were right, and that exact case is fixed in 33d9b4f61 (merged with main 7fbdf8511).

When layout_state(before) == layout_state(after), enhanced() now records Barrier::Uav { flags: 0, res } if the state is UNORDERED_ACCESS, and records nothing otherwise. A UAV -> UAV texture group is covered by same_state_texture_barriers_are_a_wait_or_nothing, which also checks UNDEFINED -> COMMON and DIRECT_QUEUE_SHADER_RESOURCE -> SHADER_RESOURCE record nothing. The existing test runs under Wine here; the new one passes too.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320743475 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7320743475). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T18:18:56Z. --- Thanks for the device check — you were right, and that exact case is fixed in `33d9b4f61` (merged with `main` `7fbdf8511`). When `layout_state(before) == layout_state(after)`, `enhanced()` now records `Barrier::Uav { flags: 0, res }` if the state is `UNORDERED_ACCESS`, and records nothing otherwise. A UAV -> UAV texture group is covered by `same_state_texture_barriers_are_a_wait_or_nothing`, which also checks UNDEFINED -> COMMON and DIRECT_QUEUE_SHADER_RESOURCE -> SHADER_RESOURCE record nothing. The existing test runs under Wine here; the new one passes too. AI-assisted.
aznohonza commented 2026-12-01 18:18:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T18:18:57Z.


Thanks for the captured-command check — you were right about the range form, and it is fixed in 33d9b4f61 (merged with main 7fbdf8511).

With NumMipLevels > 0 and NumMipLevels == NumArraySlices == NumPlanes == 1, the range now flattens to first_mip + first_layer * MipLevels + first_plane * MipLevels * ArraySize using the resource's own descriptor (array size is 1 for 3D textures). Any wider range is still recorded as the whole resource, and the index form (NumMipLevels == 0) is unchanged. one_subresource_ranges_flatten_to_that_subresource covers mip 1 of slice 1, plane 1 of slice 1, 2 mips, the index form including 0xffffffff, and a 3D texture; it passes here under Wine.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320744115 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7320744115). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T18:18:57Z. --- Thanks for the captured-command check — you were right about the range form, and it is fixed in `33d9b4f61` (merged with `main` `7fbdf8511`). With `NumMipLevels > 0` and `NumMipLevels == NumArraySlices == NumPlanes == 1`, the range now flattens to `first_mip + first_layer * MipLevels + first_plane * MipLevels * ArraySize` using the resource's own descriptor (array size is 1 for 3D textures). Any wider range is still recorded as the whole resource, and the index form (`NumMipLevels == 0`) is unchanged. `one_subresource_ranges_flatten_to_that_subresource` covers mip 1 of slice 1, plane 1 of slice 1, 2 mips, the index form including `0xffffffff`, and a 3D texture; it passes here under Wine. AI-assisted.
merzleckeier commented 2026-12-01 18:27:21 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T18:27:21Z.


Follow-up device check for both texture-barrier fixes at 33d9b4f6 on main 7fbdf851 (Win64, Wine 11.22 / VKD3D-Proton 3.1.0). I reran the recorder comparison on AMD Radeon (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4 as reported by Wine).

  • On a synthetic two-mip, two-slice texture, flat index 3 and the equivalent explicit 1 × 1 × 1 range both recorded subresource 3, with the same before and after states.
  • A texture UAV-to-UAV layout barrier recorded exactly one resource-specific Barrier::Uav with flags 0. A separate list containing the equivalent native legacy D3D12_RESOURCE_BARRIER_TYPE_UAV closed successfully on both adapters.
  • The main control recorded no barriers for the three inputs. The updated PR passed all 27 stock replay:: tests in each adapter configuration, including both new targeted cases.

MEASURED with a synthetic texture. The scope was captured commands and command-list closure before queue submission. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320973317 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7320973317). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T18:27:21Z. --- Follow-up device check for both texture-barrier fixes at `33d9b4f6` on `main` `7fbdf851` (Win64, Wine 11.22 / VKD3D-Proton 3.1.0). I reran the recorder comparison on AMD Radeon (RADV 26.3.1) and RTX 4070 SUPER (NVIDIA 620.73.4 as reported by Wine). - On a synthetic two-mip, two-slice texture, flat index 3 and the equivalent explicit 1 × 1 × 1 range both recorded subresource 3, with the same before and after states. - A texture UAV-to-UAV layout barrier recorded exactly one resource-specific `Barrier::Uav` with flags 0. A separate list containing the equivalent native legacy `D3D12_RESOURCE_BARRIER_TYPE_UAV` closed successfully on both adapters. - The `main` control recorded no barriers for the three inputs. The updated PR passed all 27 stock `replay::` tests in each adapter configuration, including both new targeted cases. MEASURED with a synthetic texture. The scope was captured commands and command-list closure before queue submission. AI-assisted (Codex).
KelboLive commented 2026-12-01 18:29:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T18:29:59Z.

Review: COMMENTED


Re-checked at 33d9b4f61 (merged with main 7fbdf8511; merge-tree clean). The blocker is fixed: on a real 4070 Ti SUPER, enhanced() now records Uav for UAV→UAV and nothing for UNDEFINED→COMMON, DIRECT_QUEUE_SHADER_RESOURCE→SHADER_RESOURCE and RT→RT, and all four Close() calls return S_OK. A forced 0x8→0x8 control still returns E_INVALIDARG, so the probe can still see the original defect. replay:: is 27/0, and deleting the before == after branch now fails same_state_texture_barriers_are_a_wait_or_nothing — good red/green.

Two from the review remain, neither the original blocker:

  1. Buffer barriers with non-UAV masks are still a bare Uav (record.rs:2480-2489). I drove a COPY_DEST→COPY_SOURCE buffer barrier through the same path and it records [Uav { res }], which orders nothing for that transition. Either special-case only AccessAfter == UAV and use a global alias+UAV pair otherwise, or document that buffer barriers are assumed UAV-adjacent.
  2. enhanced() itself is still untested: swapping layout_state(b.LayoutAfter) for LayoutBefore at record.rs:2473 leaves all 27 replay:: tests green — the same mutation as before. The new tests cover texture_barrier(), not its call site. A test that builds a D3D12_BARRIER_GROUP and asserts the returned Vec<Barrier> would close both this and the buffer case.

Minor, unchanged: std::slice::from_raw_parts(ptr, 0) with a null pointer for a NumBarriers == 0 group (:2450, :2465, :2482).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6137500898 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#pullrequestreview-6137500898). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T18:29:59Z. **Review:** COMMENTED --- Re-checked at `33d9b4f61` (merged with `main` `7fbdf8511`; merge-tree clean). The blocker is fixed: on a real 4070 Ti SUPER, `enhanced()` now records `Uav` for UAV→UAV and **nothing** for UNDEFINED→COMMON, DIRECT_QUEUE_SHADER_RESOURCE→SHADER_RESOURCE and RT→RT, and all four `Close()` calls return `S_OK`. A forced `0x8→0x8` control still returns `E_INVALIDARG`, so the probe can still see the original defect. `replay::` is 27/0, and deleting the `before == after` branch now fails `same_state_texture_barriers_are_a_wait_or_nothing` — good red/green. Two from the review remain, neither the original blocker: 1. **Buffer barriers with non-UAV masks are still a bare `Uav`** (`record.rs:2480-2489`). I drove a `COPY_DEST→COPY_SOURCE` buffer barrier through the same path and it records `[Uav { res }]`, which orders nothing for that transition. Either special-case only `AccessAfter == UAV` and use a global alias+UAV pair otherwise, or document that buffer barriers are assumed UAV-adjacent. 2. **`enhanced()` itself is still untested**: swapping `layout_state(b.LayoutAfter)` for `LayoutBefore` at `record.rs:2473` leaves all 27 `replay::` tests green — the same mutation as before. The new tests cover `texture_barrier()`, not its call site. A test that builds a `D3D12_BARRIER_GROUP` and asserts the returned `Vec<Barrier>` would close both this and the buffer case. Minor, unchanged: `std::slice::from_raw_parts(ptr, 0)` with a null pointer for a `NumBarriers == 0` group (`:2450`, `:2465`, `:2482`).
aznohonza commented 2026-12-01 18:44:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T18:44:01Z.


Both points addressed in ba1828afe (merged with main 60f7dcd90):

  1. A buffer barrier now records the bare Uav only when AccessAfter is UNORDERED_ACCESS; every other access records the global alias + UAV pair that wait_for_all uses, so COPY_DEST -> COPY_SOURCE orders everything instead of nothing. The condition is stated in enhanced()'s comment.
  2. enhanced_records_its_texture_and_buffer_barriers builds real D3D12_BARRIER_GROUPs against a registered test resource and asserts the returned Vec<Barrier>: a UAV -> SRV texture at mip 1 of slice 1, a UAV -> UAV texture, and buffer barriers with and without a UAV access after. Swapping LayoutAfter for LayoutBefore at the call site now fails that test.
  3. Zero-barrier groups no longer call from_raw_parts with a possibly null array.

The six replay::record::tests pass here under Wine; CI is re-running.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7321438374 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7321438374). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T18:44:01Z. --- Both points addressed in `ba1828afe` (merged with `main` `60f7dcd90`): 1. A buffer barrier now records the bare `Uav` only when `AccessAfter` is `UNORDERED_ACCESS`; every other access records the global alias + UAV pair that `wait_for_all` uses, so `COPY_DEST -> COPY_SOURCE` orders everything instead of nothing. The condition is stated in `enhanced()`'s comment. 2. `enhanced_records_its_texture_and_buffer_barriers` builds real `D3D12_BARRIER_GROUP`s against a registered test resource and asserts the returned `Vec<Barrier>`: a UAV -> SRV texture at mip 1 of slice 1, a UAV -> UAV texture, and buffer barriers with and without a UAV access after. Swapping `LayoutAfter` for `LayoutBefore` at the call site now fails that test. 3. Zero-barrier groups no longer call `from_raw_parts` with a possibly null array. The six `replay::record::tests` pass here under Wine; CI is re-running. AI-assisted.
merzleckeier commented 2026-12-01 18:53:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T18:53:03Z.


Buffer-barrier follow-up on the updated recorder at ba1828af against 33d9b4f6, both on main 60f7dcd9. I recorded ID3D12GraphicsCommandList7::Barrier against a synthetic default buffer, closed the lists and decoded their commands on Radeon (RADV 26.3.1) and RTX 4070 SUPER (620.73.4 as reported by Wine).

  • Copy destination to copy source produced a resource-specific UAV barrier on the prior head. The updated head produced a global alias barrier and a global UAV barrier, matching the global copy control.
  • An unordered-access-to-unordered-access buffer barrier still produced one UAV barrier for the actual resource. A separate native legacy alias/UAV list closed successfully.
  • The complete stock replay:: selection now passes 28 tests per adapter setting, including the new recorder test.

MEASURED with a synthetic buffer under Win64 Wine 11.22 / VKD3D-Proton 3.1.0. Scope is recording and list closure before queue submission. AI-assisted (Codex).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7321739455 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7321739455). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T18:53:03Z. --- Buffer-barrier follow-up on the updated recorder at `ba1828af` against `33d9b4f6`, both on `main` `60f7dcd9`. I recorded `ID3D12GraphicsCommandList7::Barrier` against a synthetic default buffer, closed the lists and decoded their commands on Radeon (RADV 26.3.1) and RTX 4070 SUPER (620.73.4 as reported by Wine). - Copy destination to copy source produced a resource-specific UAV barrier on the prior head. The updated head produced a global alias barrier and a global UAV barrier, matching the global copy control. - An unordered-access-to-unordered-access buffer barrier still produced one UAV barrier for the actual resource. A separate native legacy alias/UAV list closed successfully. - The complete stock `replay::` selection now passes 28 tests per adapter setting, including the new recorder test. MEASURED with a synthetic buffer under Win64 Wine 11.22 / VKD3D-Proton 3.1.0. Scope is recording and list closure before queue submission. AI-assisted (Codex).
aznohonza commented 2026-12-01 19:14:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aznohonza on 2026-12-01T19:14:38Z.


Thanks for checking both buffer forms on both adapters — that is the intended split: a bare UAV barrier only when the access after is UAV, the global alias + UAV pair otherwise. Good to know the stock replay:: selection is 28/28 on each.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7322461787 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7322461787). Originally posted by [aznohonza](https://github.com/aznohonza) on 2026-12-01T19:14:38Z. --- Thanks for checking both buffer forms on both adapters — that is the intended split: a bare UAV barrier only when the access after is UAV, the global alias + UAV pair otherwise. Good to know the stock `replay::` selection is 28/28 on each. AI-assisted.
KelboLive commented 2026-12-01 19:48:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T19:48:52Z.

Review: COMMENTED


Re-checked at ba1828afe (merge-tree with current main ab374c7d5 is clean). Both re-review points are fixed on native Windows (4070 Ti SUPER):

  • Buffer ordering: COPY_DEST→COPY_SOURCE now records Alias{NONE,NONE} + Uav{NONE} (and the list closes S_OK), while UAV→UAV still records one resource-specific Uav (record.rs:2489). The old head recorded a single resource Uav for the copy case — also S_OK, which is why the HRESULT alone could not show the defect; the recorded set now does.
  • Call-site coverage: enhanced_records_its_texture_and_buffer_barriers (:3106) fails on the LayoutAfter→LayoutBefore mutation ([Uav] vs [Transition 0x8→0xC0]), and replay:: is 28/28 after reverting. That was the last unguarded wiring.
  • Zero-barrier groups now skip from_raw_parts entirely (:2447-2449), so the null-pointer case is gone.

Non-blocking, narrow: a buffer barrier with AccessBefore = COPY_DEST and AccessAfter = UNORDERED_ACCESS still takes the bare-Uav branch, and a legacy UAV barrier orders UAV accesses only — not the copy. If that pair occurs in practice, it needs the global alias+UAV pair too.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6138817668 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#pullrequestreview-6138817668). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T19:48:52Z. **Review:** COMMENTED --- Re-checked at `ba1828afe` (merge-tree with current main `ab374c7d5` is clean). Both re-review points are fixed on native Windows (4070 Ti SUPER): - **Buffer ordering**: `COPY_DEST→COPY_SOURCE` now records `Alias{NONE,NONE}` + `Uav{NONE}` (and the list closes `S_OK`), while `UAV→UAV` still records one resource-specific `Uav` (`record.rs:2489`). The old head recorded a single resource `Uav` for the copy case — also `S_OK`, which is why the HRESULT alone could not show the defect; the recorded set now does. - **Call-site coverage**: `enhanced_records_its_texture_and_buffer_barriers` (`:3106`) fails on the `LayoutAfter→LayoutBefore` mutation (`[Uav]` vs `[Transition 0x8→0xC0]`), and `replay::` is 28/28 after reverting. That was the last unguarded wiring. - **Zero-barrier groups** now skip `from_raw_parts` entirely (`:2447-2449`), so the null-pointer case is gone. Non-blocking, narrow: a buffer barrier with `AccessBefore = COPY_DEST` and `AccessAfter = UNORDERED_ACCESS` still takes the bare-`Uav` branch, and a legacy UAV barrier orders UAV accesses only — not the copy. If that pair occurs in practice, it needs the global alias+UAV pair too.
lixonik commented 2026-12-01 21:40:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-01T21:40:22Z.


Independent check of ba1828afe merged cleanly on main (1e3e316c5), on native Windows 10 Pro 22H2 (build 19045) + NVIDIA GeForce RTX 5070 12 GB (driver 621.40, Ryzen 9 5950X):

  • cargo test --locked -p leonida-gpu --features diagnostics --lib replay:: -- --nocapture: 28 passed, 0 failed, 0 ignored (including all four new enhanced-barrier tests: one_subresource_ranges_flatten_to_that_subresource, enhanced_layouts_record_as_the_states_they_stand_for, same_state_texture_barriers_are_a_wait_or_nothing, and enhanced_records_its_texture_and_buffer_barriers).
  • Zero new compiler warnings in replay/record.rs.

AI-assisted: Antigravity

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7326613547 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2906#issuecomment-7326613547). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-01T21:40:22Z. --- Independent check of `ba1828afe` merged cleanly on `main` (`1e3e316c5`), on native Windows 10 Pro 22H2 (build 19045) + NVIDIA GeForce RTX 5070 12 GB (driver `621.40`, Ryzen 9 5950X): - `cargo test --locked -p leonida-gpu --features diagnostics --lib replay:: -- --nocapture`: **28 passed, 0 failed, 0 ignored** (including all four new enhanced-barrier tests: `one_subresource_ranges_flatten_to_that_subresource`, `enhanced_layouts_record_as_the_states_they_stand_for`, `same_state_texture_barriers_are_a_wait_or_nothing`, and `enhanced_records_its_texture_and_buffer_barriers`). - Zero new compiler warnings in `replay/record.rs`. AI-assisted: Antigravity

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
ProjectLeonida/mandy!2906
No description provided.