fix(agc): take a depth plane a shader wrote through its own view from that image, not from stale guest bytes #23739
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/23739"
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 yinx080 on 2026-11-19T15:08:39Z.
What
The Exit 8 (PPSA23276, UE5 with Nanite) renders most walls and floors black on
main: the G-buffer stays empty there, so lighting has nothing to shade.The draws that fail are UE5's classic Nanite material pass:
materialId / 16383.The material depth is written by Nanite's emit pass, a compute shader, through the title's own R32F storage view of the depth memory. That memory is Z64KBX, the same surface as the depth surface's mirror.
Right after the emit, that view holds the correct material ids on every wall and floor pixel. Then this happens:
layerGenerationis still the one from its first upload, every unit has been stamped since, so every unit counts as written by someone else and the results are dropped without a store.StorageTexturewith the same surface.This change takes each changed unit from the image that wrote it last, and only while it is the last writer:
StorageTexture::stampStoredreplaces the threeMarkWrittenloops ofwriteBack), andmarkLayersPendingrecords the tracker generation of each unit's latest results (layerResultsSince).StorageTexture::DepthPlaneWriterslooks at the live images with exactly the mirror's surface at the same address. A changed unit goes to the image whose latest results or own write-back is newer than every stamp on the unit's block; when several qualify, the newest wins.DepthSurface::SyncFromMemorycopies those units on the device from their images, and every other changed unit from the mirror, as before. A CPU store, a DMA copy or another image's write-back made after the shader write stamps the block newer, so the guest bytes win there.APS5_NO_DEPTH_FROM_ALIASrestores the old path; its row indocs/dev/ENVIRONMENT.mddescribes the rule.agc_driver_depth_plane_alias_*(IvanFogel's fixture from the review): a shader write through an R32F view, then a CPU store or a PM4DMA_DATAcopy into one unit, with no draw first, a draw in between (_split) or a bind before the write (_prebind). They skip when the plane is not write-watched or its block generations are unavailable.Both references are needed. The emit view in The Exit 8 never stores (step 1), so only its results time shows it wrote last; with the write-back stamp alone the corridor stays 54-100 % black. The write-back stamp covers an image whose results did reach memory, since its own stamp is newer than its results.
Overlap with #15621. #15621 changes
SyncFromMemoryandTexture.hpptoo, so one of the two will need a rebase after the other. It doesn't fix this case on its own:main+ #15621 rendered 31-100 % of the corridor near-black.Root cause. The empty write-back in step 1 is why guest memory never receives the results. This change works around it for depth planes; if the write-back's generation check is the place to fix it, I can look at that in a separate PR.
Tested
Windows 11 Pro (26200), Ryzen 7 5800H, RTX 3060 Laptop (NVIDIA 610.91), WinLibs GCC 15.2.0 r7, Release,
main07336cc200+ this branch (5d622cc26c).The Exit 8, 1080p, opening corridor. A 200 s scripted walk with a window shot every 30 s; the share of near-black pixels (max channel < 12) in the lower part of the screen, where the walls and floor are:
APS5_NO_DEPTH_FROM_ALIAS=1The 180 s shot of the last run failed to capture; the run went the full 200 s. Walls, floor, tiles, posters and the guide line render with correct occlusion, and the frame rate matches the path-off run: about 58-74 presents per 10 s after warm-up in both, with an occasional dip in each.
The new cases, 10 runs each:
_split(control, CPU, DMA)control_prebindcpu_prebinddma_prebindOn Windows the write watch stops covering the plane after the storage write-back in every run without a draw first and in about half the
_prebindruns, with or without this PR; those runs skip. Before the rework,cpu_split,dma_split,cpu_prebindanddma_prebindfailed on the draw assertion and passed withAPS5_NO_DEPTH_FROM_ALIAS=1, matching IvanFogel's Linux run.Unit tests.
ctest -R "^agc_driver_depth": 54 of 54 pass (45 existing + 9 new), and the same withAPS5_NO_DEPTH_FROM_ALIAS=1.Stray (PPSA02100), regression check, on the previous head
dbb10a3638: 5.68 fps withAPS5_NO_DEPTH_FROM_ALIAS=1, 5.69 fps with it on. Not rerun on this head.tools/check_conventions.py --base origin/mainandtools/check_test_registration.py buildpass.Not run: Linux, the validation layer.
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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T05:07:58Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change based on the source inspected; the reported runtime and test results were not independently run.
What I ran
Reviewed head
dbb10a363881dc91d6b4aaa2326233881534fdf7. No commands or tests were run. Readdescription.md,commits.md,manifest.json,diff.patch, and the complete changed filesTexture.hpp,DepthSurface.cpp, anddocs/dev/ENVIRONMENT.md; read the changed function and surrounding context inTexture.cppthrough the pinned reader. No changed files were excluded by the prepared manifest.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The full text of
Texture.cppwas not read because it was excluded from the review folder for size; only the changed implementation and relevant context were read throughrepo_read.py. Tests, build, and reported console behavior were not independently verified. No code-level test coverage for this changed behavior was confirmed.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by IvanFogel on 2026-11-20T08:44:58Z.
Review: CHANGES_REQUESTED
I reproduced the later-writer regression discussed above. With an R32F storage write followed by an ordinary CPU store or a PM4
DMA_DATAcopy into one depth tile, guest memory contains the new value but the next depth draw uses the older image. This happens when the depth surface was already bound. The cold first-bind cases pass.e825fa1492dbb10a3638merged into that mainAPS5_NO_DEPTH_FROM_ALIAS=1In each failing case, 16,399 pixels should pass the depth test. The PR draws 15, losing exactly the 16,384 pixels in the overwritten tile. CPU and DMA stores both advance the tile’s guest generation. Only the CPU store sets the CPU-write flag. A CPU-only gate would still accept stale texels after the DMA copy. I traced all four failures to the new alias-copy branch. Each time it copied one rectangle for tile 2 from alias version 2.
Four existing depth tests passed on both trees. All runs required real Vulkan with the shader cache disabled, logged the Khronos validation layer, and produced no VUID or synchronization diagnostics. Tested on CachyOS Linux, NVIDIA GeForce RTX 3070 Ti, driver 620.70.06. This was a synthetic draw and did not run The Exit 8.
Regression fixture and run instructions
The patch below applies to main
e825fa1492and its merge with this PR. After applying it, configure the usual test build, buildagc_driver_depth_plane_partial_store_tests, and run:AI-assisted review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T22:49:08Z.
Review: COMMENTED
Reviewed — comments
The alias refresh path and its test changes were reviewed at head
5d622cc26c81a33c184e70d1a905b807c688f9c5;Texture.cppwas excluded from the review bundle, so the complete changed implementation was not verified.What I ran
No build or tests were run. I used
repo_read.pyto inspect the prepared description, commits, manifest, diff, changed-file ranges, and tracker declarations/behavior at the pinned head.Results
Texture.cppfull text was excludedFindings
Blocking
None verified in the inspected code.
Non-blocking
None.
Not verified
The full text of
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppwas excluded as too large; only its changed regions were read. The manifest lists six changed files, and all six were reviewed; this excluded file was only partially read. No build, tests, Linux run, validation-layer run, or physical-console behavior was verified. The author-reported Windows test results were not run by this review.To get this to a good state
Nothing is required. The implementation in the excluded portion of
Texture.cppremains unverified, so this review does not make a formal approval decision.Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T21:57:02Z.
Review: COMMENTED
The current head checks store ownership per depth-plane unit before taking it from the alias image. The CPU and DMA prebind cases verify that a later writer stays visible even when the image still contains an earlier row. Please keep the guest-byte and final depth-test assertions together in the paired run. The ordinary depth-plane tests and new alias cases are queued on lavapipe.
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.