Skip to content

fix(agc): save the bytes a GPU-side store writes outside the write watch - #5760

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/storage-gpu-store-saved-bytes
Oct 14, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
oneandonlydean:fix/storage-gpu-store-saved-bytes

Conversation

@oneandonlydean

@oneandonlydean oneandonlydean commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What

A write-back stored on the GPU over memory outside the write watch left its units without saved guest bytes. Only the CPU path saved them. The next store of results there threw "storing storage image results pending over memory outside the write watch without the guest bytes saved before them is not implemented" (#5711, #5693), and every refresh re-uploaded the image.

  • The stored ranges are copied from the retile scratch into a host-visible buffer behind the store (both the block-unit and the whole-layer path). They become original when the batch completes (OnComplete). A write-back or refresh that needs them first syncs that batch. Anything that replaces or drops a unit's saved bytes in the meantime cancels the save for that unit.
  • A pending unit without a write generation whose range leaves the watch saves its bytes in saveBeforeUnwatch, as the watch would store it whole.
  • StoreOverUntracked: a surface outside the watch from the start is stored twice, with a CPU write to another block in between. On main the first store leaves no saved bytes (the test fails); with this change the CPU block is kept and the second result is stored.

Stacked on #5707 (review only the top commit). Once #5679 is in, its capture at landing has to skip units whose save is still pending (savedTicket[layer] == 0).

Tested

Checklist

@Amoenus

Amoenus commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

@oneandonlydean While refreshing the PPSA99902 validation stack, StoreOverUntracked access-violated on Windows NVIDIA. I reproduced it on unchanged main3e (initial failure, then nine passes followed by another failure); AMD passed20. Run can return while a Store is still queued, then destroy its local surfaces. #5789 records the reproduction.

The separate three-line cleanup wait in #5790 passed100 repetitions on each GPU, both before and after rebase onto main82. It leaves the GPU mutex before waiting and retains the original store assertions. Your new RunSecondStore also has early returns after submission, so it may need the same lifetime ordering. I have not tested #5760 or established that its new case crashes. This report concerns fixture lifetime, not validation/rejection of your production correction. AI-assisted: Codex.

@oneandonlydean
oneandonlydean force-pushed the fix/storage-gpu-store-saved-bytes branch from 8f1ffed to 84a41e2 Compare October 14, 2026 11:40
@oneandonlydean

Copy link
Copy Markdown
Collaborator Author

Rebased on main (#5707 is in, so only this commit is left); RunSecondStore now waits for the GPU before freeing its surface, as #5790 does. Thanks @Amoenus for spotting it.

@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
@github-actions github-actions Bot added the needs rebase Conflicts with main, rebase needed label Oct 14, 2026
A write-back stored on the GPU over memory outside the write watch left its
units without saved guest bytes (only the CPU path saved them), so the next
store of results landing there threw (boykopovar#5711), and every refresh re-uploaded
the image. The stored ranges are now copied from the retile scratch into a
host-visible buffer behind the store and become the saved bytes when the
batch completes; a store or refresh that needs them first syncs that batch.
Units without a write generation pending when their range leaves the watch
save their bytes there too.

The second-store fixture waits for the GPU before its surface is freed on
every return, as boykopovar#5790 does for the other cases.
@oneandonlydean
oneandonlydean force-pushed the fix/storage-gpu-store-saved-bytes branch from 84a41e2 to 69702ef Compare October 14, 2026 18:09
@github-actions

github-actions Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

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
#5892 docs/dev/debt/libSceAgcDriver.md L56-57
#5906 docs/dev/debt/libSceAgcDriver.md L56-57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants