fix(agc): keep guest bytes written after a GPU draw out of the image write-back #19130
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/19130"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by muhmuhkuh on 2026-11-12T20:47:26Z.
What
A storage image keeps the write generation of its last GPU write per unit and, up to 1 MiB, a snapshot of the guest bytes at the moment it becomes pending. The write-back now leaves to the guest the pages the CPU wrote after that generation: byte by byte against the snapshot where one is held, by whole pages otherwise. Before, a drawn linear target stored its drawn spans over such pages, and a unit without a generation was stored whole. The unit is marked stale where bytes were left and reloads at its next use. APS5_NO_GUEST_NEWER_KEEP=1 stores as before.
This is not the case #16011 fixes. #16011 covers an idle store: a CPU store made after the idle flush returns, before the copy runs, is overwritten, and #16011 makes the idle store complete before it returns. This change covers a guest store made after a GPU draw that wrote the image: the guest bytes written inside the drawn rectangle after the draw are overwritten by the write-back, and this change keeps them out of it. #16011's own tests pass on its head, and the test added here still fails on that head (both after-draw cases report WRONG). #16011 was also checked by hand against this change.
pr_overlap ran fail-closed (rc=2): it cannot compare PRs that conflict with
main, so it reported 82 PRs as unconfirmed, 38 of them sharingTexture.cpp. Those were checked by reading their diffs for the functions this change touches; one open PR, #18102, touchesmarkLayersPending(a memoized collect) without a textual conflict with this branch. Both touchmarkLayersPending; whichever lands second rebases, and the two authors coordinate the order.Tested
Windows 11 Pro (10.0.26200), NVIDIA GeForce RTX 3080 Ti, driver 610.88, Release, validation layer on (
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation). Built on the same machine onmain1d0b2c771aand on this branch at 8263b61d65f (two commits on1d0b2c771a: 1908a8e0147, 8263b61d65f).agc_driver_write_back_guest_newer(new): fails onmain. Both cases where the guest writes inside the drawn rectangle after the draw (small target, large target) report WRONG there. The control cases pass onmain. On this branch the test passes 1 of 1.agc_driver_storage_write_back_no_windowandagc_driver_storage_write_back_overhang: pass onmainand on this branch.windows_write_watch,windows_write_watch_verify_direct,windows_mappings_releaseand its variants: 6 of 6 pass onmainand on this branch.VUID-line in any log, onmainand on this branch. The phrasewas not found but was requested by env var VK_INSTANCE_LAYERSappears in no log.Checklist
main(1d0b2c771a)NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T04:33:09Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the implementation and its added test code were reviewed, but no checks were run here.
What I ran
Reviewed head
8263b61d65f7759a6a879f8e0cf937ccf76e961bagainstmainusing the prepared diff andrepo_read.py. No build or test commands were run.Results
Negative control
Not run; this session did not run the added test or alter the code under test.
Findings
Blocking
None.
Non-blocking
None.
Not verified
No runtime behavior, build, or test output was verified in this session. The description reports Windows/NVIDIA test results; those were not independently confirmed. All changed files listed in the manifest were read, including
Texture.cppthrough the pinned reader because its full text was excluded from the review folder. No other changed file was excluded.To get this to a good state
Nothing is required.
Sources
Reviewed the added write-back logic and test at Texture.cpp, Texture.hpp, WriteBackGuestNewer.cpp, and ENVIRONMENT.md.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T18:26:39Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the inspected diff and source; the author-reported focused GPU tests cover the main small and large target cases.
What I ran
Read the prepared diff and targeted source at head
988ac43473d2ed819da9a1034611d75bebf3d12fusingrepo_read.py. No build or test commands were run. ReadTexture.hpp,Texture.cpp(targeted ranges),GuestMemory.cpp(targeted range), the newWriteBackGuestNewer.cpptest, andENVIRONMENT.md.Texture.cppwas excluded from the prepared full-text bundle because it was too large; it was inspected through the reader.files.jsonwas not available as a review document; the manifest and file listing identify all four changed files.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full
Texture.cppfile, the full CPU suite, Linux behavior, and other AGC tests were not reviewed or run. The supplied description reports focused Windows 11 / RTX 3080 Ti tests, but those results were not independently verified.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-25T07:14:25Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
429c10a0df9aa8db4418e2ed1883fe704b2c184cagainstmain. No commands or tests were run. The description reports Windows 11 Pro with an RTX 3080 Ti; those runs were supplied by the author.Results
Findings
Blocking
None.
Non-blocking
Not verified
No tests were run here, and Linux, physical-console behavior, and the full CPU and AGC suites were not verified. Read
Texture.hpp,WriteBackGuestNewer.cpp, andENVIRONMENT.md; reviewed the changed hunks and targeted context inTexture.cppthroughrepo_read.py.Texture.cppwas excluded from the review folder because it was too large, so its full text was not read. The changed test's build registration was not verified.To get this to a good state
Nothing is required. Optional: add coverage for layered/block-unit targets and writes across partial tracker pages.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-27T20:28:25Z.
Review: COMMENTED
Actionable comments posted: 2
e9c94a8c-d929-4492-8f5f-93cab052c96fReviewing files that changed from the base of the PR and between
fdf873a7d2and801b7d97a1.core/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/execution/WriteBackGuestNewer.cppdocs/dev/ENVIRONMENT.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.