GPU: look up slot-eviction candidates by the raw texture key (part of #2778) #2890

Open
SlyWater wants to merge 1 commit from upstream-pr/2890 into main
SlyWater commented 2026-11-29 18:34:45 +00:00 (Migrated from github.com)

Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by SlyWater on 2026-11-29T18:34:45Z.


Part of #2778 (analysis and proposed change there; the author could not build it). Draft: it fixes a keyspace mismatch, but on our run it did not by itself make the sweep let textures go.

The mismatch

slot_evict builds raws keyed by the raw host texture pointer, with the title texture address as its value, and descriptor::evictable_slots returns its slots keyed the same way:

raws.insert(Interface::as_raw(&host.texture) as usize, at);   // key: raw, value: at
...
for (index, raw, ok, lately, indexed) in host.slots_showing(&set, frame, cutoff) {
    by_texture.entry(raw).or_default().push((at, index, indexed));   // key: raw
}

Both use sites looked the title address up in that raw-keyed map:

copies.retain(|&(at, ..)| slots.contains_key(&at));            // matches nothing
let (reset, busy) = crate::descriptor::evict_slots(at, &slots[&at]);   // would panic

A title address is never a key of slots, so retain emptied the candidates on every pass and the loop below ran zero times. The second site has to change with the first, or the fixed retain makes the sweep panic on the missing key.

Tested

Built and run on Windows 11, i5-12400F, RTX 3070 8 GB, title 1.0.2.1, Series S 1080p, with the change applied on main (f889bb0):

  • no crash, no panic, no behaviour change outside the sweep;
  • the sweep still reports 0 textures (0 MB) let go. Before the change it saw 30836 idle-looking with 14926 not to be taken (a slot shaders pick by index shows them); after it the same class of counters, still nothing taken, so the candidate set is empty for a second reason this change does not establish (e.g. the raw keys of those textures are not in the slots map at all).

So this removes one definite bug on the path and nothing more; it should not be read as closing #2778. A test for it can be written without the title (build raws with one entry and a slots map keyed the way evictable_slots returns it, then assert the retain keeps the copy); I have not added one here.

No game files, dumps or title logs are included.

<!-- greyfinch-sync:trustno1-coder/VIctory-NVIDIA:issue:5553806803 --> Imported from [trustno1-coder/VIctory-NVIDIA](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/2890). Originally posted by [SlyWater](https://github.com/SlyWater) on 2026-11-29T18:34:45Z. --- Part of #2778 (analysis and proposed change there; the author could not build it). Draft: it fixes a keyspace mismatch, but on our run it did not by itself make the sweep let textures go. ## The mismatch `slot_evict` builds `raws` keyed by the **raw host texture pointer**, with the **title texture address** as its value, and `descriptor::evictable_slots` returns its slots keyed the same way: ```rust raws.insert(Interface::as_raw(&host.texture) as usize, at); // key: raw, value: at ... for (index, raw, ok, lately, indexed) in host.slots_showing(&set, frame, cutoff) { by_texture.entry(raw).or_default().push((at, index, indexed)); // key: raw } ``` Both use sites looked the **title address** up in that raw-keyed map: ```rust copies.retain(|&(at, ..)| slots.contains_key(&at)); // matches nothing let (reset, busy) = crate::descriptor::evict_slots(at, &slots[&at]); // would panic ``` A title address is never a key of `slots`, so `retain` emptied the candidates on every pass and the loop below ran zero times. The second site has to change with the first, or the fixed `retain` makes the sweep panic on the missing key. ## Tested Built and run on Windows 11, i5-12400F, RTX 3070 8 GB, title 1.0.2.1, Series S 1080p, with the change applied on main (`f889bb0`): - no crash, no panic, no behaviour change outside the sweep; - the sweep still reports `0 textures (0 MB)` let go. Before the change it saw `30836 idle-looking` with `14926 not to be taken (a slot shaders pick by index shows them)`; after it the same class of counters, still nothing taken, so the candidate set is empty for a second reason this change does not establish (e.g. the raw keys of those textures are not in the `slots` map at all). So this removes one definite bug on the path and nothing more; it should not be read as closing #2778. A test for it can be written without the title (build `raws` with one entry and a `slots` map keyed the way `evictable_slots` returns it, then assert the `retain` keeps the copy); I have not added one here. No game files, dumps or title logs are included.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2890:upstream-pr/2890'
git switch 'upstream-pr/2890'

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.

git switch 'main'
git merge --no-ff 'upstream-pr/2890'
git switch 'upstream-pr/2890'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2890'
git switch 'upstream-pr/2890'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2890'
git switch 'main'
git merge --squash 'upstream-pr/2890'
git switch 'main'
git merge --ff-only 'upstream-pr/2890'
git switch 'main'
git merge 'upstream-pr/2890'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
trustno1-coder/VIctory-NVIDIA!2890
No description provided.