fix(agc): the stage-A fast path leaves a view of a pending image whose keys were filled to the full lookup #249

Merged
MichonGoddijn231849 merged 1 commit from upstream-pr/249 into main 2026-10-02 07:30:29 +00:00
MichonGoddijn231849 commented 2026-10-01 19:12:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-01T19:12:57Z.


What

#163's per-read DCC model: after a uniform key fill with a clear code, a sampled read through the surface's keys reads the clear value instead of the image's pending results (cachedTexture, clearThroughKeys). The stage-A fast path (fastTexture) skipped that check. It returned the record's view of the pending image whenever the scanned keys matched the entry's, so a sampled read between the fill and the image's next refresh read the previous results.

The fast path now leaves such a view to the full lookup: when the record's source image has keys filled with a clear code and the read goes through keys (dccAddress != 0). The full lookup then binds the clear or takes its other branches as before. Once the image is refreshed (upload resets filledKeys), the fast path applies again.

GTA V clears its 1280×720 bloom buffer every frame by filling its DCC keys (code 0000). Its composite then samples the buffer through the fast path before the buffer's next refresh, so each frame added onto the last one:

  • the scene luminance went to FP16 max within a second (a white screen);
  • later it alternated between about 19 and 200 from frame to frame (pulsing).

Until now, GTA needed APS5_KEYS_FILL_CLEAR=1 to avoid this.

Tested

Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0.

  • GTA V (PPSA04264) in the North Yankton prologue, with #167, #231 and #232, without APS5_KEYS_FILL_CLEAR. I read the scene luminance (the 1×1 R32F the auto-exposure averages into) back from its GPU image every frame:
    • Before: 156 of the last 200 frames at about 65000 (FP16 max).
    • After: 0 of 494 frames above 1000, luminance 10–54, one frame-to-frame change above 1.8×. The same range as with APS5_KEYS_FILL_CLEAR=1.
  • A bisect with the immediate clear limited to one key range pointed at the bloom buffer's keys: clearing those alone was enough.
  • ctest: all tests 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
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4708382639 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/249). Originally posted by [MichonGoddijn231849](https://github.com/MichonGoddijn231849) on 2026-10-01T19:12:57Z. --- ### What #163's per-read DCC model: after a uniform key fill with a clear code, a sampled read through the surface's keys reads the clear value instead of the image's pending results (`cachedTexture`, `clearThroughKeys`). The stage-A fast path (`fastTexture`) skipped that check. It returned the record's view of the pending image whenever the scanned keys matched the entry's, so a sampled read between the fill and the image's next refresh read the previous results. The fast path now leaves such a view to the full lookup: when the record's source image has keys filled with a clear code and the read goes through keys (`dccAddress != 0`). The full lookup then binds the clear or takes its other branches as before. Once the image is refreshed (`upload` resets `filledKeys`), the fast path applies again. GTA V clears its 1280×720 bloom buffer every frame by filling its DCC keys (code 0000). Its composite then samples the buffer through the fast path before the buffer's next refresh, so each frame added onto the last one: - the scene luminance went to FP16 max within a second (a white screen); - later it alternated between about 19 and 200 from frame to frame (pulsing). Until now, GTA needed `APS5_KEYS_FILL_CLEAR=1` to avoid this. ### Tested Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB DDR5-5600, MinGW-w64 GCC 15.2.0. - GTA V (PPSA04264) in the North Yankton prologue, with #167, #231 and #232, without `APS5_KEYS_FILL_CLEAR`. I read the scene luminance (the 1×1 R32F the auto-exposure averages into) back from its GPU image every frame: - Before: 156 of the last 200 frames at about 65000 (FP16 max). - After: 0 of 494 frames above 1000, luminance 10–54, one frame-to-frame change above 1.8×. The same range as with `APS5_KEYS_FILL_CLEAR=1`. - A bisect with the immediate clear limited to one key range pointed at the bloom buffer's keys: clearing those alone was enough. - `ctest`: all tests 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 - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes. Written with Claude (Anthropic) under my direction; I reviewed and tested it. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
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!249
No description provided.