Repository navigation
Conversation
`ID3D12GraphicsCommandList7::Barrier` was in the recorder's not-recorded list, so a recorded stream lost those ordering points on replay. Hook it and record each group as the legacy barriers the runtime already uses for the same wait: a global one as the alias + UAV pair `play::wait_for_all` falls back to, a texture one as a transition between the states its layouts stand for, a buffer one as a UAV barrier on the whole buffer (D3D12 requires offset 0 and the whole size). A texture subresource range that names more than one subresource is recorded as the whole resource: a legacy transition carries one subresource. That is conservative and stated in the code, with the condition to revisit it. The mapping's test covers every layout and both queue-specific forms.
A transition to the state a resource is already in is invalid (E_INVALIDARG, even with the debug layer off), and enhanced barriers often keep the layout: two UAV dispatches are the common case. Record the UAV barrier that wait stands for instead, and nothing at all when both layouts stand for the same other state. This matches what `join` does when two transitions cancel out. A range with a non-zero `NumMipLevels` can still name exactly one subresource. When all three counts are 1, flatten it to that subresource with the resource's own mip and array sizes instead of recording the whole resource. The subresource-index form is unchanged. Both rules are a pure helper, tested without a device.
KelboLive's re-review: a buffer barrier whose access after is not UAV was recorded as a bare UAV barrier, which orders nothing for, say, COPY_DEST -> COPY_SOURCE; it now records the same global alias + UAV pair as a global barrier. A zero-barrier group no longer makes a slice from its (possibly null) array either. The new test drives `enhanced()` itself through a texture group (which also catches a swapped LayoutBefore/LayoutAfter at the call site) and a buffer group in both forms. AI-assisted: yes
|
The partial-range shortcut changes the recorded state of untouched mips even when all subresources start in the same layout. I reproduced it at ba1828a using the existing two-mip, two-array-slice fixture in enhanced_records_its_texture_and_buffer_barriers.
I passed the range through enhanced() and round-tripped its Cmd::Barriers through the current wire encoder and decoder. Applying the decoded first command to a four-entry state table yields [SRV, SRV, SRV, SRV]. The second recorded transition expects UAV at index 0. Encoding the first command as two existing legacy transitions (indices 2 and 3) round-trips intact and yields [UAV, UAV, SRV, SRV], matching the second transition. For a known texture descriptor, expanding a partial range into per-subresource transitions fits the existing wire format. ALL can still represent a range that actually covers the whole resource. This was a CPU-side recorder/codec test with synthetic inputs; it did not submit commands to a GPU. Codex-assisted for #2570. |
KelboLive
left a comment
There was a problem hiding this comment.
Same head (ba1828afe) as #2906, which I reviewed through three rounds — the blocker there (same-state texture transitions) was fixed and verified on a real device, and merge-tree against current main is clean. No re-review needed. The only remaining item is non-blocking: a buffer barrier with AccessBefore = COPY_DEST, AccessAfter = UNORDERED_ACCESS still records a bare Uav, which does not order the copy. Approved in substance.
…s pair A legacy UAV barrier orders UAV accesses only, so a bare Uav is enough only when the access before is UAV (or NONE). A copy before it records the global alias + UAV pair, as the non-UAV case already did. The test covers COPY_DEST -> UAV, NONE -> UAV, and COPY_DEST -> COPY_SOURCE; the six replay::record::tests pass under Wine. AI-assisted.
|
Fixed in AI-assisted. |
|
The current recorder still widens a partial 3D mip range to ALL. I reran The earlier array-slice finding also applies to a known 3D texture. My synthetic descriptor used depth 16 and four mips. Asking the production converter to transition only mips 1 and 2 from UAV to shader resource produced This fixture checks the CPU recorder with synthetic input. AI-assisted, independently verified against the raw results. |
|
Thanks for the 3D case — you are right, and it is a real limitation, not a fixture artifact: a partial mip range of a 3D texture is several subresources (one per mip), and the legacy encoding needs one transition per subresource, not That needs AI-assisted. |
|
The partial-range flattening is fixed in What changed in The test is the synthetic depth-16, four-mip 3D fixture from @merzleckeier: mips 1–2 → transitions for subresources 1 and 2, untouched mip 0 → subresource 0, whole-resource range → AI-assisted. |
Re-created from the original #2906.
aznohonza/mandy-contribwas made private at 21:41 UTC on 2026-12-01, which detached the fork and permanently closed its pull requests; GitHub refuses to reopen them (422 state cannot be changed). Same branch, same headba1828afe3600716e20c81cc9ce2e4c77523b5a3. The original review thread is at #2906.replay/record.rslistedID3D12GraphicsCommandList7::Barrieras 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:play::wait_for_allfalls back to on a device without enhanced barriers.D3D12_RESOURCE_STATESits 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).The wire already carries
Cmd::Barriers, and playback already issues those legacy barriers, so nothing changes inplay.rsorwire.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_statecovers every layout and both queue-specific forms;enhanced_records_its_texture_and_buffer_barriersdrivesenhanced()itself with texture and buffer groups,same_state_texture_barriers_are_a_wait_or_nothingcovers the same-state forms, andone_subresource_ranges_flatten_to_that_subresourcethe range forms.The workspace also checks with the default features (
cargo xwin check --target x86_64-pc-windows-msvc --workspace --all-targets --locked). Replay is behind thediagnosticsfeature, so that unit test runs withcargo 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.