Repository navigation
GPU: let go of a placed texture's host copy as soon as its memory is … - #550
pug205gti6 wants to merge 1 commit into
Conversation
…unmapped A placed texture's host copy waited for the idle sweep: five seconds and four frames of nothing asking for it (`resource::let_go_idle`). Nothing is asking while the title streams its next set of textures in, so a texture the title had already finished with kept its card memory through the whole stream -- and the run paged. Unmapping the title memory is how the title says it is done with a texture; that is the moment to act on, and it was already a call (`watch::title_memory_remapped`) with the range in hand. WHAT GOES, AND WHEN. `resource::evict_placed_in(base, len)` walks the placed textures the title fills whose bytes meet `[base, base + len)`, and lets a host copy go when only its title resource holds it: `Arc::strong_count(host) == 1` and `host::references(&host.texture) == 1`, the same two conditions `let_go_idle` requires, taken under the same `made` lock and followed by the same `texture::unstage`, `host::retire`, `host.gone` marking and `KINDS[2]`/`KINDS[3]` counters. `title_memory_remapped` calls it after the views and placements there are forgotten. Nothing waits on a fence, so no submission is held up, and no list or slot that still names the copy is touched: it stays, as before, until they let it go. The next use makes the host copy anew from the memory the runtime has just mapped, which is exactly what the idle sweep relied on. Overlap is answered by a new `resource::ranges_overlap(a_start, a_len, b_start, b_len)`: half-open, zero-length ranges share nothing, and the ends saturate, so a range cannot wrap into a false hit. It is the one piece of this that can be tested without a card, so it is: `ranges_overlap_handles_boundaries_zero_len_and_overflow` pins adjacency in both orders, a single shared byte on either side, containment both ways, empty ranges, and the top of the address space. Mutation-probed: `<` to `<=` in the first comparison makes the adjacent case report an overlap and the test fails on it. `VICTORY_TEXTURE_SWEEP=0` still lets nothing go. The switch moved into one `sweeping()` so the two paths cannot disagree about it. The path is traced through `host::trail` like the idle sweep's, naming how many went and their KiB. SCOPE. resource.rs and the call in watch.rs, which is where `title_memory_remapped` is defined (`lib.rs` re-exports it). No test drives `evict_placed_in` itself: it needs the host device, and the two conditions it acts on are the ones `let_go_idle` already had. What is new and testable is the range test.
|
Duplicate of #432: @HailLucifer666 opened this patch 80 minutes earlier, and Both PRs are CONFLICTING, so this copy does not resolve the conflict it was probably made for. Please continue in #432 so the review history and any test data stay in one place. |
|
Tested Setup: RTX 5080 16 GB / Ryzen 5 5600, Series X profile, warm shader cache,
The forest is the cutscene's first shot. With the patch the load runs ~4× longer, the cutscene's clock runs out while the world is still loading, and the script skips past it. Likely cause:
During loading the title remaps pages constantly while the table grows to tens of thousands of textures, so the cost is roughly O(remaps × textures) on the streaming path. It fits the numbers: in the first ~2 minutes the title asks for far fewer textures (the "waiting" count stays low too), so the title itself is held up rather than re-uploading what was evicted. Possible fixes: queue the I did not time the walk directly ( |
…unmapped
A placed texture's host copy waited for the idle sweep: five seconds and four frames of nothing asking for it (
resource::let_go_idle). Nothing is asking while the title streams its next set of textures in, so a texture the title had already finished with kept its card memory through the whole stream -- and the run paged. Unmapping the title memory is how the title says it is done with a texture; that is the moment to act on, and it was already a call (watch::title_memory_remapped) with the range in hand.WHAT GOES, AND WHEN.
resource::evict_placed_in(base, len)walks the placed textures the title fills whose bytes meet[base, base + len), and lets a host copy go when only its title resource holds it:Arc::strong_count(host) == 1andhost::references(&host.texture) == 1, the same two conditionslet_go_idlerequires, taken under the samemadelock and followed by the sametexture::unstage,host::retire,host.gonemarking andKINDS[2]/KINDS[3]counters.title_memory_remappedcalls it after the views and placements there are forgotten. Nothing waits on a fence, so no submission is held up, and no list or slot that still names the copy is touched: it stays, as before, until they let it go. The next use makes the host copy anew from the memory the runtime has just mapped, which is exactly what the idle sweep relied on.Overlap is answered by a new
resource::ranges_overlap(a_start, a_len, b_start, b_len): half-open, zero-length ranges share nothing, and the ends saturate, so a range cannot wrap into a false hit. It is the one piece of this that can be tested without a card, so it is:ranges_overlap_handles_boundaries_zero_len_and_overflowpins adjacency in both orders, a single shared byte on either side, containment both ways, empty ranges, and the top of the address space. Mutation-probed:<to<=in the first comparison makes the adjacent case report an overlap and the test fails on it.VICTORY_TEXTURE_SWEEP=0still lets nothing go. The switch moved into onesweeping()so the two paths cannot disagree about it. The path is traced throughhost::traillike the idle sweep's, naming how many went and their KiB.SCOPE.
resource.rs and the call in watch.rs, which is where
title_memory_remappedis defined (lib.rsre-exports it). No test drivesevict_placed_initself: it needs the host device, and the two conditions it acts on are the oneslet_go_idlealready had. What is new and testable is the range test.