fix(agc): remake a surface's storage image when its DCC keys move #177

Merged
oneandonlydean merged 1 commit from upstream-pr/177 into main 2026-09-30 18:18:01 +00:00
oneandonlydean commented 2026-09-30 11:47:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-30T11:47:29Z.


What

The storage image cache keys a surface by memory, extent, layout and storage format, and the image keeps the DCC key range of the first descriptor that made it. When a later descriptor names other metadata for the same surface (the title reallocated the keys, or the memory held another surface before), the cached image kept the old keys. The title's fast clears of the new keys never reached it, and its write-backs marked keys the surface no longer owns.

Now, when a descriptor with DCC metadata names a key address other than the cached image's, cachedStorageTexture evicts that image and makes a new one from memory under the named keys. evictStorage flushes the old image's pending results first, as it does for any eviction, so the new image starts from what the rendering left in memory. Views and recipes that still hold the old image see it gone from the cache (StorageImageCached). A sampled view of another image's pending results (FindPending) is taken only when that image follows the same keys. A descriptor without metadata keeps whatever image the surface has.

In PPSA21564 the title draws its intro movie into the 4K UI layer and, on the title screen, fast-clears that layer through its DCC keys before drawing PRESS ANY BUTTON. In runs where the layer's first descriptors at boot named other metadata, the clear was lost and the layer kept the movie's last, nearly black frame over the whole title scene until the menu: an intermittent black title screen.

The recorder test device now sets formatProperties, which a StorageTexture needs to pick its Vulkan format. #131 adds the same line; the two merge cleanly.

Tested

  • Linux (CachyOS, RTX 4090): agc_driver_recorder_tests gets movedMetadataTests. On a host-imported 256x256 surface it makes the storage image under uncompressed keys, then names a second key range holding a fast clear. It checks that the image is remade under the new keys and reads the clear, that the old image left the cache, that a descriptor without metadata keeps the new image, and that moving the keys back remakes the image from memory. On main it fails with "the storage image kept the keys the surface no longer names".
  • The test does not cover results pending in the old image at the move: that is evictStorage's existing flush, and whether the flush stores them depends on write tracking of the test block, which Linux main does not have yet (#121). A version of the test that draws into the image before moving the keys back passes with #121 merged.
  • Exercised in PPSA21564 on our integration branch: the title scene no longer stays black after the intro movie.
  • ctest: 64/64 pass. agc_driver_graphics_tests passes on a throwaway merge with #113 (which links it again).

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4690035560 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/177). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-30T11:47:29Z. --- ### What The storage image cache keys a surface by memory, extent, layout and storage format, and the image keeps the DCC key range of the first descriptor that made it. When a later descriptor names other metadata for the same surface (the title reallocated the keys, or the memory held another surface before), the cached image kept the old keys. The title's fast clears of the new keys never reached it, and its write-backs marked keys the surface no longer owns. Now, when a descriptor with DCC metadata names a key address other than the cached image's, `cachedStorageTexture` evicts that image and makes a new one from memory under the named keys. `evictStorage` flushes the old image's pending results first, as it does for any eviction, so the new image starts from what the rendering left in memory. Views and recipes that still hold the old image see it gone from the cache (`StorageImageCached`). A sampled view of another image's pending results (`FindPending`) is taken only when that image follows the same keys. A descriptor without metadata keeps whatever image the surface has. In PPSA21564 the title draws its intro movie into the 4K UI layer and, on the title screen, fast-clears that layer through its DCC keys before drawing PRESS ANY BUTTON. In runs where the layer's first descriptors at boot named other metadata, the clear was lost and the layer kept the movie's last, nearly black frame over the whole title scene until the menu: an intermittent black title screen. The recorder test device now sets `formatProperties`, which a `StorageTexture` needs to pick its Vulkan format. #131 adds the same line; the two merge cleanly. ### Tested - Linux (CachyOS, RTX 4090): `agc_driver_recorder_tests` gets `movedMetadataTests`. On a host-imported 256x256 surface it makes the storage image under uncompressed keys, then names a second key range holding a fast clear. It checks that the image is remade under the new keys and reads the clear, that the old image left the cache, that a descriptor without metadata keeps the new image, and that moving the keys back remakes the image from memory. On main it fails with "the storage image kept the keys the surface no longer names". - The test does not cover results pending in the old image at the move: that is `evictStorage`'s existing flush, and whether the flush stores them depends on write tracking of the test block, which Linux main does not have yet (#121). A version of the test that draws into the image before moving the keys back passes with #121 merged. - Exercised in PPSA21564 on our integration branch: the title scene no longer stays black after the intro movie. - `ctest`: 64/64 pass. `agc_driver_graphics_tests` passes on a throwaway merge with #113 (which links it again). ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
github-actions[bot] commented 2026-09-30 16:13:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-09-30T16:13:11Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#163 core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp L297
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:5915149018 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/177#issuecomment-5915149018). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-09-30T16:13:11Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #163 | `core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp` [L297](https://github.com/boykopovar/AnyPS5/blob/52ab9e3544cce401a84f6f16a3899ed19ebe6a76/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp#L297) | | |
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
boykopovar/AnyPS5!177
No description provided.