fix(agc): end a native multisample depth surface whose planes the guest rewrote instead of refusing its publication #28796
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/28796"
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 oneandonlydean on 2026-12-03T17:45:11Z.
What
A read of guest memory under a host-written native multisample depth surface stops the run with "native multisample depth publication cannot re-import the guest's undecided byte" when the title's CPU has rewritten the surface's planes (#28664: PPSA25009 on Windows, 6 of 13 runs at 62 to 82 s; PPSA02817 on Linux, about 1 run in 6). In the traces there the CPU zero-fills depth and stencil pages and writes other words over the HTILE of a live, bound surface, with no unmap, free or bind first and no driver store.
The write watch is per page, so on a page the CPU stored to, a byte that still equals the snapshot may be a same-value store (a zero over a zero) or untouched. A reuse of the memory already takes the guest's byte there. A CPU, DMA, texture or buffer read kept the host's byte and, once a plane had taken a guest byte and the merged planes could no longer be imported, threw.
At that point the planes are the guest's: it has overwritten them.
DepthSurface::PublishToGuestnow does there what a reuse does:DepthSurfaceViewWithStencilWriteIntentdoes for a surface the guest replaced since its publication. One[gpu]line per ended surface (first 8).The next bind of the target imports its planes from guest memory. Planes that do not prove a clear give that import's existing sampling refusal until the title clears the target.
Nothing else changes: a publication with nothing undecided, one whose merged planes still import, and one where the CPU only stored values equal to the snapshot (no plane took a guest byte) behave as before.
The cost is in the debt entry: host depth on a page the CPU stored to is lost where the console would keep it.
Tested
Linux (CachyOS, GCC, Release, RTX 4090), commit built with tests:
tests/execution/NativeMultisampleDepth.cpp: a new case refills a depth page of a host-written 4 sample D32S8 surface with its old bytes and writes one word over its HTILE, then reads the page from the CPU. The read returns the guest's page, the surface is gone, the guest's HTILE word and depth page are whole, the host's stencil plane and the depth samples outside that page are published, and the next bind imports the target from guest memory. The three cases that used to expect the refusal (CPU read, DMA copy and writable shader buffer over a stencil page the CPU stored to) now expect the guest's page and an ended surface. The same-value cases are unchanged.ctest -R '^agc_driver_'on the GPU: "100% tests passed out of 1777" (24 of them skip by their own conditions).Requireput back,agc_driver_native_depth_publicationfails with "a native depth publication over a page the guest rewrote refused or kept its owner".8968347f3e(base) and this commit in one window, order base, head, base: frame p50 56.90 / 56.56 / 55.04 ms, so +0.59 ms against the mean of its two neighbours, under the 1.0 ms noise floor of that scene; GPU time per present 46.61 / 46.59 / 46.59 ms. A second head run was discarded for outside CPU load. The new path did not run in that scene (its[gpu]line never printed), which is the expected no-harm result.Not tested: PPSA25009 and PPSA02817 on this commit, and Windows.
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)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T17:50:37Z.
Review: COMMENTED
DepthSurface::PublishToGuestnow stores astd::size_tfor every undecided byte, including when a same-value rewrite ultimately leaves the surface active. That is up to eight bytes of temporary index storage per byte of guest data on a 64-bit host. A 3840×2160 four-sample D32 plane can therefore require roughly 1 GiB just for those offsets when most of the plane is undecided. Can the fallback track contiguous spans or use a compact mask so a large rewrite cannot make this publication path exhaust host memory?At
1b627c49e2, the scalar control and the native depth retirement, publication, and bare publication tests passed on both pinned main and the merge using Linux lavapipe. Each arm inserted validation layer 1.4.369 with shader caching disabled. Neither log showed a missing-layer message orVUID-errors. The temporary memory finding is from source inspection.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-03T17:53:55Z.
Review: COMMENTED
Actionable comments
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp, lines3673· 🚀 Performance & Scalability · ⚡ Quick winstd::size_tfor every byte whose guest value matches the baseline but differs from the host result. For a fully drawn 3840×2160 four-sample D32 plane, the offset payload alone can exceed 1 GB on a 64-bit target. This allocation also occurs for same-value-only stores, wheretookGuestremains false and the fallback never uses the offsets.ec534e9a-b735-40ed-839a-23763f5847c7Reviewing files that changed from the base of the PR and between
2bf6ec6143and1b627c49e2.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppdocs/dev/debt/changes/storage-import-touch-publication.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-03T18:28:26Z.
Review: COMMENTED
Reviewed — no blocking findings
The fallback preserves guest-owned bytes and retires the depth owner as intended; I found one memory-scaling concern.
What I ran
Reviewed head
1b627c49e2aede4ab93cf4a67d43d952306d3fe6againstmain; no merged-preview check was run. I inspected the prepared diff and targeted source ranges with the pinned reader. No tests or build commands were run.Results
Negative control
Not run; no source mutation or test execution was performed.
Findings
Blocking
None.
Non-blocking
undecidedvectors append onesize_tper ambiguous byte. A fully stored 4 KiB page can therefore add 32 KiB of offset data on a 64-bit build; across many pages this can cause substantial temporary memory use during publication. Compact spans or a bitset could reduce this overhead. DepthSurface.cpp, lines 3642 and 3673Sources
Not verified
DepthSurface.cppwas read at lines 3600–3810 and 4318–4360;NativeMultisampleDepth.cppat lines 1165–1200 and 1440–1500, plus the changed test hunks in the prepared diff; the changed debt documentation was reviewed in the diff. The remaining contents of the two C++ files were not read.files.jsonlists no excluded files. Tests, hardware behavior, and the author-reported CI and performance results were not independently verified.To get this to a good state
Nothing is required.