d3d12-gpu: record enhanced barriers as the legacy ones they stand for #2962
Closed
github-bot
wants to merge 6 commits from
github-bot/gh-2962 into main
AGit
pull from: github-bot/gh-2962
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
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.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2962
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2962"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@aznohonza on GitHub · 2026-12-01 21:55 UTC · original
gpu/record-enhanced-barriers→main· +454 −1 · 1 files · 6 commits · closed without mergingRe-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.
@andrew-ai on GitHub · 2026-12-01 22:01 UTC · original
The partial-range shortcut changes the recorded state of untouched mips even when all subresources start in the same layout. I reproduced it at
ba1828afeusing 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 on GitHub · 2026-12-01 22:19 UTC · original · reviewed
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, andmerge-treeagainst current main is clean. No re-review needed. The only remaining item is non-blocking: a buffer barrier withAccessBefore = COPY_DEST, AccessAfter = UNORDERED_ACCESSstill records a bareUav, which does not order the copy. Approved in substance.@aznohonza on GitHub · 2026-12-01 22:28 UTC · original
Fixed in
a4a26ec63. The bareUavis now recorded only whenAccessAfteris UAV andAccessBeforeis UAV or NONE; a copy before it records the global alias + UAV pair, the same as the non-UAV case. The test coversCOPY_DEST -> UAV(alias pair),NONE -> UAV(bare), andCOPY_DEST -> COPY_SOURCE(alias pair); the sixreplay::record::testspass under Wine. Thanks for catching it.AI-assisted.
@merzleckeier on GitHub · 2026-12-01 22:41 UTC · original
The current recorder still widens a partial 3D mip range to ALL.
I reran
a4a26ec6320e52f2a3536b3b7be2d6a47c8773d4on main1abef08dwith #2975, whose files are separate from the recorder. All six stock recorder tests passed under Wine, including the updated bufferCOPY_DESTto UAV alias-plus-UAV case.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
Transition { sub: ALL, before: 8, after: 192 }. The next request for untouched mip 0 still producedTransition { sub: 0, before: 8, after: 1024 }(UAV to copy destination). Applying the first recording to the four mips puts mip 0 in shader resource, which disagrees with that second before-state.This fixture checks the CPU recorder with synthetic input. AI-assisted, independently verified against the raw results.
@aznohonza on GitHub · 2026-12-01 22:52 UTC · original
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
ALL. Collapsing toALLwrites the after-state into mips the range never named, which is exactly why the next barrier's before-state disagrees.That needs
texture_barrierto return a list rather than one barrier and a per-mip split for 3D ranges, so I would rather not squeeze it into this reviewed head. I will open a separate item for it (partial 3D mip ranges: one legacy transition per mip, with your synthetic depth-16/four-mip fixture as the test) and link this PR. The array-slice half you found earlier is the same flattening decision.AI-assisted.
@aznohonza on GitHub · 2026-12-01 23:21 UTC · original
The partial-range flattening is fixed in
replay/partial-mip-split(b1f4a8f6d, stacked on this branch until it lands; I will retarget it tomainand open the PR then, as promised above).What changed in
texture_barrier: it returns the list of legacy barriers the enhanced texture barrier stands for. A single-subresource range keeps the indexsubresourcegives; a partial range enumerates its mips × array slices × planes into one transition each; a range that covers the whole resource stays oneALLtransition.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 →
ALL, and the array-slice case → subresources 2 and 4. All sevenreplay::record::testspass under Wine; with the enumeration replaced by a singleALLtransition the new test fails.AI-assisted.
@MoonEyes on GitHub · 2026-12-02 12:32 UTC · original
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
@Kal0s-design on GitHub · 2026-12-02 13:31 UTC · original
Ran natively on Windows 11, head
a4a26ec63merged into currentmain(d0bf821fa, clean merge), pinned toolchain,cargo test -p leonida-gpu --features diagnostics --lib --locked. This goes past the closure checks in #2906. I executed the recorded barriers on a device with the debug layer and compared them with the enhanced originals. The partial-range flattening already reported above is left out. OnmaintheBarriercall is only counted as not recorded, so none of these inputs record anything there.Suites on the merge
replay::record::tests(6, incl. the 4 new)watch::tests::a_block_guarded_before_we_were_told_of_its_view_can_be_written, passed when rerun alone. That file is untouched and other builds were running in parallel--all-targets(diagnostics)record.rs. The 10 warnings are all in files this PR does not touchRecorded barriers executed with the debug layer
The throwaway test creates a 64x64 RGBA8 texture with 2 mips and 2 slices, starting in
COMMON. For each sequence, one copy of the texture gets the enhanced barriers throughID3D12GraphicsCommandList7::Barrier. A second copy gets whatenhanced()returns for the same barriers, issued withResourceBarrier. Both lists are executed, then the debug layer's errors are counted. The sync and access values are ones the debug layer accepts. WARP and the NVIDIA card gave identical results, and both reportEnhancedBarriersSupported.0→0x4,0x4→0xC0,0xC0→00→0xAC3,0xAC3→0x8,0x8→00→0x8, UAV,0x8→0xC0,0xC0→00→0x4,0x4→00→0x4,0x4→00→0x4,0→0x400,0x400→00→0x8,0→0x4,0x4→00→0x4,0→0x400,0x400→0Each error is id 527,
Before state (0x0: D3D12_RESOURCE_STATE_[COMMON|PRESENT]) ... does not match with the state (0x4: D3D12_RESOURCE_STATE_RENDER_TARGET) specified in preceding ResourceBarrier.The cause is
layout_statemappingUNDEFINEDto0(-1 | 0 => 0x0). That holds only when the texture really is inCOMMON.UNDEFINEDwithDISCARDis how a transient render target or UAV is normally reused from whatever layout it was left in, so the recorded transition names a before-state the resource is not in. Playback issues the recorded before-state unchanged (play.rs,Cmd::Barriers). The same mapping makesUNDEFINED → COMMONrecord nothing, which leaves the replayed texture in its old state while the title treats it asCOMMON. The before-state forUNDEFINEDhas to be the resource's actual state at that point in the list. The recorder's state tracking applies changes only when a list runs, so it does not directly give that state for a barrier earlier in the same list.enhanced()over the input space (CPU)I ran all 32 before-layouts (UNDEFINED and 0 to 30) against 31 after-layouts on the whole range. That gave 915 transitions, 9 UAV barriers and 68 empty results. Of the 40 empty results with different layouts, 4 are
UNDEFINEDto a COMMON-family layout (the case above). The other 36 are a queue-specific layout and its common form, withVIDEO_QUEUE_COMMONreaching0only through the catch-all arm.Two inputs record fewer waits than I would expect. These are questions for the author rather than observed corruption.
AccessBefore = D3D12_BARRIER_ACCESS_COMMON(0) →UNORDERED_ACCESSUav(res)AccessBefore = NO_ACCESS(0x80000000) →UNORDERED_ACCESSCOMMONwithCOPY_DEST → SHADER_RESOURCE,DIRECT_QUEUE_COMMONwithUAV → SHADER_RESOURCEorCOPY_DEST → COPY_SOURCE)The reply above describes the bare case as "
NONE -> UAV", but the code compares againstACCESS_COMMON, which is 0 and notNO_ACCESS. As I read the enhanced-barrier rules,ACCESS_COMMONbefore means any earlier access the layout allows, a copy write included, and a legacy UAV barrier does not order that. WasNO_ACCESSmeant there? For textures,texture_barrieronly compares the two mapped states, so a barrier that keeps the layout and changes only the access is dropped. Would the alias + UAV pair used for buffers be the right stand-in there? This is the other side of the same-state case I raised in #2906: not recording abefore == aftertransition fixes the list close, but when the access goes from a write to a read, some barrier is probably still needed.Every other buffer pair I tried matches the description.
UAV → UAVgives a bare UAV barrier.NO_ACCESS,COPY_DEST,SRV,UAV|SRVandUAV|COPY_DESTbefore, each againstUAV,SRVandUAV|SRVafter, give the alias + UAV pair.Not checked: the in-game run requested above; capture and playback of a real stream end to end (I called
enhanced()directly with a registered resource, as the PR's own test does); depth textures (DEPTH_STENCIL_READmaps to0x20only); a hardware data race for the two missing waits.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
@MoonEyes on GitHub · 2026-12-02 17:06 UTC · original
RUN (in game, batch of eleven render-path pull requests), each head merged with
git merge --no-ffonto main3c106eb2f, in one build: #3071c2065b540, #298265155eceb, #296400a068106, #310779333e26b, #2833823087ec3, #2947b07f64346, #291933e2e4c13, #2962a4a26ec63, #2847c8b950cb4, #3114c4ebe52de, #26640e2b6287c. RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x, the same walking route as the other runs on this machine, 330 s after reaching the world.For reference, the same machine and route rendered 13.3 to 17.2 fps today on main with single pull requests or other batches. These fps are a check that nothing fell over, not a measurement of a gain.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; free system memory was low (median 0.6 GB); arrival in the world was driven by keys and not checked on pictures. An earlier attempt of this batch is not counted: two runs were started at the same time by mistake on one GPU (no device loss in either, but the measure is not clean).
AI-assisted (Claude Code).
@MoonEyes on GitHub · 2026-12-02 18:00 UTC · original
Triage of head
a4a26ec63(merge base60f7dcd90, 355 commits behind;git merge-treeagainst currentmain45dc41f95: no conflicts).1 file:
d3d12/crates/leonida-gpu/src/replay/record.rs(+454/-1).CI green on the head (6 checks).
Existing verification: Verified on this head by @Kal0s-design (recorded barriers executed on a device with the debug layer) and in @MoonEyes's eleven-PR in-game batch on
3c106eb2f.This check: Open point from the thread: @merzleckeier showed a partial mip range of a 3D texture is still widened to
ALL; the author agreed and put the fix in a stacked branch (replay/partial-mip-split) to follow. That is a known limitation of the replay recorder (diagnostics), not of the render path; acceptable if the follow-up is tracked.I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.
Verdict: ready (verified on this head; 3D partial-mip follow-up tracked separately).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@fiestorra on GitHub · 2026-12-03 05:41 UTC · original
VERIFY-2962 — 454 líneas en
replay/record.rsy ningún test nuevo, con la suite en 643/1 (el 1 de la iGPU)El título: «record enhanced barriers as the legacy ones they stand for» — grabar las barreras enhanced como las legacy que representan.
Y eso es una traducción entre dos dialectos de la misma idea — el mismo género que
#2686(latches paradxil-spirv) y#2800(cadenas canónicas): el runtime emite una forma moderna, el grabador guarda una forma que el reproductor entiende, y la equivalencia entre las dos tiene que ser exacta.Lo que me hace pedir un test, y no es una preferencia: una equivalencia entre dos enumeraciones es una tabla —
enhanced → legacypara cada estado y cada acceso — y una tabla se verifica con una tabla. 454 líneas sin una sola prueba nueva, en el único sitio de esta noche donde la respuesta es mecánica, es lo que no cuadra.Lo que verifiqué: la suite con el cambio — 643 pasan (su base es más vieja que la de
main, de ahí el número) y la única falla es la de la iGPU. No lo verifiqué con un test porque no hay.Y la pregunta que le haría: ¿el grabador puede producir una combinación
enhancedsin equivalente legacy? Si la respuesta es sí, ese caso es una barrera perdida al reproducir y no una traducción; y si es no, hay una tabla que se puede escribir en veinte líneas.Pull request closed