fix(agc): drop stale depth-plane results whose guest memory was unmapped #9406
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9406"
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 JJenkx on 2026-10-21T20:57:01Z.
What
A depth plane that a draw wrote is marked stale and stored to guest memory later, when something overlaps it or the device stores idle results. If the title has unmapped that memory in the meantime, the store creates a
StorageTextureover pages that are no longer committed, and the driver stops:The path is:
Wobbly Life (PPSA29413) hits this about 108 s in: it unmaps the memory of a 64 MiB 4096x4096 D32 depth target (64 KiB Z swizzle) after drawing to it, before the plane is stored.
FlushDepthPlanesnow checks for readable committed pages before storing a stale plane. A readable plane without write permission retains the existing unsupported-store failure and its pending results; it is not treated as unmapped. When none are left, it does not store the plane: the pending depth is dropped, the surface is no longer stale, and a one-time warning names the plane. The discard path is used only when the readable committed-range query is empty. The debt file records the behaviour, and what the console does with such a store is not known.Tested
Protected-memory regression correction. The former writable-only guard also discarded pending depth for a readable mapping protected against writes, and printed that it was unmapped. A CPU/mock probe using a real
PROT_READmapping confirms the difference: the pinned main rejects the store and keeps pending depth (rejected=1, pending=1); the original #9406 rebased onto that same main silently drops it (rejected=0, pending=0). The correction queries readable ranges before discarding. The new cross-platformTestReadOnlyStalePlaneFlushrequires the original rejection and pending state to survive. The unchanged extended mock fixture fails its specific rejection assertion with the original #9406 libraries and passes with the corrected depth implementation. These initial results use separately compiled objects relinked with the pinned main object set; they are supplemental CPU/mock evidence, not the coherent full-source Vulkan comparison. The coherent Release build also passes. Maina19e7f6fand corrected headf4c543528eeach passagc_driver_graphicsandagc_driver_graphics_maps_fallbackthree times (six runs per arm). The exact coherent corrected fixture fails the readable-protection assertion against the original rebased #9406 libraries in both query paths. These binaries use a mock device and do not establish Vulkan-layer coverage. Coherent paired hardware validation also passes on maina19e7f6fdc5475c538e2a9135aa45880503ef377and headf4c543528eb339d059f9472b02cae9475e5d81e8: five focused checks per arm (host-import mock, graphics mock, depth-plane partial store, depth storage and prepared exports). Vulkan required, shader cache disabled, actual Khronos insertion confirmed in each of the three hardware cases. Both arms have the same pre-existingVUID-VkPipelineColorBlendStateCreateInfo-pAttachments-00605; the change adds no VUID types. This does not claim zero validation errors. Conventions and whitespace pass; merge-tree is clean against newer mainad19afc31e, which was not the test baseline. Pinned raw hardware/mock logs, negative-control results and source review. A Windows exact-head mock check has been requested separately and is not claimed here.Independent macOS report, historical head. @imellag reports Planet of Lana PPSA19450 on Apple M4 Pro, macOS 27.0.1 under Rosetta 2 and MoltenVK 1.4.2. The tester identifies the same unmapped 64 MiB D32 depth-plane flush path with a backtrace and preceding memory-unmap trace. Four runs without this PR stopped; two with historical head
1855089a95reached gameplay and the 200-second limit, logging the drop warning. This was a macOS integration containing #8658 and several other patches, not stock main, and has not been rerun with the protected-memory correction. It is attributed external correctness evidence; no FPS gain or console equivalence is inferred.Independent same-base repeat, 2026-10-23: @xXPBSXx reports PPSA25936 on main
ba1b117cec6caa95fb6e0c46b4392baa0ce2d11cversus that exact main plus this PR head1855089a95e9ab865a4b50d952c6e72044e3f9c4(local merge1478b1c4642184969a9e5439e28f73402ece13bb). Two 600-second runs per arm on each of AMD Radeon RX 6400 and NVIDIA RTX 4080 SUPER: the storage-texture/no-committed-pages stop occurs in both main runs on each GPU and in neither change run on either GPU. The tester reports unchanged non-AGC libraries and relinker between arms. This is attributed external evidence, not a local rerun; n=2 per arm/GPU does not establish an intermittent-failure rate, other-title coverage, gameplay correctness, console equivalence or an FPS gain. The common base is deliberately older than the then-current main. This repeat replaces that tester's earlier comparison between different main revisions.Linux 7.2.9, Ryzen 9 7950X, Radeon RX 6650 XT, RADV Mesa 26.2.4, Release.
New test.
TestUnmappedStalePlaneFlushinagc_driver_graphics(DepthSurfaceReuse.cpp, mock device) draws to a mirrorable D32 plane at an unmapped address, then flushes it. It requires that the flush does not throw, stores nothing and clears the stale state.DepthSurface.cpprestored to main and the test kept: fails, because the flush throws (rechecked onb27924d851).Independent Linux regression report. On head
1855089a9merged onto main7e2ba73e4, Dextroid17 reports that bothagc_driver_graphicsandagc_driver_graphics_maps_fallbackpass 6/6 runs each; restoring main'sDepthSurface.cppwhile keeping the regression test makes both fail 6/6. This exercises both LinuxPROCMAP_QUERYand/proc/self/mapspaths. These focused binaries use a mock device and do not load the Vulkan loader or ICD; settingVK_INSTANCE_LAYERSfor them does not establish validation-layer coverage. The actual Vulkan comparison is the separate full-suite report below. These are independently reported results on CachyOS, not a local rerun (report).Full
ctest -j8. Run on mainb27924d851and on this change rebased onto it (1855089a95), withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(the loader inserted the layer; nowas not found but was requestedline),ANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1. Both runs have 1827 tests with the same 4 failures and the same 25 skips. The failures are:guest_named_shm_concurrency;agc_idle_publish_wait;agc_driver_image_array_window_past_layer_limit;agc_driver_tessellation(segfault).The
VUID-sets and counts are identical:VkWriteDescriptorSet-descriptorType-00337VkPipelineColorBlendStateCreateInfo-pAttachments-00605VkImageMemoryBarrier-image-03320VkImageViewCreateInfo-usage-02275vkCmdCopyBuffer-srcBuffer-00118With
DepthSurface.cpprestored tob27924d851and the test kept,agc_driver_graphicsfails under the same environment, because the flush throws. The same comparisons on the earlier bases0c6a5bd593(1813 tests) andb3c0f48bdd(1806 tests) also matched.PPSA29413, natively. Same scripted input (Cross every 15 to 20 s):
cecb540a630c6a5bd593The runs with the change reach the play menu, the tutorial prompt and the intro comic at about 120 FPS. Each printed the drop warning once for the title's 64 MiB depth plane, and none caused a GPU fault in the kernel log.
Rebase. Main's per-unit depth-plane stores (#9026) now store only the overlapped units. The check sits in that path, before
SyncFromMemory, and clears every stale unit of an unmapped plane. The PPSA29413 rows below are on the earlier bases; the title was not rerun onb27924d851.Overlap. #1368 and #1395 also change
DepthSurface.cpp, and #1368 changesDepthSurfaceReuse.cpp. Neither changesFlushDepthPlanesor handles a plane whose memory is unmapped: #1368 adds 2D-array depth storage and only setsmaxImageArrayLayersinRunDepthSurfaceReuseTests, and #1395 adds an alternative array-storage path. Both conflict with current main, so a merge with this PR was not tested; whichever lands second must keep this check and test. This PR does not depend on either.8e6bbb3a2dmerged onto current main:agc_driver_graphicspasses 3 of 3 and fails 3 of 3 with main'sDepthSurface.cpprestored. One ran on an RTX 5070 Ti and an AMD RDNA2 iGPU (comment); the other did not record its GPU (comment).Other titles (reports by others in this PR):
0c6a5bd593in 3 of 3 runs; see the comment for the runs with the PR (comment).Not verified:
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)Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-21T22:59:42Z.
This needs a rebase: head
ecb2220no longer merges onto maina6dcea927.git merge-treereports conflicts inGraphics/src/DepthSurface.cppanddocs/dev/debt/libSceAgcDriver.md. #9026 (f57bbc936, "store only the depth plane units a flush overlaps") rewroteFlushDepthPlanes. Thesurface->memoryStale = false; … SyncFromMemory … stored.emplace_back(...)block the check was inserted into no longer exists. Main now stores per-unit throughStaleUnitsIn/StoreDepthPlane(resource, units)/ClearStale(units).Is the bug still on main? I applied only the PR's
TestUnmappedStalePlaneFlushto maina6dcea927(Windows 11, WinLibs GCC 15.2.0, Release; mock-device test, run with both the RTX 5070 Ti and the Radeon iGPU selected).agc_driver_graphicsfails:So the flush still tries to store the unmapped plane on main. In the mock it now fails on the storage-format check, before the
storage texture has no committed guest pagescheck inTexture.cpp. The rebased check needs to go beforeSyncFromMemory/StoreDepthPlanein the new overlapped-units branch. It also needs to clear the stale units there, so thatDepthPlanesStale()turns false.Nit: the diff adds
#include <cstdio>while the file already includes it three lines below.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T02:27:46Z.
Thanks, and for confirming the bug on main with the mock test. The PR head is now
8e6bbb3a2d, rebased onto0c6a5bd593(after #9026), andgit merge-treeagainst current main is clean.SyncFromMemory/StoreDepthPlane. For a plane without writable committed pages it callssurface->ClearStale(), soDepthPlanesStale()turns false, and continues.DepthSurface.cppincludes<cstdio>once; the duplicate came from main's file during the rebase and is gone.ctestwith Khronos validation on main0c6a5bd593and on the PR: 1813 tests, same failures, same VUIDs;Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-22T02:58:48Z.
Re-checked
8e6bbb3a2merged onto currentmain(clean) on Windows 11, WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1:agc_driver_graphicspasses 3/3 on the RTX 5070 Ti and 3/3 on the AMD RDNA2 iGPU (ANYPS5_GPU=AMD). That includesTestUnmappedStalePlaneFlush.DepthSurface.cppfrommain, it fails withflushing a depth plane whose guest memory is not mapped must drop its results: ... guest storage texture format 100 cannot be used as a storage image, which is the failure from my earlier comment.FlushDepthPlanesand the single<cstdio>include look right.AI-assisted: yes (Claude Code); results above were run on this machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-22T03:42:30Z.
Windows data point for
8e6bbb3a2merged ontomain6ef5a1c4c(clean,git merge-treerc 0): Windows 10.0.19045, MinGW-w64 GCC 15.2.0, Release.ctest -N -R '^agc_driver_graphics$'lists exactly that one test;ctest --no-tests=error -R '^agc_driver_graphics$'was run three times per tree. The GPU was not recorded in these logs, so no device is claimed.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpprestored tomain(the new test cases kept): fails 3 of 3 (ordinary test failure, not a crash).Not tested: other platforms, a title run.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T05:33:16Z.
Review: DISMISSED
The reported failure is reproducible in the mock regression, and the change places the unmapped-memory check before synchronization and storage. The author’s paired Vulkan validation-layer runs, title negative control, and independent Windows positive/negative runs are useful evidence.
git diff --checkalso passes on the current head.I’m requesting changes for the remaining repository requirements:
0c6a5bd593, while currentmainis4a17c71757. Please rebase onto currentmain, resolve any conflicts, and refresh the focused AGC validation runs on that base. AGC changes require the same focused tests on main and the change with the validation layer and Vulkan-required environment, comparing VUIDs and naming the GPU.DepthSurface.cppandDepthSurfaceReuse.cpp) or #1395 (sharedDepthSurface.cpp) because those branches conflict with current main. Both PRs modify the depth-surface implementation. Please manually establish whether the changed behavior overlaps, coordinate the order with their authors where it does, and updateDepends on:accordingly. The scan also identifies uncomparable shared debt-file edits; please refresh that check after rebasing and resolve any actual same-entry overlap with the authors.The recorded Linux full-suite and title runs are on base
0c6a5bd593, not currentmain; the external Windows checks are valuable independent reports but do not replace the required refreshed paired validation. No local AGC test was run in this review environment: it has no/dev/dridevice or existing build tree. Hosted product jobs on this PR are skipped; the conventions check, eligibility, labels, and report checks pass.Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T05:44:35Z.
A second title for this fix, and it reproduces on demand: Hamster Playground (PPSA06652) 01.009.000, Unity. Linux 7.2.9, Radeon RX 6650 XT, RADV Mesa 26.2.4, GCC Release.
Trigger: from a save that already has a house, Cross at 25/40 s clears the disclaimer, Down at 55 s moves to PLAY on "Select your house", Cross at 58 s loads the house. On
mainthe driver stops about 2 s later, at 60.3 s, every time I've run it that way:Stack (GDB on
main38d3c0858a, breaking at_Unwind_RaiseExceptioninlibc.prx): the first throw is this PR's path:The presenter thread only reports it afterwards (
[videoout] presentation failed).Before/after: this PR's base
0c6a5bd593against its head8e6bbb3a2d. OnlylibSceAgcDriver.prxdiffers (sha256 prefixesd850c2947bd5d79cand64a871bf7952ae3b); every other library is the same set, and the title is relinked against each. Same input schedule, same restored save before every run.0c6a5bd593storage texture has no committed guest pages8e6bbb3a2dTwo of the pairs come from a launch that restored the same save before every run. The third pair is from the run right after the one that created the house.
With this PR the house loads: the in-game tutorial notebook over the 3D room, then the "Skip Tutorial" dialog. The log has this PR's warning in place of the stop:
followed by four
storage image ...+0x1fe0000: memory no longer registered; 510 pending ranges droppedlines.Logs and reports of all six runs, the two screenshots, and the GDB log with its script: 20261022-pr9406-PPSA06652.tar.gz (sha256
c99e6e173cb370faf87a79077eeac4fcff160bafdefd6331879a09f5a6100de2).AI-assisted testing and report: yes, Claude Code.
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-22T06:31:46Z.
@MarcZX10 thanks. Addressed:
Rebase. Now on
mainb27924d851as1855089a95; it applied without conflicts.tools/check_conventions.py --base origin/mainpasses. The debt change is one new bullet after "Depth planes in guest memory" and edits no existing entry.Paired validation on that base. Full
ctest -j8onb27924d851and on1855089a95, run on a Radeon RX 6650 XT (RADV Mesa 26.2.4, Linux 7.2.9). Environment:VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(the loader inserted the layer, with nowas not foundline),ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1. Results:VUID-sets and counts are identical; the table is in the body.Negative control on that base. With
DepthSurface.cpprestored tob27924d851and the test kept,agc_driver_graphicsfails under the same environment: "flushing a depth plane whose guest memory is not mapped must drop its results".Overlap with #1368 and #1395. I compared their patches. Neither changes
FlushDepthPlanesor handles a plane whose memory is unmapped:DepthSurfaceReuse.cpphunk only setsmaxImageArrayLayers;So
Depends on: nonestays. Both conflict with current main, so I could not test either combined with this PR. Whichever lands second has to keep this check and its test; I've noted that in the body and will ping their authors.The title runs in the body are still from the earlier bases; Wobbly Life was not rerun on
b27924d851.Imported from boykopovar/AnyPS5. Originally posted by THEMANnt on 2026-10-22T09:24:10Z.
Windows Biped (PPSA24589), content version 01.000.002, 2026-10-22 retest for discussion #9376.
Compared unmodified main
7e2ba73e4c8c26b5d632b0d2f46166ffc1b8a29dagainst PR head1855089a95e9ab865a4b50d952c6e72044e3f9c4merged cleanly onto it (local merge61bdb4b103c37455dab895304c87b4bf35e30f96). Windows 11 Pro build 26200, Ryzen 7 7800X3D, 32 GB RAM, RTX 5070 Ti 16 GB, NVIDIA 616.92, GCC 15.2 Release.AGC graphics: storage texture has no committed guest pagesand SIGABRT at about 170 seconds. The harness subsequently stopped the failing process at 172.08 seconds when available RAM fell below 5 GiB; its recorded stop reason ismemory_watchdog, not a natural crash exit.duration_limit. No storage-texture driver failure or SIGABRT captured. The PR's new path was exercised:Both runs reused the same source assets and the same pre-run save snapshot, with isolated frozen runtime-library copies. The native game executable was identical. No game patch, metadata override or scripted controller input. Candidate minimum sampled available RAM was 5.14 GiB; available commit 21.79 GiB.
Focused tests:
agc_driver_graphics,agc_driver_depth_fast_clear,agc_driver_depth_storagepassed 3/3 on both trees, withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, verbose CTest output. Both logs have zeroVUID-matches and no missing-layer warning; the Vulkan test selected the RTX 5070 Ti. Candidate graphics coverage includesTestUnmappedStalePlaneFlush. An initial depth-test attempt skipped because the build selection omitted those sources; they were enabled, rebuilt and run successfully for the comparison above.Remaining: main-menu music is still absent; gameplay music works (verified with the PR). The earlier cutscene-audio issue was not rechecked. Save reload and full-game/long-term stability are not established by this bounded run. These mixed-scene FPS samples are not a performance comparison.
The title was sitting in a menu midway through the candidate session; I then resumed gameplay. The total recording duration is not continuous gameplay duration.
Near the end, I confirmed that gameplay after resuming remained responsive, without another freeze or visible graphics problem.
AI-assisted: yes (Codex prepared the builds/logging and checked results; I controlled and visually tested the game).
Imported from boykopovar/AnyPS5. Originally posted by Dextroid17 on 2026-10-22T11:38:34Z.
Linux data point for
1855089a9onmain7e2ba73e4(local merge44ddd9d81,git merge-treeclean): CachyOS, kernel 7.2.11, GCC 16.2.1, CMake 4.4.3, Ninja, Release,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,-j1.ctest -N -R '^agc_driver_graphics'lists two tests here:agc_driver_graphicsand the Linux-onlyagc_driver_graphics_maps_fallback(APS5_NO_PROCMAP_QUERY=1), which the Windows runs above cannot cover: the newGuestMemory::CommittedRangescall inFlushDepthPlanesgoes throughdescribePages, which on Linux takes thePROCMAP_QUERYioctl or, with that variable set, the/proc/self/mapsscan (on Windows,VirtualQuery).Head. Both tests pass 6 of 6 runs each (3 plain, 3 with
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, which changes nothing here, see below); each test's output has the new[gpu] depth plane 0xa0000000+0x40000 was unmapped with GPU results pending; they are droppedline, on the ioctl path and on the/proc/self/mapsfallback alike.Negative control.
Graphics/src/DepthSurface.cppfrom7e2ba73e4, the PR'sDepthSurfaceReuse.cppkept: both tests fail 6 of 6, alwaysflushing a depth plane whose guest memory is not mapped must drop its results: AGC graphics: guest storage texture format 100 cannot be used as a storage image, the line @wachi35676 reported on Windows in https://github.com/boykopovar/AnyPS5/pull/9406#issuecomment-6328446069; thewas unmappedmessage does not appear.One note for anyone adding a validation-layer arm here:
agc_driver_graphics_testsis a mock-device binary and loaded no Vulkan loader or ICD on this host (LD_DEBUG=libslists nolibvulkan.so.1;VK_LOADER_DEBUG=allprints nothing), soVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validationcannot apply to it and no GPU name attaches to its result.AI-assisted: yes (Claude Code); results above were run on this machine.