Count a texture pool take only when its sync left no slot behind, so a retired texture is not freed while a set still holds its view.

Once the frame's creation time is spent, pool_refill skips a slot it left earlier in the frame, and pool_sync_entries
may return before the walk. Such a slot keeps its old view in the current set with nothing in the change log, so the
takes after it do not carry the change into the other sets. vk_pool_takes counted those takes all the same, and at
about six submissions a frame, more than VK_POOL_SETS of them could pass within one frame while a retired texture's slot
was skipped every time. retire_sweep would then free the image while every set still named it. A take now counts only
when its sync left no slot behind (PL.retry clear): after it, every slot change made before it is in that set and in
the log, and the takes after it bring it into the others. A sealed second take inside one submission still goes
uncounted, which only delays the free.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5cd431f792e00ca3b9a03657cd4aab64fc38dae7)
This commit is contained in:
chrg6
2026-11-09 21:32:45 -05:00
committed by tangerineturtle1
parent a87f6e1bd6
commit 49dd6639f1
3 changed files with 12 additions and 5 deletions

View File

@@ -1161,7 +1161,8 @@ static uint64_t evict_idle(uint64_t want, uint64_t used, uint64_t budget) { //
// every slot that names it gets the kind's stand-in. Any use in the meantime takes it back as it is (retire_cancel):
// a lookup other than the pool refresh, or a mark on one of its slots (the stand-in was sampled).
// - destroyed (retire_sweep) once the texture pool has taken every set of its ring since, each brought up to date
// when taken (vk_exec_draw.c pool_take_set, pool_catch_up), and the GPU has finished the submissions recorded until
// when taken (vk_exec_draw.c pool_take_set, pool_catch_up), after a sync that left no slot behind wrote its stand-in
// (vk_pool_takes counts only such takes), and the GPU has finished the submissions recorded until
// then: no set can be bound with its view any more, and no submission that bound one is still running. Its key is
// held then: a held key makes no entry in the pool refresh (held_out), so the slot keeps its stand-in; a mark on the
// slot drops the hold and the next refresh makes the texture again, as does any other lookup.