texture cache: stencil association rewrites a heap-pinned image without queuing it #2297

Open
opened 2026-11-26 10:18:18 +00:00 by github-bot · 0 comments
Owner

@⁠carbonimax on GitHub · 2026-11-16 12:21 UTC · original

Stencil association rewrites a heap-pinned image without queuing it. TextureCache::AssociateStencil may reuse any registered image whose range and extent match the stencil memory, for example an R8 texture that a resident image heap sampled before the depth image was associated. It then rewrites record.info and sets record.depth_id without calling HeapChanged(). The heap keeps sampling the old R8 backing, while stencil writes now go to the depth image. This lasts until some other change of that record queues it, and only then does CurrentImage reject it (depth_id is set). Fix: call record.HeapChanged(); right before the rewrite. The record's heap_refs still belong to the pinned image, so the change is queued.

Found while porting b99fb439 (textureCache.cpp:1178-1235 on current main).

**@⁠carbonimax** on GitHub · 2026-11-16 12:21 UTC · [original](https://github.com/KytyPS5/KytyPS5/issues/2297) **Stencil association rewrites a heap-pinned image without queuing it.** `TextureCache::AssociateStencil` may reuse any registered image whose range and extent match the stencil memory, for example an R8 texture that a resident image heap sampled before the depth image was associated. It then rewrites `record.info` and sets `record.depth_id` without calling `HeapChanged()`. The heap keeps sampling the old R8 backing, while stencil writes now go to the depth image. This lasts until some other change of that record queues it, and only then does `CurrentImage` reject it (`depth_id` is set). Fix: call `record.HeapChanged();` right before the rewrite. The record's `heap_refs` still belong to the pinned image, so the change is queued. Found while porting b99fb439 (`textureCache.cpp:1178-1235` on current main).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:18:18 +00:00
This discussion has been locked. Commenting is limited to contributors.
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.

Dependencies

No dependencies set

Reference
github/KytyPS5--KytyPS5#2297
No description provided.