agc: a cached template keeps a sampled texture the lookup no longer returns, so Demon's Souls level lighting goes dark at twice the draws #8040
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 boykopovar/AnyPS5. Originally posted by fisherjoey on 2026-10-19T18:33:51Z.
What happens
Demon's Souls (PPSA01341 v1.07, Linux, RTX 5070 Ti, NVIDIA 595.91.07): in the first level after New Game, indirect lighting comes out dark or black, and the title issues about twice as many indexed indirect draws per frame as in a normal run. The frame rate drops by a third, from about 9 to about 5.8 presents per 10 s. On our main-based test sets this happens in roughly 60% of runs.
We measure it per 10 s window as
DRAW_INDEX_INDIRECT / (DRAW_INDIRECT + DRAW_INDEX_INDIRECT_MULTI)on queue 0. The denominator is about 24 packets per frame, so the ratio is the title's indexed indirect draws per frame. A normal level sits at 200 to 225; an affected run sits at 410 to 475.Current main still does it. We ran main
676269473(this morning's main, which includes #6492) with #6280, #6926, #7844 and a local stencil-export workaround that lets the title reach the level on NVIDIA. Both runs that reached the level with warm shaders crawled: a median ratio over the second half of the level of 414 and 438, at 5.92 and 5.55 presents per 10 s.Where
A cached
ShaderResources(here, dispatch templates) is reused whenRevalidateproves it current. The fast proof,fastRevalidateandfastRevalidateEach(ShaderResources.cpp:2823, 2980), proves each bound sampled texture from write stamps, DCC keys and the pending registry. It never checks that the sampled lookup would still return the boundTextureobject. Only the full walk (3187) repeatscachedTextureand compares objects, and it runs only when the fast proof fails. So a template whose surface memory has not changed can keep binding an object the lookup no longer returns, in two ways:cachedTextureerases an entry it finds changed and makes a new one, anderaseTexture(228) marks a held texture released. Since #6492, the nextResourceCache::Insert(3666) drops every entry holding a released texture. Until that Insert,Find(3485) still returns the template, and its fast proof still passes.cachedTexturechooses between a snapshot and a view of a storage image bySampledFromStorageEligibleand the storage registry (709). After a snapshot's surface becomes host-imported, the lookup would return a storage view instead. The cache entry is only replaced when some lookup for that surface runs. A template that is the only user of the surface never runs one, so nothing is released, #6492 has nothing to drop, and the template binds the old snapshot until it leaves the resource cache.Evidence
All runs: Demon's Souls PPSA01341 v1.07, Linux (Nobara, kernel 7.2), RTX 5070 Ti, driver 595.91.07, 900 s from boot through New Game into the first level. Most of the work was on a set based on main
ccb0c0926(before #6492) with local patches; the PR lists them.Textureobject than the template had, in 5 programs. The textures were a 1600x900 format-71 target and a 1024x512 format-22 surface. In 3 of the 7, the old object was still alive.Expected
A cached template should not bind a texture the sampled lookup no longer returns for its surface. A fix with tests follows in a PR.
AI-assisted: yes