[Gpu] Collect an image only once it is old enough in frames

Since images age by frame, clamping the age to the current frame made every
image of the first frame collectable during the first 16 frames, and a
submission that ended no frame could delete a texture the frame still used.
Without memory pressure nothing is collected until the full age has passed;
under pressure the clamp still lets collection relieve memory early.
This commit is contained in:
ParantezTech 2026-10-02 18:51:29 +03:00
parent 1b3c380137
commit 901548fcbb
1 changed files with 7 additions and 1 deletions

View File

@ -34,7 +34,13 @@ public sealed partial class GuestImageCache
{
var pressured = _totalUsedMemory >= _memoryPressureBytes;
var aggressive = allowAggressive && _totalUsedMemory >= _criticalMemoryBytes;
var age = Math.Min(aggressive ? 160UL : pressured ? 80UL : 16UL, tick);
var age = aggressive ? 160UL : pressured ? 80UL : 16UL;
if (tick < age && !pressured && !aggressive)
{
return;
}
age = Math.Min(age, tick);
var deletions = aggressive ? 40 : pressured ? 20 : 10;
var candidates = new List<ResourceSlotIdentifier>(deletions);
// Deleting a depth image also deletes its stencil association, so the recency walk ends first.