Texture read-backs: no title-memory lock or TICKETS held while tiling #270
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/270"
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?
Imported from PastiiJay/klbf-lab. Originally posted by DB85656 on 2026-11-29T17:22:13Z.
What
texback::landtook the whole title-memory read lock (title_memory_reading()) andTICKETSat its start and held both to the end: across mapping the read-back buffer and tiling every subresource into the console layout. Every remap of title memory, and every ticket invalidation (remapped/replaced/released), waited for a landing to finish.Now:
title_memory_reading_in(at, size); withVICTORY_MAP_LOCK_FINE=1only a change of that memory waits);TICKETSare held only while the allocation's bytes are read and while the tiled result is written back; mapping and tiling run without either;copy_mapped, so a remap or release during the tiling skips the write, exactly as a change before the landing did. Both checks go through onestill_valid()(same "skipping texture readbacks whose title allocation changed" line).Lock order (mapping, then
TICKETS) is unchanged. Nothing else changes: same bytes copied, same skips.Measured
On my build (beta-amd base, Core Ultra 7 265KF, RX 9060 XT, 4K,
VICTORY_MAP_LOCK_FINE=1), in the game: texture read-back landings went from peaks of 60.75 ms to about 1-2 ms, and waits on the mapping lock fell from several seconds to a few tens of ms per 5 s window. WithVICTORY_MAP_LOCK_FINEoff (the default) the gain comes only from not holding the lock while tiling.Testing
stable-amd(texback.rswas identical there, the patch applied as is), but it has not been built or run onstable-amdyet.texback::testspassed on my branch.-BenchLength testA/B onstable-amdwill follow in a comment.🤖 Generated with Claude Code
Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-29T17:25:57Z.
thanks @DB85656, getting the locks off the tiling path is the kind of change that adds up. it's passed on for the next round.
Imported from PastiiJay/klbf-lab. Originally posted by efsebayern on 2026-11-29T18:25:14Z.
I tested the exact
stable-amdbase72d557fand PR head4cbf331on Windows 11 25H2, i7-13700K, RTX 4080 SUPER (621.40), and 32 GB RAM. Both were unmodifieddiagbuilds withdiagnostics. Profile X, title upscaler to 1440p, RT and frame generation off,VICTORY_MAP_LOCK_FINE=1.Each run started from the same manual save and a fresh copy of the same prewarmed shader/pipeline cache. I used the benchmark's input lock, ran each build for 125 seconds from its first world frame, and included complete diagnostic windows between world +20 and +120 seconds. FPS is weighted by each host window's duration.
Both PR runs had fewer reader waits per second, with mapping activity in a similar range across all runs (872–935 changes/s). Total wait time varied, and both PR runs had a longer individual worst wait than either base run. The wait counters cover all readers of the mapping lock. The PR's per-landing lock hold time was outside the scope of these counters.
This sample did not establish an FPS gain or regression. Draw load varied across repeats from the same save, particularly in B1. Pipeline queues were mostly clear during the sampled windows (max pending 0, 0, 7, 1 in run order). All four runs exercised the texture readback path and completed without device removal. Visual equivalence remains unverified.
cargo test --locked --profile diag -p victory-gpu --features diagnostics --lib texback::testson the PR head passed the allocation-ticket invalidation test.Imported from PastiiJay/klbf-lab. Originally posted by co11ector on 2026-11-30T07:59:55Z.
Same shape on RDNA 4 (16 GB, Windows 11), v26.11.17, Profile X, FSR 3.1, FG x2.
47-minute run with the per-frame lines on. 17 gaps of 1.5 s or more in the log; the four largest all begin on the line right after
victory_gpu::texback: texture readback landed copied=432768 bytes=262144:The first line after the 26.8 s gap is
watch::fine: mapping lock readers (VICTORY_MAP_LOCK_FINE=1), last 5 s: 416 waits 3915.3 ms (longest 108.0 ms).Private commit was 29.1 GB of 32 GB at that point (commit limit 82 GB, 5.9 GB of RAM free), so page faults are part of it; but the stall always lands on a read-back, and a 108 ms longest wait does not explain 26 s.
Card at the same moment: 11.9 GB in use of a 13.7 GB budget (
KLBF_TEXTURE_SHARE=40).For what it is worth, the #333 leak is not active in this run yet:
views.listhas 1 entry andshapesis at 125k of 4,194,304, so these stalls are not the shapes saturation.Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-30T09:57:56Z.
Thanks again, third excellent report tonight (#329, #145 and this one). You're right about the spot: when a read-back lands, both the title-memory read lock and the tickets list are held for the whole read, tiling and copy, so a remap waiting on that lock can leave everything else queued behind it. Tiling outside the locks and keeping only the check and the copy under them is the direction we're looking at.
An A/B to confirm, same save, same drive:
VICTORY_TEXTURE_BACK=0. It turns those read-backs off. Test only: with it, boats sit too low in the water, since that's what the read-backs are for. If the big freezes go away, that confirms it.Also: is
VICTORY_MAP_LOCK_FINEsomething you set yourself, or did it come from the launcher?Imported from PastiiJay/klbf-lab. Originally posted by co11ector on 2026-11-30T10:58:29Z.
VICTORY_MAP_LOCK_FINE=1comes from KLBF's ownplay.ps1, line 367 (VICTORY_MAP_LOCK_FINE = '1'; VICTORY_POOL_CAP = '1'); my launch profile copies that line verbatim. Nothing I added.On #333: I checked my logs and you are right, the shape path is not the problem in KLBF. In the 47-minute run the
memory, more:line showsshapes of placed views kept: 124453 -> 125753andof the view table's entries 1 are constant buffer views and 0 views of placed memory, soKLBF_PLACED_NORMALis doing its job and nothing reached the 2^22 cap.I will run the
VICTORY_TEXTURE_BACK=0A/B on the same save and post the freeze gaps here. The boats sitting low is fine for a test.Imported from PastiiJay/klbf-lab. Originally posted by PastiiJay on 2026-11-30T10:59:17Z.
Thanks @co11ector, good to know
VICTORY_MAP_LOCK_FINE=1comes from our own launcher defaults, noted. And thanks for checking the #333 path in your logs too. Looking forward to theVICTORY_TEXTURE_BACK=0A/B.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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.