fix(agc): keep render target results where the write tracker cannot prove memory fresh #120

Merged
oneandonlydean merged 1 commit from upstream-pr/120 into main 2026-09-30 15:09:58 +00:00
oneandonlydean commented 2026-09-29 00:24:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-09-29T00:24:54Z.


What

Where the write tracker cannot see CPU writes (no write watching: the whole Linux guest arena today, and memory outside the Windows arena), CollectWrites answers 0 and every unit reads as changed at every check. Two paths lost a render target's results there:

  • StorageTexture::Refresh dropped all pending results whenever the surface's DCC keys read as a clear code, not only when the keys changed to one. Draws never update the title's keys, so a resident target cleared under a clear code keeps that code while holding newer draw results, and the lookup of the next draw sampling it re-cleared the image. On Linux Astro Bot's intro composite sampled an empty UI layer (black/missing text). Now only new clear keys drop results; results kept under the image's own clear code are stored whole (the store marks every key uncompressed, as writeBack does) and re-uploaded like any untracked unit.
  • Unit shadows: a slab unit is fresh only at a tracker generation and MarkShadowed ignores generation 0, so a write-back retiled into a slab over unwatched memory was never marked, published or read back; its texels were lost and the next upload re-read the stale import. UnitShadowEnabled now also requires a write-watched arena, and ShadowDestinationFor offers no slab outside the arena; those retiles go into the import, as with APS5_NO_UNIT_SHADOW=1. Windows arena memory behaves as before.

Tested

  • Linux (CachyOS, RTX 4090): agc_driver_recorder_tests passes. Its new GPU test (target cleared under 0000 keys, drawn into, refreshed; then new 0001 keys) fails without the Refresh change ("a refresh under the image's own clear keys dropped the draw's results") and without the unit shadow change ("a unit shadow was offered for memory the write tracker does not watch").
  • agc_driver_graphics_tests passes with #113 merged in.
  • Exercised in Astro Bot on our integration branch: the intro's UI layer renders on Linux.
  • ctest: 57/57 pass.

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:4670910933 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/120). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-09-29T00:24:54Z. --- ### What Where the write tracker cannot see CPU writes (no write watching: the whole Linux guest arena today, and memory outside the Windows arena), `CollectWrites` answers 0 and every unit reads as changed at every check. Two paths lost a render target's results there: - `StorageTexture::Refresh` dropped all pending results whenever the surface's DCC keys read as a clear code, not only when the keys *changed* to one. Draws never update the title's keys, so a resident target cleared under a clear code keeps that code while holding newer draw results, and the lookup of the next draw sampling it re-cleared the image. On Linux Astro Bot's intro composite sampled an empty UI layer (black/missing text). Now only new clear keys drop results; results kept under the image's own clear code are stored whole (the store marks every key uncompressed, as `writeBack` does) and re-uploaded like any untracked unit. - Unit shadows: a slab unit is fresh only at a tracker generation and `MarkShadowed` ignores generation 0, so a write-back retiled into a slab over unwatched memory was never marked, published or read back; its texels were lost and the next upload re-read the stale import. `UnitShadowEnabled` now also requires a write-watched arena, and `ShadowDestinationFor` offers no slab outside the arena; those retiles go into the import, as with `APS5_NO_UNIT_SHADOW=1`. Windows arena memory behaves as before. ### Tested - Linux (CachyOS, RTX 4090): `agc_driver_recorder_tests` passes. Its new GPU test (target cleared under 0000 keys, drawn into, refreshed; then new 0001 keys) fails without the `Refresh` change ("a refresh under the image's own clear keys dropped the draw's results") and without the unit shadow change ("a unit shadow was offered for memory the write tracker does not watch"). - `agc_driver_graphics_tests` passes with #113 merged in. - Exercised in Astro Bot on our integration branch: the intro's UI layer renders on Linux. - `ctest`: 57/57 pass. ### 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
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!120
No description provided.