fix(agc): preserve GPU results in CPU-stamped full image blocks #1997

Closed
ToyuAU wants to merge 4 commits from upstream-pr/1997 into main
ToyuAU commented 2026-10-09 04:19:49 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ToyuAU on 2026-10-09T04:19:49Z.


What

Withdrawn as a proposed fix for #1970. The new #1995 evidence identifies guest allocator reuse inside a still-registered allocation. This candidate's baseline/allocation checks cannot establish ownership in that case. Its passing tests cover images that still own their memory, not the reported lifetime failure. #1994 and #1995 already provide the author's hardware-tested workaround; preserve this branch and its test results for reference rather than merge a competing byte policy without lifetime proof.

A draft candidate for the full 64 KiB page-stamp behavior discussed in #1970. A CPU page stamp currently discards an entire aligned image block even when guest bytes still equal the upload baseline, losing pending GPU results. Extend #1918's immutable byte merge to every watched image block: unchanged destination bytes accept changed GPU results, actual CPU edits survive, and newer ordered driver stores or replaced allocations still veto the merge.

Depends on #1918 at 97655b677e273d93fb8fdfe1393ae7a372904a1b, which is included in this branch. This PR adds the full-block extension and regression cases; it does not replace that partial-edge PR. Open alternative #1599 addresses partial-edge equality and does not implement this full-block byte merge. Existing fixes #1968 and #1969 do not establish byte ownership for CPU-stamped full blocks.

New #1995 reports write-trap evidence of Unity allocator reuse and a Windows/NVIDIA Silksong workaround, APS5_STORE_AT_FLIP=1, with #1994's opt-in watched imports. That is distinct from this byte merge and already provides the reported title's tested workaround. A baseline cannot prove that bytes still belong to the image when a guest allocator reuses memory inside the same registered allocation; unchanged or reset bytes may belong to the new object. This PR therefore does not resolve #1970's allocator-lifetime cause and must not be treated as a substitute for storing results before guest GPU completion is exposed. Keep draft pending that ownership decision and hardware evidence.

Pack block baselines and merge outputs into shared buffers instead of allocating a Vulkan buffer per block. Capture and ordinary writeback retain baselines across uploads, clears, copies and aliases. Add a separate CTest invocation covering mixed CPU/GPU bytes, same-value CPU writes, uncollected page writes, refresh, second merge cycles, driver precedence, allocation replacement, unchanged GPU results, aliases, pending operations, CPU fallback and an aligned 8 MiB surface with every block CPU-stamped.

Keep this draft pending native CI and runtime/performance validation. Baseline storage scales with image size, upload capture copies guest bytes, and snapshot-covered blocks bypass unit shadows. The exact Silksong format-56/tile-7 stack on Windows/NVIDIA has not been reproduced; this is a general ownership fix candidate, not a playability claim.

Tested

  • macOS arm64 host, Apple Clang 17: x86-64 C++20 syntax checks passed for Texture.cpp and the runtime fixture using pinned Vulkan/SDL headers. This does not execute the Linux/Windows runtime.
  • Tooling tests: 14 passed. Documentation links, committed conventions and diff checks passed.
  • Native CI passed for code revision 690ebaded1e266df03954a0816236845c8b24376 (Build run); the subsequent commit updates only this validation debt entry.
  • Linux x86-64, GCC 13.3, Mesa 25.2.8 llvmpipe, Vulkan required: full build and patched libraries passed. CTest: 474 passed, 25 capability skips, zero failures, 499 registered tests. Both storage regressions executed: edges 6.23 s, full blocks 6.25 s, below the 30 s limit.
  • Windows x86-64, WinLibs GCC 15.2: full build and patched libraries passed. CTest: 285 passed, 205 capability skips, zero failures, 490 registered tests. Both storage GPU regressions skipped on the hosted runner; this is compilation coverage, not Windows GPU validation.
  • The Linux runtime fixture uses #1918's test-only page-watch backend; Vulkan host imports, GPU commands, detiling, allocation tracking and readback remain production code. Native write-watch races and real Windows GPU execution remain unverified.
  • No interactive title testing performed.

Checklist

  • Current main ancestry; depends on the disclosed #1918 prerequisite
  • One topic per PR; follow-up to #1918 in a separate PR
  • No new code comments
  • No unimplemented paths or silent stubs added
  • No investigation notes, reports, images or logs added to the repository
  • No new third-party dependencies
  • Generic behavior, not specific to one title
  • Depends on: #1918
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4795922012 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1997). Originally posted by [ToyuAU](https://github.com/ToyuAU) on 2026-10-09T04:19:49Z. --- ### What Withdrawn as a proposed fix for #1970. The new #1995 evidence identifies guest allocator reuse inside a still-registered allocation. This candidate's baseline/allocation checks cannot establish ownership in that case. Its passing tests cover images that still own their memory, not the reported lifetime failure. #1994 and #1995 already provide the author's hardware-tested workaround; preserve this branch and its test results for reference rather than merge a competing byte policy without lifetime proof. A draft candidate for the full 64 KiB page-stamp behavior discussed in #1970. A CPU page stamp currently discards an entire aligned image block even when guest bytes still equal the upload baseline, losing pending GPU results. Extend #1918's immutable byte merge to every watched image block: unchanged destination bytes accept changed GPU results, actual CPU edits survive, and newer ordered driver stores or replaced allocations still veto the merge. Depends on #1918 at `97655b677e273d93fb8fdfe1393ae7a372904a1b`, which is included in this branch. This PR adds the full-block extension and regression cases; it does not replace that partial-edge PR. Open alternative #1599 addresses partial-edge equality and does not implement this full-block byte merge. Existing fixes #1968 and #1969 do not establish byte ownership for CPU-stamped full blocks. New #1995 reports write-trap evidence of Unity allocator reuse and a Windows/NVIDIA Silksong workaround, `APS5_STORE_AT_FLIP=1`, with #1994's opt-in watched imports. That is distinct from this byte merge and already provides the reported title's tested workaround. A baseline cannot prove that bytes still belong to the image when a guest allocator reuses memory inside the same registered allocation; unchanged or reset bytes may belong to the new object. This PR therefore does not resolve #1970's allocator-lifetime cause and must not be treated as a substitute for storing results before guest GPU completion is exposed. Keep draft pending that ownership decision and hardware evidence. Pack block baselines and merge outputs into shared buffers instead of allocating a Vulkan buffer per block. Capture and ordinary writeback retain baselines across uploads, clears, copies and aliases. Add a separate CTest invocation covering mixed CPU/GPU bytes, same-value CPU writes, uncollected page writes, refresh, second merge cycles, driver precedence, allocation replacement, unchanged GPU results, aliases, pending operations, CPU fallback and an aligned 8 MiB surface with every block CPU-stamped. Keep this draft pending native CI and runtime/performance validation. Baseline storage scales with image size, upload capture copies guest bytes, and snapshot-covered blocks bypass unit shadows. The exact Silksong format-56/tile-7 stack on Windows/NVIDIA has not been reproduced; this is a general ownership fix candidate, not a playability claim. ### Tested - macOS arm64 host, Apple Clang 17: x86-64 C++20 syntax checks passed for `Texture.cpp` and the runtime fixture using pinned Vulkan/SDL headers. This does not execute the Linux/Windows runtime. - Tooling tests: 14 passed. Documentation links, committed conventions and diff checks passed. - Native CI passed for code revision `690ebaded1e266df03954a0816236845c8b24376` ([Build run](https://github.com/boykopovar/AnyPS5/actions/runs/37883363708)); the subsequent commit updates only this validation debt entry. - Linux x86-64, GCC 13.3, Mesa 25.2.8 llvmpipe, Vulkan required: full build and patched libraries passed. CTest: 474 passed, 25 capability skips, zero failures, 499 registered tests. Both storage regressions executed: edges 6.23 s, full blocks 6.25 s, below the 30 s limit. - Windows x86-64, WinLibs GCC 15.2: full build and patched libraries passed. CTest: 285 passed, 205 capability skips, zero failures, 490 registered tests. Both storage GPU regressions skipped on the hosted runner; this is compilation coverage, not Windows GPU validation. - The Linux runtime fixture uses #1918's test-only page-watch backend; Vulkan host imports, GPU commands, detiling, allocation tracking and readback remain production code. Native write-watch races and real Windows GPU execution remain unverified. - No interactive title testing performed. ### Checklist - [x] Current main ancestry; depends on the disclosed #1918 prerequisite - [x] One topic per PR; follow-up to #1918 in a separate PR - [x] No new code comments - [x] No unimplemented paths or silent stubs added - [x] No investigation notes, reports, images or logs added to the repository - [x] No new third-party dependencies - [x] Generic behavior, not specific to one title - [x] Depends on: #1918 - [x] AI-assisted: yes
github-actions[bot] commented 2026-10-09 04:36:43 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-09T04:36:43Z.


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
#1686 docs/dev/TechnicalDebt.md L242
#1847 core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp L770
docs/dev/TechnicalDebt.md L242-243
#1994 docs/dev/TechnicalDebt.md L242-243
#1995 docs/dev/TechnicalDebt.md L242
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6074354192 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/1997#issuecomment-6074354192). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-09T04:36:43Z. --- <!-- 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 | |---|---|---|---| | #1686 | `docs/dev/TechnicalDebt.md` [L242](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/docs/dev/TechnicalDebt.md#L242) | | | | #1847 | `core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp` [L770](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp#L770)<br>`docs/dev/TechnicalDebt.md` [L242-243](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/docs/dev/TechnicalDebt.md#L242-L243) | | | | #1994 | `docs/dev/TechnicalDebt.md` [L242-243](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/docs/dev/TechnicalDebt.md#L242-L243) | | | | #1995 | `docs/dev/TechnicalDebt.md` [L242](https://github.com/boykopovar/AnyPS5/blob/f145139676a48306681d3a4d5fabf83938759daf/docs/dev/TechnicalDebt.md#L242) | | |

Pull request closed

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!1997
No description provided.