d3d12/gpu: a released target at a shared address leaves the older one found (D3D12-TARGETS-AT-RESTORE) #3054
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u origin "github-pr/3054:github-pr/3054" git switch "github-pr/3054"
Open
leonida/mandy
upipibi wants to merge 1 commit from
github-pr/3054 into main
pull from: github-pr/3054
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3132
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
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
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3054
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/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?
This branch is out-of-date with the base branch
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.D3D12-TARGETS-AT-RESTORE, item 5 of @zmasi's finding (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7334060836). Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7336489248
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 (https://github.com/ProjectLeonida/mandy/pull/3054#issuecomment-7358705620). 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 (https://github.com/ProjectLeonida/mandy/pull/3054#issuecomment-7342597771): 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
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).
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).
Tested this against #2960 in the game: only
ff53fd8b9on top of 27613ab6b (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 https://github.com/ProjectLeonida/mandy/issues/2960#issuecomment-7342531668.AI-assisted (Claude Opus 5.5).
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
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.)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.)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.
@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).