fix(agc): publish multisample depth over pages only an import window touched #22062
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22062"
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 ycbuzi on 2026-11-17T03:53:45Z.
What
Native multisample depth publication threw
native multisample depth publication cannot distinguish an unwritten byte from a same-value guest storeon pages whose only CPU-side mark came from an import window.When a host import runs over watched memory, the write tracker re-walks the pages the write watch reports dirty. Pages whose bytes did not change across the import get an
ImportWindowstamp: a possible CPU touch, not a store (CheckImportWindowcovers this). The block's stored stamp stays put andStoredOveranswers false. The tracker still noted those pages incpuPages, though, andUnchangedSinceLastCollect(the publication's last per-byte check) readscpuPages. So a host-changed byte that still equalled its snapshot on such a page counted as a possible same-value CPU store, and the read threw.Main already settles this for pending GPU results: under an import window, a page counts as stored only when its bytes change (see the "Pages under an import window" debt entry). This PR applies the same rule to depth publication:
WriteTrackerkeepscpuStoredPages, the pages noted as real CPU stores. The pages an import window resolved without a change (and runs walked asImportWindow) are noted as touches only (noteCpuTouch).cpuPagesand every existing query behave as before.StoreUnchangedSinceLastCollectworks likeUnchangedSinceLastCollectbut ignores those touches.PublishToGuestuses it for its last per-byte check. A touched page takes the host result. A real same-value CPU store, before or after the window, still throws.Evidence from the title: a temporary diagnostic build (not in this PR) printed the failing byte for PPSA06866 on the Radeon iGPU:
Every byte of the page was unchanged. The block's stored stamp was older than the capture, and only the CPU stamp was newer, which is the
ImportWindowsignature.Tested
Windows 11 (26200), MinGW GCC 15.2.0, Release.
agc_write_tracking(newCheckImportWindowTouchIsNotAStore). An unchanged import-window page still failsUnchangedSinceLastCollectbut passesStoreUnchangedSinceLastCollect. New bytes inside the window and a later same-value store both read as stored. Untouched pages read as unstored.agc_driver_native_depth_publication:ImportSameValuemust now publish the host depth over the touched page. The newImportThenSameDepth(a same-value CPU store after the window) must keep the guest byte or refuse.SameDepth,Possible,ChangedHulland the other existing cases are unchanged.521fb7fec4vs this branch,ctest -R '^(agc_driver_native_multisample_depth|agc_driver_native_depth_.*|agc_write_tracking)$'withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, twice per GPU, non-elevated. The layer loaded on both sides (nowas not found but was requestedlines). There were 0VUID-errors on main and 0 on the branch, on every GPU. Results were identical on both sides: 31 of 32 passed.agc_driver_native_depth_bda_clearreports Not Run because its executable is a separate target I did not build.driver_queued_fillskips on both sides. The publication test printed the new case (write=30) on all three GPUs on the branch.libSceAgcDriver.prx. Before: abort after 114 s with the error above (reproduced with the diagnostic build). After: the error did not come back, and the game kept running and presenting until the 300 s harness limit stopped it, with no new driver failure in the log.7a78b2aabd:StoreUnchangedSinceLastCollectalso ignored import-window touches only on pages with no stored stamp in their 64 KiB block; a touched page beside a CPU-stored page still threw throughStoredOver. It now reads only real CPU stores there, and publication asks once per page before the per-byte query.agc_write_trackingchecks a store beside a touch. Rebuilt and ran on the same machine (RTX 4070 SUPER):agc_write_tracking*11/11,agc_driver_native_multisample_depthandagc_driver_native_depth_*28 passed,driver_queued_fillskipped as on main. The Vulkan validation A/B and the Divinity run above were on4790a046b9; this change touches no Vulkan calls.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)elsebranch ofPublishToGuest's byte loop and the D32S8 debt entry; whichever merges second takes the resolution in EagleBearerYS's comment https://github.com/boykopovar/AnyPS5/pull/22062#issuecomment-6941196314, verified by their dry merge bd8f8b7465). Also conflicts as text with #21719 (addsDepthReadCause::Writepublication in the same file and debt entry): this PR only changes how an undecided byte's page is classified, so #21719's strictWritepath keeps throwing for real same-value stores either way; whichever lands second merges both🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by kurexw on 2026-11-17T09:35:23Z.
Review: COMMENTED
Tested on macOS 27.2 on an Apple M4. This is an x86-64 build under Rosetta with Apple clang 21.0.0, on MoltenVK 1.4.2 from the LunarG Vulkan SDK 1.4.363.1.
Method. The base was
mainata72186d3cfplus #22056 and #22074, which fix the macOS build of two other targets; both have since merged. I built the base and this PR merged onto it (a clean merge) in two separate build directories. I ran them alternately, base then PR, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationandVK_LOADER_DEBUG=layer: three runs each:agc_write_trackingagc_driver_native_depth_publicationwas not found but was requestedVUID-linesThere's no regression, but on macOS the two tests this PR changes stop before or after its new cases, at checks the base already fails:
agc_write_tracking: it fails witha page only an import window stamped as a possible CPU touch was not listed. That check is inCheckImportWindowOtherThread, which this PR doesn't change. It runs after the newCheckImportWindowTouchIsNotAStore, so the new check passes on macOS.agc_driver_native_depth_publication: it fails withAGC graphics: guest writes raced native multisample depth publication, in an early case right aftersamples=2 write=3(the loop atNativeMultisampleDepth.cpp:4672). TheImportSameValueandImportThenSameDepthcases at line 4693 are never reached. So on macOS this test can't confirm the publication change in either direction.I didn't run a title.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T01:17:03Z.
Review: COMMENTED
Reviewed — no blocking findings
The reviewed changes appear consistent with the stated import-window behavior; I could not independently run the reported checks, so a formal approval is not justified.
What I ran
Reviewed head
7a78b2aabdd8a22fe3eb2dde2f6b348c9bd23638usingrepo_read.pyto inspect the prepared diff and relevant code at that pinned head. No tests or builds were run. The author-reported results are not results from this review.Results
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
Tests, builds, Vulkan validation, and the reported game run were not independently verified. Reviewed files:
GuestMemory.hpp,GuestMemory.cpp,DepthSurface.cpp,WriteTracking.cpp,NativeMultisampleDepth.cpp, anddocs/dev/debt/libSceAgcDriver.md. All six are marked included in the manifest; targeted relevant hunks and surrounding code were read, not every line of each full file.To get this to a good state
Nothing is required. Optional: run the reported tracker and depth-publication tests on the reviewed head and attach the results.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T18:41:42Z.
Review: COMMENTED
CheckImportWindowTouchIsNotAStoreusesbase + 0x2010to place a later store on a different page frombase + 0x100. The macOS write watch usesgetpagesize()and reports whole host pages. On a host exposing 16 KiB pages, these addresses are on the same watch page, so the test cannot expect one range to count as stored and the other to remain a touch. The fixture runs without a platform guard. Could it use the host watch granularity for those offsets while still keeping both pages in the same tracker block?Source review of
7a78b2aabd. The native depth and write-tracker files conflict with currentmain, and I have no native macOS result for the fixture.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.