fix(agc): publish and retire native depth owners under an initial multisampled colour import #17956
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17956"
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-10T00:56:10Z.
What
Assassin's Creed Mirage (PPSA13960) binds new 4-sample colour targets over the memory of 4-sample D32S8 depth owners without HTILE that it drew and that were then published and kept. With #17915, the next stop at the end of the prologue cinematic is:
Why it stops. Before a multisampled colour target's first draw,
PrepareMultisampleTargetForDraw_nid_no_patchimports its initial contents from guest memory (#15986, #16086). Its preflightrequireUnownedrefuses when any active native depth guard overlaps the colour footprint. It doesn't publish or retire anything (#15986's non-mutating preflight). So a kept owner, published with no guest byte taken and kept by #15941, stops the import even though its samples are already in guest memory. A host-written owner stops it too.In our runs the colour footprint covered the owner's depth plane (a 1720x968 x4 B10G11R11 target over a 1720x968 x4 owner) or part of its stencil plane (a 960x540 x4 R16F target over a 960x540 x4 owner's stencil plane).
The change (
MultisampleTarget.cpp, the start of the import):initial multisample color contents overlap another native owner) runs first, on its own. If another colour target owns the bytes, the import still refuses there, before any depth owner is touched.initial multisample color contents are not fully mapped), moved up from after the publication. A footprint that runs into unmapped memory refuses before any depth owner is published or retired.RequireNoResidentDepthRead_nid_no_patch(target.address, bytes, std::nullopt, true, DepthReadCause::Attachment)runs over the colour footprint. That publishes every host-written depth owner under the footprint and, since the cause isAttachment(#17915), retires every owner over it once it's published, kept or not. One call covers all of an owner's planes: each plane, HTILE included, has its own guard with the owner's shared state, and the footprint is tested against all of them.requireUnownedthen runs as before, at the same three points.Why here, and why it's legal. The publication refuses while a multisampled colour target is being acquired (
HoldsMultisampleTargetsLock()). At this point the targets lock isn't held: the import takes it only in a scoped block before, and again after the capture. The draw path (Draw.cpp) calls the import without it too. The publication takes the GPU mutex, which is recursive and already held by the draw, and the surface and depth guard locks, in the same order as the depth attachment's reads. No colour guard lock is held across it.Why
Attachmentand notReuse.Reuseretires only an owner whose publication took a guest byte, so a kept owner, the title's case, would stay active and the import would still stop. A colour target is a new owner of the same bytes, which is whatAttachmentmeans in #17915; two active owners of the same bytes can't coexist. For undecided bytes, both causes take the guest's byte, which #15941's debt entry already lists for "colour target" reuse.What the import then reads. Its capture runs after the publication, through the read guard and
FlushGpuWrites. So it holds the published samples, or the bytes a kept owner already published, or the results of storage writes still pending over a kept owner's plane. On the console the colour target reads whatever bytes are there; that this matches is inferred, not measured on a PS5.What still refuses. Everything that refuses inside the publication, before the retirement: a written owner the publication can't handle (D16/D32-only, an unapplied clear, a sampling refusal), pending storage writes over a written owner's plane, and a resident colour alias over a plane. The owner then stays resident and no colour target is created. Publication inside a GPU completion, or with the targets lock held, can't be reached from this point.
Other effects.
hostEverWritten=0) was already retired by any guest read (#15941). Now the colour import retires it too, instead of refusing.DepthSurfaceHoldsstops serving it, and the owner is released at the next depth creation once the view is dropped.... overlap another native ownerinstead of... overlap resident native depth.Two existing expectations change accordingly:
--aliased-depthNewTargetAfterImport(#15964/#15986) now expects that message. It still requires the depth owner to stay resident.--initial-uniform_refusals(#15986) used a never-written D32 owner, which the import now retires. The case now marks the owner written, so the publication can't handle it, and expects that refusal with the owner resident and its view unchanged. It stays a non-mutating refusal.The debt entries for the initial colour contents and for D32S8 guest publication say this.
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 and changed tests.
New test,
agc_driver_native_depth_colour_import(--colour-over-owner), at 2, 4 and 8 samples:The fixture. A D32S8 owner without HTILE (120x68) is imported over uniform planes and drawn (per-sample depth, stencil 0x40 + sample). Then an R32F colour target (R8 over the stencil plane) of the same extent, samples and XOR is prepared for its first draw.
What each passing mode checks:
The modes:
DepthSurfaceHoldsrefuses it, and the view still holds the owner's samples;native multisample depth publication over pending storage image writes is not implemented;initial multisample color contents overlap another native owner, and the depth owner is untouched;sample-preserving guest publication of native multisample depth is not implemented for this owner;initial multisample color contents are not fully mapped.In 6-9 the owner stays resident, guest memory is unchanged and no colour target is created.
The harness. This mode creates the test's device the way
main's sample-import modes do, withshaderStorageImageMultisampleandshaderStorageImageWriteWithoutFormat, which the non-uniform upload needs (#16086). The mode skips without them, as in #17152.Red on the base without the change (#17915's head + the tests only), each mode on its own (a local harness, not in this PR), on lavapipe, where every mode fails at its first sample count (4):
AGC graphics: initial multisample color contents overlap resident native depth. Modes 6-8 fail because the base refuses with that message instead of the one the mode expects, for examplemultisample target refusal did not match initial multisample color contents overlap another native owner: AGC graphics: initial multisample color contents overlap resident native depth;--aliased-depth depth-only|stencil|no-stencilon the same mismatch, and--initial-uniform_refusalswithinitial color capture did not refuse a resident depth owner it cannot publish;Green with it. Lavapipe: the new test (18 cases), the four
--aliased-depth/--aliased-stenciltests and the sevennative_color_initialtests pass, 12 of 12. RADV: below.Mutations (lavapipe):
Reuseinstead ofAttachment: modes 0, 1, 2, 4 and 5 fail withAGC graphics: initial multisample color contents overlap resident native depth. Mode 3 passes through the existing never-written rule, and 6-8 pass.a colour import refused over another colour owner retired the depth owner.a colour import refused over an unmapped tail retired the kept depth owner or imported; modes 0-8 pass.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_color_initial|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 73rd and ran 27 cases (9 modes at 2, 4 and 8 samples).VUID-line or "was not found but was requested".Conventions.
tools/check_conventions.py --base e7c3bfd130passes on both (exit 0).Runs by others.
c2f6018794merged ontomain5c26d4f13c, 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_sample_multisample_target,agc_driver_native_depth_other_identity,agc_driver_native_depth_overwritten_planesandagc_driver_native_depth_colour_importpass 3 of 3 each, none skipped.ctest -V -Rpattern above, 3 runs on each side.maindf5829dca2(the merge base): 70 tests, all pass 3 of 3.c2f6018794: 73 tests, all pass 3 of 3. That includesagc_driver_native_depth_colour_import(all nine modes at 2, 4 and 8 samples, 27 cases), the fouraliasedtests and the sevennative_color_initialtests.VUID-line, and the layer was found.NativeMultisampleDepth.cpp,SampleMultisampleTarget.cppand test CMake file on2b61bc285e(#17915's head, without the change), 2 runs. The same five tests fail with the same messages as above:agc_driver_native_depth_colour_import, the three--aliased-depthtests andagc_driver_native_color_initial_uniform_refusals.agc_driver_native_depth_aliased_stenciland the other sixnative_color_initialtests pass there.839a783bf7, after the merges of #15941 andmain(comment), 3 runs on each side:main3339e01f59has 74 tests and this PR 76 (with #17915'sagc_driver_native_depth_other_identity), all pass 3 of 3. NoVUID-line. Negative control on #17915's head0f80c9148bwith this PR's test files: the same five tests fail 3 of 3 with the same messages, andaliased_stenciland the other sixnative_color_initialtests pass.839a783bf7, Linux, AMD Radeon RX 9070 XT (RADV, Mesa 26.2.5), GCC 16.2.1, Release, validation layer 1.4.363,ctest -R agc_driver. 1121 of 1122 pass; the one failure,agc_driver_tessellation(a segfault), is one they report on unmodifiedmaintoo. NoVUID-line, andcheck_conventionspasses.b5e79ef455against its merge basemain6db6a3e927, 3 runs each,ctest -R '(native_color_initial|native_depth|native_multisample|depth_storage|depth_surface|^agc_storage_|sample_multisample_target)'.agc_driver_native_depth_colour_importandagc_driver_native_depth_other_identitypass 3 of 3, and the other 73 matching tests pass 219 of 219 on both sides. Every run selects the RTX 3070, the layer is inserted in every Vulkan test's log, and no log has aVUID-line.main1bdf1d5e46with this PR at839a783bf7merged locally.mainstops after about 90 s, at the first scene change after the intro, onnative multisample depth publication cannot distinguish an unwritten byte from a same-value guest store, andmain+ #15941 alone stops at the same place (89 s). With this PR the title ran through at least four more scene changes, 179 s and 5,233 frames, to a clean exit.b5e79ef455merged ontomain11f95ea8f6(with #17915), Windows 11 Home, WinLibs GCC 16.2.0, Release, validation layer, RTX 5070 Ti (621.01) and a Ryzen 7 7700X's integrated Radeon (Adrenalin 26.10.2).^(agc_driver_native_depth.*|agc_driver_native_multisample.*|agc_driver_sample_multisample_target.*|agc_shader_memory.*)$:main35 of 35, this PR 36 of 36 in 3 of 3 runs on both GPUs; the only skip isagc_driver_native_depth_driver_queued_fillon both sides; noVUID-line. Without theAttachmentread beforerequireUnowned,agc_driver_native_depth_colour_importfails on the Radeon with the title's stop.On current
main. #17915 is merged, so the diff againstmainis now this change alone:MultisampleTarget.cpp,NativeMultisampleDepth.cpp,SampleMultisampleTarget.cpp, the test CMake file and the debt doc.DepthSurface.hppandDepthSurface.cppcome frommainunchanged. The head,c3ac3b0f62, mergesmainbfcd717ebcintob5e79ef455. The code and test lines are the same as inb5e79ef455's own diff over #17915. Git merged the debt doc without a conflict but kept two copies of the D32S8 publication entry,main's (#21719) and this change's. The merge keeps one, whose sentence now reads "Only a reuse taking a guest byte, a new depth or multisampled colour target or a guest write retires the owner." It builds, and the validation command withagc_storage_write_back_scratchleft out gives 89 tests: 87 pass and the same 2 skip. Onmainbfcd717ebcthe same command gives 88 tests: 86 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, 5 runs per side.
The tree.
maine7c3bfd130+ #15941 + #16363 + #17915's commit + #13963 + #16364 + #16365 + #17890, with logging that prints where this change retires an owner.A local experiment on both sides. It's identical on both sides and isn't part of any PR. A guest access over a host-only multisampled colour target retires the target instead of refusing. Without it, those refusals (#13963/#13248's territory) stop the title before this point, as in #17915's runs.
Base: 4 of 5 runs stop on the message.
The fifth run took a slow loading path and didn't reach the point.
With this change: 5 of 5 run to the 720 s close with no exception. The change retired a kept owner (
hostWritten=0,hostEverWritten=1) 5 times, in 3 runs. That includes the same 1720x968 x4 depth-plane case (twice) and the stencil-plane case (twice). The other two runs took the slow loading path.Limit. Around this point the title nearly stops presenting, about 0.05 frames per second, and its frames turn to garbage, then black.
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)initial multisample color contents overlap resident native depthat the end of the prologue cinematic (with a local experiment for the other colour refusals; the picture after it is not yet right); PPSA03706, by vojenfr, past its first scene change after the intro (#15941 alone stops there)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T03:30:02Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
839a783bf7, base main.PublishToGuestandpublishWrittenDepthin DepthSurface.cpp, the depth attachment path in DepthSurface.cpp, andPrepareMultisampleTargetForDrawin MultisampleTarget.cpp.Results
Findings
Blocking
None.
Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp:1497: the import runs the depth publication and retirement before the accessibility check at line 1499 and the capture compare at line 1503. A colour footprint that overlaps a kept depth owner and runs into unmapped memory therefore publishes the owner, retires it, and then refuses with "initial multisample color contents are not fully mapped". The bytes published are the owner's samples, so guest memory stays correct. But the refusal is not non-mutating as the description implies for refusals, and no test covers an unmapped tail over a kept owner. Failure scenario: a colour target over a kept owner whose last rows fall outside mapped memory. The owner is retired and the draw throws.Sources
github.com/boykopovar/AnyPS5@839a783bf7/core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp (L1496-L1503)Not verified
tools/check_conventions.pywas not run. The description reports a warning about a debt entry's length.To get this to a good state
Nothing is required.
Optional: move the accessibility check above the depth publication call at
MultisampleTarget.cpp:1497, and add a case for an unmapped tail over a kept owner.Recordatorio: tu suscripción a Claude es gracias a MimOS (mimoslinux.org).
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-19T20:49:10Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this; the points below are optional.
What I ran
Reviewed head
b5e79ef455f9f624df7bc385bac268a4c27354a5using the pinnedrepo_read.pyreader. I did not run build or test commands; this review environment provides read-only access.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I did not independently reproduce the reported tests, mutation checks, or console behavior. All seven changed files listed in the manifest were included and read; no changed files were listed as excluded. The review-folder listing did not provide
files.json.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Superseabas on 2026-11-22T18:39:19Z.
Review: APPROVED
Windows check of head
b5e79ef455with GCC 16 on an NVIDIA and an AMD GPU, merged ontomain11f95ea8f6, which now includes #17915 (clean merge). The Windows runs listed so far are an RX 6700 XT on an older head; this adds NVIDIA on Windows and the current head.Setup: Windows 11 Home 10.0.26200, WinLibs GCC 16.2.0 (
x86_64-ucrt-posix-seh, r3), Release full build, run from PowerShell withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. GPUs, each picked withANYPS5_GPU: NVIDIA GeForce RTX 5070 Ti (621.01) and the Ryzen 7 7700X's integrated AMD Radeon (1002:164e, Adrenalin 26.10.2). This was built together with #21763, which touches other files.^(agc_driver_native_depth.*|agc_driver_native_multisample.*|agc_driver_sample_multisample_target.*|agc_shader_memory.*)$:main35 of 35, and with this PR 36 of 36 in 3 of 3 runs, on both GPUs. The new one isagc_driver_native_depth_colour_import. The only skip, on both sides, isagc_driver_native_depth_driver_queued_fill, which skips on Windows by design. NoVUID-lines.RequireNoResidentDepthRead_nid_no_patch(…, DepthReadCause::Attachment)call beforerequireUnowned,agc_driver_native_depth_colour_importfails on the Radeon with the title's stop,AGC graphics: initial multisample color contents overlap resident native depth.The reordering reads right to me. Another colour owner still refuses first, and an unmapped footprint now refuses before any depth owner is published or retired. The publication runs where the targets lock isn't held.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T03:15:56Z.
Review: APPROVED
Reviewed exact head
b5e79ef455f9f624df7bc385bac268a4c27354a5. The production change distinguishes attachment-driven depth publication from ordinary access/reuse, publishes and retires overlapping native depth before initial multisample colour capture, and checks the colour footprint is fully guest-mapped before publication. The added regressions cover another identity and colour-over-owner ordering. Exact-head Windows validation from Superseabas passed the focused depth selection on NVIDIA and AMD with validation enabled; MarcZX10 found no blocking source issue. I have not rerun the requested PPSA09806 title on this exact head, so that title-specific confirmation remains unverified rather than a blocker. AI-assisted: yesImported from boykopovar/AnyPS5. Originally posted by malekaifa on 2026-11-23T22:22:44Z.
Review: APPROVED
Re-reviewed exact head
c3ac3b0f62842c19e3fcb6c8bb141b1d993a2869after the current-main merge.git range-diffshows the two still-relevant branch commits (67cb2b1877a0,b5e79ef455f9) unchanged; the removed old commit is now upstream via #17915. The PR delta correspondingly shrank from seven files to five. The merge-resolved debt entry preserves the reviewed publication/retirement wording without the duplicate main entry, andgit diff --checkis clean. Hosted Windows/conventions/eligibility/report/portability/PR/labels checks are green, and the author reports the focused RX 9070 XT depth set at 89 tests with only the same two skips as main and 0 VUIDs. No new blocker found. AI-assisted: yes