d3d12: keep RDNA2's 2 GB aperture segment from filling (device lost at the first heavy scene with relay 2) #2670
Closed
github-bot
wants to merge 9 commits from
github-bot/gh-2670 into main
AGit
pull from: github-bot/gh-2670
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!2670
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2670"
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?
@amujark on GitHub · 2026-11-30 01:27 UTC · original
amujark:fix/rdna2-aperture-segment→main· +588 −40 · 9 files · 9 commits · closed without mergingClaimed in the coordination issue as: D3D12-RDNA2-APERTURE-SEGMENT (#2570)
What and why
On an RDNA2 card with the default play settings (
LEONIDA_RELAY=2) the host device is removed at the first heavy scene (the opening cinematic):0x887A0007, DRED breadcrumbs empty, "nothing of ours was running on the card", with about 1,250-1,270 host lists alive. It happened in every run, andmainalone does it 72 s in even withLEONIDA_BURY_LAG=16.LEONIDA_RELAY=0survives, at about 8 fps.This is the failure of PastiiJay/klbf-lab#127. The video memory manager's 2 GB aperture segment, which DXGI's budgets leave out, holds the driver's command buffers (1 MB and more per command list).
land()kept the lists of the lastbury_lag()flights, and every host list kept its own prelude for life, so the segment ran full and the scheduler marked the device faulted.The fix is ported by hand from kyokyotosh/VIctory-6700XT (GPL-3.0, as this tree), one commit each, attributed in the messages and the doc comments:
f173347: the host lists of landed flights go back to the pool at once (list::recycle_landed). What their commands named (Held: the wholeDeferred, the texture states, twins and refreshes being found, and theDetached's descriptor state and uploads) waitsbury_lag()throughretire. Both the reaper thread and the path without it use it.018d372:host/segments.rsreads the adapter's segments withD3DKMTQueryStatistics(Wdk_Graphics_Direct3Dfeature). They are logged once at device creation and looked at every 100 ms at most. While an aperture segment holds more thanLEONIDA_SEGMENT_TIGHTpercent of its limit,send_latelands the flights in the air.e3c0703: it is looked at on every send, with hysteresis: tight from 80 % by default, clear below 70 % (0: never). While tight, idle host lists are trimmed to 64, with their bytes taken out of the pool's count. The threshold is a pure function (is_tight) with unit tests.63a773e: preludes come from a pool. One is taken when a list is first submitted with transitions and given back at its reset; 128 are kept idle, 16 while tight. The pool keeps each allocator's creation instant, soLEONIDA_ALLOCATOR_TRIMstill sees its real age.LEONIDA_LAZY_PRELUDE=0still makes one with the list.There is one more change, in the launcher. With the fix and relay 2 on the same card, the lighting rose and fell with where the camera looked and went black, which looks like the automatic exposure reading a late value. The same build in the same place with
LEONIDA_RELAY_COPY=0looked right at 17-20 fps.d3d12/scripts/play-nvidia.ps1setsLEONIDA_RELAY_COPY=1for every card; it now leaves it out on Radeon RX 6000 cards.-More @{LEONIDA_RELAY_COPY='1'}still puts it back (checked with-DryRun). Only the RX 6800 XT is measured.Tested
RX 6800 XT, one run each, Series S profile,
-Log, pipelines already cached:main452d1d1b6, relay 2,LEONIDA_BURY_LAG=16LEONIDA_RELAY_COPY=0(the last commit's default here)cargo test -p leonida-gpu: 556 passed, 1 failed, 47 ignored. The failure,descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in, fails the same way onmain452d1d1b6. The newhost::segments::tests::*andlist::tests::a_trim_keeps_the_first_and_takes_the_restpass.cargo check -p leonida-gpuand--features diagnostics: ok.cargo clippy -p leonida-gpu --features diagnostics: no new warnings in the changed lines.cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc: ok.python -I scripts/check_no_game_data.pyon the changed files: pass. The branch is onmain452d1d1b6and merges cleanly withmain0eab02a8b.GPUs tested: AMD Radeon RX 6800 XT, Adrenalin 32.0.21045.29003, Windows 11 (Ryzen 9 5950X, 32 GB)
AI-assisted: yes (Claude Code)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)On an RX 6800 XT with relay 2 and the launcher's default settings the lighting rose and fell with where the camera looked and ended black (the automatic exposure seems to read a late value). The same build and place with LEONIDA_RELAY_COPY=0: the light right at 17 to 20 fps (relay 0 is right too, at 8 fps). Measured 2026-11-30 on that card only. play-nvidia.ps1 now drops LEONIDA_RELAY_COPY from its defaults when the card name matches Radeon RX 6000; the card name is read once and shared with the frame generation check. -More @{LEONIDA_RELAY_COPY='1'} is applied after and still wins. AI-assisted.@merzleckeier on GitHub · 2026-11-30 01:34 UTC · original
I reproduced a launcher edge case with mixed Radeon and NVIDIA adapters. With both an RTX 4070 SUPER and RX 6800 XT in the controller inventory,
-Adapter 'RTX 4070'still emitsLEONIDA_ADAPTER=RTX 4070, butLEONIDA_RELAY_COPYis now unset at launch and after replaying the F1 command. A savedLEONIDA_ADAPTER=RTX 4070produces the same result.main40e7fe69and after merging1462e3e8(6be18311). Main emitsLEONIDA_RELAY_COPY=1in all controls. The PR retains1with the RTX alone, omits the setting with the RX 6800 XT alone, and omits it on the mixed setup with either card selected. An explicit savedLEONIDA_RELAY_COPY=1still wins on the mixed setup.#indexselectors. Basing the default on the resolved DXGI adapter would keep the workaround scoped to the selected card. Launcher rule · DXGI selection845e0208) gives the same relay settings. In all six cases across three runs,-MotionBlursurvives the F1 replay, and the four motion-blur passes stay enabled.This checks launcher settings with synthetic inputs. Aperture pressure and rendering were outside the probe. AI-assisted with OpenAI Codex.
@bobcatchris on GitHub · 2026-11-30 01:50 UTC · original
Independent verification on native Windows 11 Pro (
10.0.26200) + AMD Radeon RX 7900 XTX (gfx1100, driver32.0.32029.2010, Rust1.98):1462e3e8dcleanly ontomain(40e7fe69d) — zero conflicts.cargo test -p leonida-gpu --lib -- --test-threads=4—558 passed; 0 failed; 47 ignored(12.93s), including the newhost::segmentstests.python -I scripts/check_no_game_data.pyon all 6 touched files — PASS.AI-assisted: Antigravity (Gemini 4 Neon)
@amujark on GitHub · 2026-11-30 08:12 UTC · original
Thanks, you were right: the launcher judged by every controller in the PC, not by the card the game plays on. Fixed in
077d6084c, as you suggested, by moving the decision to the runtime:play-nvidia.ps1, andplay.ps1, which had the same default) now setLEONIDA_RELAY_COPY=autoinstead of1, andplay-nvidia.ps1no longer removes it by the controller list.host.rs: when the host device is made, the adapter it is on (EnumAdapterByLuid(device.GetAdapterLuid()), so the default card,LEONIDA_ADAPTERby name and the F1 menu's#indexall count) is checked: AMD vendor id0x1002andRX, optional spaces,6and three digits in DXGI's description (the launcher's oldRX\s*6\d\d\d). Underauto,relay_copy()is off only on such a card and logs which way it went. If the adapter cannot be read it stays on, which was the default before this branch. Its one caller (make_relay_fetch) runs on aHost, after the device exists.1or0still wins: the F1 file and-Moreare applied over the launcher'sauto, and the runtime only treatsautoby card.d3d12/README.mdlists the variable.What was tested:
cargo test -p leonida-gpu --lib -- rx6000 every_line_fits values_cycle: 3 passed (a new table test of the name rule: RX 6800 XT, RX 6700M, RX6600 yes; RX 7900 XTX, RX 580, Radeon(TM) Graphics, an NVIDIA name, "RX 6800" with NVIDIA's vendor id and WARP no; plus the menu's width and cycling tests).play-nvidia.ps1 -DryRun:LEONIDA_RELAY_COPY=autoplain and with-Adapter 'RTX 4070'(which also printsLEONIDA_ADAPTER=RTX 4070);-More @{LEONIDA_RELAY_COPY='1'}prints1.autoshould give what the previous commit gave (relay copy off), which is what the light was measured with.Left as it is: the frame-generation default a few lines below (
$card -match 'RTX\s*(40|50)\d\d') reads the same joined list, so on a mixed PC it can turn on DLSS frame generation while the game runs on the Radeon. That is onmainalready and outside this PR.AI-assisted (Claude Code).
github-bot referenced this pull request2026-11-30 10:02:41 +00:00
@lerapeurdu62280-debug on GitHub · 2026-11-30 18:25 UTC · original
Game-run A/B on Windows AMD RDNA2 (RX 6600 8 GB), the profile this PR is about.
n=1each, and one difference in the caches I could not avoid (below), so read it as a first data point, not a proof.tested: #2670 on RX 6600 8 GB (Windows, AMD 32.0.21045.29003), better: story load + device lost at ~180 s / play for ~290 s, closed by hand, no device lost.
The caveat: B started with every pipeline A and the warm step had made, and made none in play, while A still made 69 in play. Both device losses on
mainon this card (also the cold run in #2464) came while pipelines were being made in play, so part of the difference may be the cache, not this PR. A cleaner pair would be A and B both from the same emptied pipeline cache; I can run that if it helps.Contribution : EI S.O.S INFO LUDO
@lerapeurdu62280-debug on GitHub · 2026-11-30 18:46 UTC · original
The cleaner pair, as offered above: A and B from the same emptied caches (Leonida's
pipelinesfolder and AMD'sDxcCachemoved aside before each run), so neither starts with pipelines the other made.tested: #2670 on RX 6600 8 GB, better: device lost ~240 s after the story pack opened / no device lost through ~380 s, closed by hand. Same caches state this time, so the cache caveat of my first comment does not apply here. Still
n=1per side. The frame rate is the same in both (0.2 fps while pipelines are made in play); this PR does not change that, nor should it.Contribution : EI S.O.S INFO LUDO
@amujark on GitHub · 2026-11-30 20:54 UTC · original
Added
aace3e264: while an aperture segment is tight, the trim this PR adds froze the line of submissions and the title's present for 150-260 ms.What happened.
trim_idle()andtrim_preludes()ran inline on the submitting thread at the first submission aftersegments::tightturned true. They freed up to ~448 idle host lists and ~112 preludes there, and freeing them is the graphics kernel's time. TwoLEONIDA_TIMELINEcaptures showed it:tight=true/tight=falsepair in the log exactly;The change. The same objects are taken out under the same locks, by the same decision. Only their drop moves to a thread of its own,
leonida-trim. It is not the reaper, which can sit in 70-100 ms spans.LEONIDA_TRIM_ASYNC=0gives the old behaviour.LEONIDA_ABcan switch it live.Measured on an RX 6800 XT (driver 32.0.21045.29003), Ryzen 9 5950X, Series S profile, relay 2, FSR 3.1:
Tests.
trim_tests,host::segmentsand the trim test inlist.rs: 9 passed, with and without--features diagnostics. The diag build passes.AI-assisted.
@merzleckeier on GitHub · 2026-12-01 13:43 UTC · original
Checked the release-thread behavior with a real D3D12 buffer at
aace3e264+9f27ba2e1. I passed a 64 KiB hardware buffer throughlet_go_apartand held its destruction behind a channel handshake. WithLEONIDA_TRIM_ASYNC=1, the caller returned while the destructor was still held onleonida-trim. With0, the destructor ran on the caller and it returned only after release. Both arms passed on AMD RADV and RTX 4070 SUPER under Wine 11.22. The seven aperture-policy unit tests passed as well. This isolates ownership and scheduling of the release. Native RDNA2 aperture pressure and frame times remain outside this run.AI-assisted with OpenAI Codex (GPT-6).
@KelboLive on GitHub · 2026-12-01 14:49 UTC · original · reviewed
Independent check on Windows (Ryzen 9 7950X3D, RTX 4070 Ti SUPER, rustc 1.98.1) at
aace3e264.cargo test --locked -p leonida-gpu --lib -- --test-threads=4: 559 passed, 0 failed, 47 ignored; the author'sviews_are_made_beside_the_heap_and_copied_infailure passes here, so it is not a regression from this PR. Merged onto current main (tree18cdc655): 641 passed, 0 failed, 59 ignored,merge-treeclean,check_no_game_dataanddiff --checkclean, both launcher scripts parse.take_heldretired (host.rs:5030-5047,list.rs:398-408,:8599-8606), the aperture is polled at most every 100 ms (segments.rs:115-124), 80/70 hysteresis is enforced with strict>and safe at 0 (:95-101,:149-199), and the 64-list/16-prelude trims fire only while tight (list.rs:353-365,host.rs:1726,:1745).it_stays_tight_ten_points_below_the_percentanda_percent_under_ten_does_not_wrap_when_it_was_tight(7 → 5 passed, 2 failed). The guard is covered.One gap worth closing, because it is the actual fix: the lifetime change has no test that would go red if landed lists were held again. A test that counts a landed flight returning its list to the pool (drop/recycle counter) would cover
recycle_landed/take_held, which is the part that stops the aperture filling — the segment polling and hysteresis are well covered by comparison.As the body says, the device-loss and perf claims are RX 6800 XT-only; this machine cannot reproduce them, and the code-level evidence above is what can be checked without that card.
@lerapeurdu62280-debug on GitHub · 2026-12-01 20:20 UTC · original
Test report on RDNA 2 (RX 6600 8 GB), PR head
aace3e264merged on top ofmainlocally (rebuilt at 18:41 UTC+1 today, with #2764 / #2828 / #2865 / #2904 from main).Setup: AMD Radeon RX 6600 8 GB (driver 32.0.21045.29003), Ryzen 5 3600, 32 GB RAM, Windows 11 build 26300.
scripts/play-d3d12.ps1 -SeriesSwith FSR 3.1,LEONIDA_SUBMIT_FRAMES=0. Retail game data.What I saw (5 sessions today, about 2 h of play in total, longest 51 min):
host::segmentsat device creation0x887A0007Relay stage: stage 2 in every session (
LEONIDA_RELAY=2in the settings line, or unset = default;exact=true). Side note: with relay 2 set, thehostinfo line "what shaders wrote is copied back by a thread of its own … (LEONIDA_RELAY=1)" reads as if relay 1 were set, which confused me at first.Guard off (A/B): same build, same save,
LEONIDA_RELAY=2+LEONIDA_SEGMENT_TIGHT=0, 12 min of play: aperture segment at most 30 MB / 2048 MB, no device removed, 17.3 fps average, 4.3 % of frames over 100 ms.Reading: on this RX 6600 with current
main+ this PR, the 2 GB aperture segment never comes close to filling, with or without the guard, and I could not reproduce the device loss. So on this card the guard is harmless but I can't confirm it is what prevents the loss; the other parts of the PR were not turned off in the A/B. A run of plainmainwithout the PR would be the next step if you want one.AI-assisted (Claude). EI S.O.S INFO LUDO
@MoonEyes on GitHub · 2026-12-02 11:50 UTC · original · edited 2026-12-02 11:51 UTC
Closing: this pull request no longer applies to current
main(merge conflict ind3d12/crates/leonida-gpu/src/host.rs), and open pull requests that have fallen out of step withmainare being closed so the list stays workable. If you still want this change, rebase it on currentmainand reopen it (or open a new pull request); it will be looked at again.AI-assisted (Claude Code).
@lerapeurdu62280-debug on GitHub · 2026-12-02 12:26 UTC · original
@amujark this was closed only for the
host.rsconflict, and the fix is still needed on RDNA 2 (my report above: RX 6600 8 GB, about 2 h of play without the device lost at the first heavy scene).In case it saves you time: I resolved that conflict on 2 December (main's reaper kept, with this PR's
recycle_landedand preludes in reserve) onlerapeurdu62280-debug/mandy:notre/2670, based on2705632c5. It still merges cleanly on today's main (f6dd2242e). Your commits are kept as they are, so you can rebase onto it or take only the resolution, and reopen.Contribution : EI S.O.S INFO LUDO
Pull request closed