fix(agc): retire a published native depth owner when a depth target of another identity binds its planes #17915
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17915"
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 hugodearaujo on 2026-11-09T22:25:33Z.
What
Assassin's Creed Mirage (PPSA13960) binds depth targets of another identity at the memory of a 4-sample D32S8 owner without HTILE that it drew and that was then published and kept. In our runs it does this at least four ways at the end of the prologue cinematic:
0x10dfd20000) with another stencil address (0x10e1580000), over a 960x540 x4 owner (stencil0x10e0590000), whose stencil plane lies inside the new depth plane;Each one stops on:
Why it stops. A new attachment reads its three planes with
RequireNoResidentDepthRead_nid_no_patch(..., DepthReadCause::Reuse)(#15941): a host-written owner there is published, and since9452ca6e35it's retired only when its publication took a guest byte. An owner that took none, or that an earlier read already published, is kept with its guards active. The loop right after the three reads then refuses on any active guard of an owner the host ever wrote. #15941's debt entry says so: "a new depth target over a kept one throws".That loop can only see kept owners. Every guard the reads leave over the planes is no longer host-written: a host-written one is published by the read, and one still host-written after it throws inside it. The reads and the loop test the same half-open ranges with the same three plane sizes, and the creation holds the GPU mutex throughout, which every
NoteDepthSurfaceWritealso holds. So the loop fires exactly when a published, kept owner overlaps the new planes.The case isn't specific to the title: on #15941's own fixture, a host-written owner with nothing undecided stops there when a target of another identity binds (
DecidedNewDepthTargetbelow). #15941's case (3) passes only because it has an undecided byte.The change.
DepthReadCause::Attachment, for the three plane reads of a new depth attachment.Reuse, its publication takes the guest's undecided bytes (#15941's rule for "a new depth target reusing the memory").Reuse, it retires every owner over the planes once they're published, kept or not:RequireNoResidentDepthRead_nid_no_patch's existing loop marks them inactive and removes their guards, andreleaseRetiredfrees them at the same creation (#15300).ReuseandAccessare unchanged, so draw inputs, storage images and the other reuses still keep an owner whose publication took no guest byte (#15941's case 9).Why retiring is right here. A reuse that only reads the memory can leave the owner valid, which is why #15941 keeps it. A new attachment is a new owner of the same bytes. Two active owners can't both hold them: a later bind of the old identity would find it active, with samples from before the new target's draws. On the console both targets are the same memory, and the new one reads what is there.
retire()would add for a multisample owner is only the owner-map erasure. Every lookup already checksactive, and multisample owners have no stale planes. #15941's091068b618relies on the same, so this follows its pattern rather than #15707'sretire+storeStaleStencil.DepthSurfaceHoldsno longer serves it, andreleaseRetiredfrees the owner afterwards.What still refuses. Everything that refuses before the retirement still does: an owner the publication can't handle (D16/D32-only, an unapplied clear, pending storage writes over a plane, a resident colour alias), publication inside a GPU completion, and publication while a multisampled colour target is being acquired. The owner then stays resident.
Tested
Linux 7.2.14, AMD Radeon RX 9070 XT, RADV (Mesa 26.2.6), Release with tests; and lavapipe (LLVM 23.1.4) for the new tests.
New cases.
agc_driver_native_depth_other_identity(--other-identity), at 2, 4 and 8 samples, D32S8 without HTILE, Z_X:The title's geometry, scaled by 1/8. An owner of 120x68 and a target of 208x117 share the depth address, with another stencil address; the old stencil plane lies inside the new depth plane.
The steps. The owner is imported over uniform planes and drawn (per-sample depth and stencil). The target binds with a first draw that writes every sample (#16363's proof), and a guest access then publishes it. Every byte of both planes, padding included, is compared with a model of what each step wrote.
The modes:
Reusevertex read that took no guest byte, which keeps it, as before;DepthSurfaceHoldsno longer serves the view, and the view still samples the owner's samples. Then A→B→A, and both owners are freed;native multisample depth publication over pending storage image writes is not implemented, and the owner stays resident.Modes 0-4 also check that the new target imports (one new surface, a new view) and that the old owner is retired and freed, unless its view is held.
DecidedNewDepthTargetinagc_driver_native_depth_publication(#15941's fixture, with HTILE): a host-written owner with nothing undecided, then a 128x64 target of another identity. It publishes the host's bytes, the target imports, and the owner is retired.Red on the base without the change. The base is
main+ #15941 + #16363 with the tests only. Each mode was run on its own:DecidedNewDepthTargetfail with the message above: on RADV, 15 of 15 cases plusDecidedNewDepthTarget; on lavapipe, 10 of 10 plusDecidedNewDepthTarget(4 and 8 samples);Green with it. On RADV, 18 of 18 plus
DecidedNewDepthTarget; on lavapipe, 12 of 12 plusDecidedNewDepthTarget.Mutations (lavapipe):
Attachmentretiring only on a guest byte:other_identityfails withthe owner of another identity was not retired and released, andpublicationfails atDecidedNewDepthTarget.Attachmentrefusing undecided bytes:publicationfails at #15941's case (3) withcannot distinguish an unwritten byte from a same-value guest store.Validation layer, paired, same machine (
VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1,ANYPS5_REQUIRE_VULKAN=1,ctest -V -R "native_depth|native_multisample|depth_storage|depth_surface|agc_storage_|multisample_guest|repeat_storage_guard|cached_image|storage_flush_ordering|storage_one_slice|storage_read_during|storage_write_back|msaa_address_on_plane"):agc_storage_pending_key_refresh,agc_storage_clear_hand_over). The new test is the 65th.VUID-line or "was not found but was requested".Conventions.
tools/check_conventions.py --base 6719b01bf3passes on both (exit 0).Runs by others.
2b61bc285emerged ontomainbc1c4123e8, a clean merge. Windows 11 Enterprise 22621, AMD Radeon RX 6700 XT (driver 32.0.21045.16010), WinLibs GCC 15.2 UCRT, Release.agc_driver_native_multisample_depth,agc_driver_native_depth_other_identityandagc_driver_native_depth_overwritten_planespass 3 of 3 each, none skipped.agc_driver_native_depth_publication, which holds the newDecidedNewDepthTargetcase, wasn't in this run.ctest -V -Rpattern above, 3 runs on each side.maine7c3bfd130: 63 tests, all pass 3 of 3.2b61bc285e: 65 tests, all pass 3 of 3. That includesagc_storage_pending_key_refreshandagc_storage_clear_hand_over, which skip on the RX 9070 XT, andagc_storage_write_back_scratch.agc_driver_native_depth_other_identityruns all six modes at 2, 4 and 8 samples, andagc_driver_native_depth_publicationpasses withDecidedNewDepthTarget.VUID-line, and the layer was found.e59a3c31df(the tests without the change):agc_driver_native_depth_other_identityandagc_driver_native_depth_publicationfail 3 of 3 with the message above.0f80c9148b, after the merges of #15941 andmain(comment), 3 runs on each side:main3339e01f59has 74 tests and this PR 75, all pass 3 of 3, withagc_storage_pending_key_refreshandagc_storage_clear_hand_overpassing on both sides. NoVUID-line. Negative control onmain3339e01f59merged with #15941's7ce55ad00e, with this PR's tests:agc_driver_native_depth_other_identityandagc_driver_native_depth_publicationfail 3 of 3 with the message above, andagc_driver_native_depth_publication_without_htilepasses.On current
main. #15941 is merged, so the diff againstmainis now this change alone. The head,b0beb53d75, mergesmain6db6a3e927into it. The one conflict was the debt entry for D32S8 guest publication, wheremainand this change each rewrote one sentence; the merge keeps both. It builds, and the validation command withnative_color_initialadded andagc_storage_write_back_scratchleft out gives 84 tests: 82 pass and the same 2 skip, withagc_driver_native_depth_other_identityandagc_driver_native_depth_publicationamong the passes. Onmain6db6a3e927the same command gives 83 tests: 81 pass and the same 2 skip. Neither log has aVUID-line or "was not found but was requested".check_conventionspasses, with thedebt-lengthwarning that entry already has onmain.The title. Assassin's Creed Mirage (PPSA13960): title, New Game, Assassin, Full Synchronization Off, 720 s per run, interleaved. Tree:
main6719b01bf3+ #13963 + #16364 + #16363 + #16365 + #15941, plus an earlier, source-only version of #17890's change as a local commit (a36837b782; without it this tree stops at 73-77 s on the pending-storage publication refusal), with logging that prints where this change retires an owner.initial multisample color contents overlap resident native depth. The base's third run stopped on the storage one too.Reusepublication and retirement of the depth owners under it;Overlap
DepthReadCauseand the retirement loop this change reuses; this change is one more cause in it.overwrittenStencilargument and its import over uneven planes. So this change depends on both. It doesn't depend on #13963, #16364, #16365 or #17890.requireNativePlanesFree. With this change the loop is gone, and the three reads in their new place takeDepthReadCause::Attachment. That's the order #15941's author proposed there forReuse(comment).DepthSurface.cppmerges clean; the test file, its cmake file and the debt entry conflict only at insertion points, and keeping both sides resolves them.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)DepthReadCauseand its retirement loop, and #16363 are merged)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T03:38:11Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
0f80c9148b35f777de9ce9d3a4ffd86c084ae79e(basemain).files.jsonunderreviewed.Results
MultisampleTarget.hppFindings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:1104:PublishToGuestnow returns whether it took a guest byte, but the name still reads as a plain action. Since the repository allows no comments in code, a name that says what the result means (for examplePublishedTookGuest) would keep the contract visible at the call site inpublishWrittenDepth.core/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hpp:6: the header now includesDepthSurface.hpponly for theDepthReadCauseenum. Every file that includesMultisampleTarget.hppnow also pulls in the depth surface header. Moving the enum to a small shared header would avoid that.Sources
github.com/boykopovar/AnyPS5@0f80c9148b/core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp (L1104)Not verified
ShaderResources.cppis too large for the review folder; only its two changed call sites and its caller search were checked.releaseRetiredwaits for recorded GPU work when aReuseread (vertex, index, storage image) retires an owner during recording. Not traced.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T20:55:08Z.
Review: COMMENTED
Reviewed — comments
The targeted source and diff review found no verified blocking defect, but the full changed test file was not read, so a formal approval is not justified.
What I ran
Reviewed head
b0beb53d75d3da14433525b91054c9cf246cc3d5using the prepared diff andrepo_read.py. No tests were run.Results
Findings
Blocking
None verified in the portions read.
Non-blocking
None.
Not verified
The full text of
NativeMultisampleDepth.cppwas not read; only the changed test hunks indiff.patchwere inspected. Test claims and platform results in the description were not independently verified. Other changed files were read only around the changed lines. Read:description.md,commits.md,manifest.json,diff.patch,DepthSurface.hpp, targeted ranges ofDepthSurface.cpp, and the debt entry inlibSceAgcDriver.md. Excluded: full-file contents ofNativeMultisampleDepth.cpp, the full changed CMake file, and unmodified repository context beyond targeted searches/ranges. The changed-file manifest lists five files; all five are represented in the diff, but complete file reads were not performed.To get this to a good state
Nothing is required. The review comments are informational: complete review of the changed test code before making a formal merge decision.