d3d12/gpu: a released target at a shared address leaves the older one found (D3D12-TARGETS-AT-RESTORE) #3054
Open
github-bot
wants to merge 1 commit from
github-bot/gh-3054 into main
AGit
pull from: github-bot/gh-3054
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!3054
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3054"
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?
@upipibi on GitHub · 2026-12-02 06:16 UTC · original
upipibi:d3d12/targets-at-restore→main· +117 −7 · 1 files · 1 commits · openD3D12-TARGETS-AT-RESTORE, item 5 of @zmasi's finding (#2570). Claim: #2570
What was wrong
TARGETS_AT(resource.rs) maps an address to the texture the host writes (a target, depth, or unordered access) that was made there.alias_sourcelooks it up so that a view the title places in that memory, in another format, reads the host's texture rather than title memory. The table held one texture per address:targets.insert);targets.remove), although the first was still alive.From then on, a view over the first texture found nothing. It read title memory, which shaders never wrote.
What it changes
TARGETS_ATkeeps every live texture made at an address, newest last. The newest is the one found, as before, so nothing changes while both are alive.targets_put/targets_take: a release removes only that texture. If it was the newest, the one made before it is found again.levels_changed(at)runs only when the texture found atatchanges, as before.TARGETS_CHANGEDis raised before every release that touches the table: a raise with no change only makes the quick path (LEONIDA_ALIAS_QUICK) look again.One file, no new switch. The behaviour differs from
mainonly after the newer of two live textures at one address is released.When the older texture is the right answer. Once the newer texture is released, what it drew is in neither place: its host copy goes with it, and shader writes to a target reach title memory only for the kinds
texbackcopies back. The older texture is still alive, and whatever the title draws into it next lands in its host copy and nowhere else. A view placed there now sees those draws. Onmainit read title memory and never saw them. The texture found now depends only on which targets are alive, not on the order they were released.main's answer is better only when the memory is refilled by the CPU or by a copy after the release and the older target is not drawn into again.mainalready behaves that way whenever the older target is the only one at that address.How it was tested
RTX 3070 8 GB, driver 621.40, Windows 11 24H2. No game files.
resource::tests::releasing_the_newer_texture_at_an_address_finds_the_older_again(diagnostics, on the device), run with and without the quick path (ALIAS_QUICK_TEST): texture A, then B made at A's address, then a placed view there. The view finds B; after B is released, it must find A again; after A is released, nothing.main's release put back (the whole entry removed when the newest goes), this test fails at "the older texture is found again". It passes with the change.resource::tests::the_texture_found_at_an_address_gives_way_to_the_one_before_it: pure, no device. It covers the order of release, which releases report a change, unknown textures and addresses, and making the same texture twice.cargo test -p leonida-gpu --features diagnostics --lib --locked: 751 passed, 0 failed, 59 ignored.cargo test -p leonida-gpu --lib --locked: 667 passed, 2 failed (texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers,watch::tests::unmapped_blocks_are_reported_once_until_mapped). Both pass when run alone, onmainand on this branch, so they look like order-dependent flakes in files this change does not touch.cargo clippy -p leonida-gpu --all-targets --features diagnostics -- -D warnings: nothing inresource.rs; the 10 errors left are in other files and are onmainalready.python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/resource.rs: clean.The game: I have not run it. EdenBendheim's in-game batch run on an RTX 3090 included this head and passed (#3054). zmasi named this as a candidate for #2960, where the weapon shop's 3D preview blurs under dynamic resolution and is sharp at a fixed resolution. Dynamic resolution makes targets again, which could leave two at one address. TripyFox ran that menu with dynamic resolution and this change (#3054): still blurred, so this PR does not fix #2960.
AI-assisted: written with Claude Code (Claude Opus 5.5). A separate read-only reviewer agent (Claude Opus 5.5) audited the diff before this was opened.
🤖 Generated with Claude Code
@Kal0s-design on GitHub · 2026-12-02 07:40 UTC · original
Windows 11, MSVC toolchain 1.98.1. Head
ff53fd8b9merged into currentmain229d352ee: the merge is clean. Unit tests only.cargo test -p leonida-gpu --features diagnostics --lib:LEONIDA_D3D12_WARP=1): 774 passed;LEONIDA_D3D12_DEBUG=1): 774 passed, with no message from the layer.cargo test -p leonida-gpu --libwithout diagnostics: 692 passed, 0 failed, run twice. The two failures in the description (alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers,watch::tests::unmapped_blocks_are_reported_once_until_mapped) didn't come back here.Red/green, on the hardware device and on WARP. I put
main's release back intargets_take: the whole entry goes when the newest texture is released. Both new tests then fail. The device one isreleasing_the_newer_texture_at_an_address_finds_the_older_again. The pure one isthe_texture_found_at_an_address_gives_way_to_the_one_before_it, atresource.rs:5166, "the older one is found again",left: None. With the change both pass.Not checked: the game, so nothing on #2960.
GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
@lixonik on GitHub · 2026-12-02 10:02 UTC · original
Verified locally on Windows 10 22H2 + NVIDIA GeForce RTX 5070 12 GB (driver
621.40), PR headff53fd8b9merged ontomaina917c54d6:cargo test -p leonida-gpu --locked --lib resource::-- 30 passed, 0 failed.python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/resource.rs-- exit0.diagbuilddiagnostics,dlss,mimalloc,-NoFrameGen -NoPrecompile, 65 s in-world, 214 s total):ERRORlines, 0 device removals, clean startup and shutdown.1,000+draws/frame, up to5,289draws): median 20.3 fps (49.2 ms/frame); preparing33.2 ms(copies13.2 ms, textures1.1 ms), GPU wait0.0 ms, copying back5.5 ms.Result: PASS.
AI-assisted: yes (Antigravity).
@TripyFox on GitHub · 2026-12-02 10:31 UTC · original
Tested this against #2960 in the game: only
ff53fd8b9on top of27613ab6b(resource.rsis identical there), Series X with the title's dynamic resolution (floor 0.5, 4K output), the same save and the same shop menu. The weapon preview is still blurred, so this doesn't fix #2960. The run itself was clean: no device removal or crash, and the onlyERRORlines are Streamline'sgetRefreshRate ... is not a valid window, whichmainwithout this PR logs the same way. Full results of the other checks are in #2960.AI-assisted (Claude Opus 5.5).
@MoonEyes on GitHub · 2026-12-02 18:18 UTC · original
Verification of #3054 (third party, code review on Linux; not built: Windows-only
leonida-gpu)ff53fd8b9f56174b90f0dbb61c844f0a7597861f(1 file,d3d12/crates/leonida-gpu/src/resource.rs,+117/-7).
0ae5a2664.git merge-tree --write-tree origin/main pr/3054againstmain45dc41f95is clean(202 commits behind).
python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/resource.rs: exit 0.Review
TARGETS_ATheld one texture per address. Releasing the newer of two targets at one address removedthe entry, so the older live one was no longer found. Releasing the older first already left the newer in place,
because of the
== selfcheck onmain. AVecper address, newest last(
resource.rs:1615-1646), fixes the cause.targets_takereturnstrueonly when the found entry changes, andlevels_changedruns only then(
:3606-3609). That is right.targets_putdedups (retain) before pushing. The lists are tiny, so the linearscans cost nothing.
TARGETS_CHANGEDis now raised on every target release, not only when the entry matched (:3603-3606). Thecomment explains it. The cost is an extra re-look by
LEONIDA_ALIAS_QUICKcaches, which is cheap.:5153-5177) covers put, take, order, dedup and the missing cases. The device test(
:5179-5226) goes throughcreate_at_addressandalias_ofwith and without the quick path, and fails onmain's one-entry table. It isdiagnostics-only and returns silently with no host. Print a skip line, asother device tests do.
texture. Anything the newer target rendered to that memory is in neither the older texture nor title memory. Is
the older texture's content the better answer than title memory in that case? The body says #2960 was not fixed
by this (TripyFox's run), which fits. A line in the body or
findings.mdon when "older found again" is thecorrect picture would settle it.
Process
layer) and lixonik ran unit tests on native Windows.
Verdict: ready on review (not built here). It still needs CI approved and an answer to the question above.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@EdenBendheim on GitHub · 2026-12-02 19:17 UTC · original
Windows native unit verification (
VERIFY-3054-WIN) — PASS WITH NOTE on headff53fd8b9f56174b90f0dbb61c844f0a7597861f(merged cleanly onto80910637f, Ryzen 9 5900X / Windows 11 / MSVC):scripts/check_no_game_data.pyon changed files): PASS.80910637f):cargo test -p leonida-gpu --locked -- address --test-threads=1(and with--features diagnostics) exited101(E0425, missingtargets_putandtargets_takeintroduced by this PR).cargo test -p leonida-gpu --locked -- address --test-threads=1: 13 passed.cargo test -p leonida-gpu --locked --features diagnostics -- address --test-threads=1: 15 passed.(AI-assisted verification:
gemini-4-neon+gpt-6.2-astra.)@EdenBendheim on GitHub · 2026-12-02 21:02 UTC · original
RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head
ff53fd8b9f56174b90f0dbb61c844f0a7597861f(in addition to the Windows unit verification posted above).git merge --no-ffontomainb41763227(diagnostics,dlss,mimalloc,exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit0).14PRs):#3200d1a91afd1,#319880a627bb1,#319193b47ac9d,#3189c182fc392,#3176ae0075d9a,#3168337388052,#31641065952da,#3146ebc0253ff,#312464600ef0c,#3069311d33a40,#30318df1bfce7,#3029e49404808,#3054ff53fd8b9,#3010d645712a3.610.88, Series X profile,2560x1440,-NoFrameGen,scripts/game-gate.ps1(301.3 sin world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (GATE CONTROL moved=2.51 m,max_from_ctrl=5,053.9 m).PASS(0device lost,0crashes,0warnings,0missed pipeline waits,20.10 FPSmedian vs19.13 FPSmainb41763227baseline, clean exit0x00000000).(AI-assisted verification:
gemini-4-neon+gpt-6.2-astra.)@fiestorra on GitHub · 2026-12-02 22:27 UTC · original
VERIFY-3054 — Windows nativo: las 32 pruebas de recursos pasan y el control muerde la pila de direcciones
(this PR)0ae5a2664(behindmainb41763227)main—merge-treeclean,git merge --no-ffcleanRan
Negative control (synthetic):
targets_takeremoves the texture it is given; I made it remove the oldest instead (here.remove(0)), rebuilt and ran:The test bites on the mechanism the change adds.
What the change is: the table of targets keeps a stack per address (
BTreeMap<u64, Vec<usize>>) instead of one texture, so two textures found at one address both stay: the newest answers a lookup, and releasing it gives way to the older one again — which is whattargets_take'snewestreturn and the three new tests pin. The scenario it models is a resource released and refound at the same address in a later place; before this, the older entry was lost.What I could not test
Written with an AI assistant.
@upipibi on GitHub · 2026-12-03 16:29 UTC · original
@MoonEyes, on your question: neither source has what the newer target drew once it is released. Its host copy goes with it. Shader writes to a target reach title memory only for the kinds
texbackcopies back (texback.rs:10-15, four water formats by default), and the release drops that texture's pending copies (resource.rs:3597,texback.rs:119-120). So the choice is between the older target's host copy and title memory that no draw reached (the comment atresource.rs:1873).The older copy is the right answer for whatever the title does next. The older target is still alive, and the title can draw into it again. Those draws land in its host copy and nowhere else, for the same reason. With this PR, a view placed there sees them. On
main, the view reads title memory and misses every one of them for as long as the older target lives.It is also what
mainalready gives in two other cases: when the newer target was never made, and when the two are released in the other order (older first, so the newer one stays found). With this change, which texture is found depends only on which targets are alive, not on the order they were released.main's answer is better in one case. Suppose that after the release the memory is refilled by the CPU, or by a copy into a texture the title fills there (LEONIDA_COPY_BACK), and the older target is not drawn into again. Then title memory has the new data and the older copy doesn't.mainalready behaves this way whenever the older target is the only one at that address, so this PR adds no new case of it.I've put this in the body, along with TripyFox's #2960 run: still blurred, so this PR does not fix #2960.
On the skip line: the other device tests in
resource.rsalso return without printing when there is no host (:4709,:4940,:5034onmain), and this one does the same. I've left the head atff53fd8b9so the runs above stay on the exact head. It still merges cleanly ontomain717b90233(git merge-tree).Answered with the help of Claude Code (Claude Opus 5.5).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.