fix(agc): import a native multisample D32S8 target over uneven planes once its first draw wrote every sample #16363
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/16363"
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-06T12:04:15Z.
What
Assassin's Creed Mirage (PPSA13960) reuses the memory of its 4-sample D32S8 depth target (no HTILE) every frame:
prepareUniformPlaneSampling) finds planes that do not hold one value each and recordsnative multisample depth plane without HTILE does not hold one depth value in [0, 1]. The target is still drawn.DepthSurfaceTexture.The first draw of each frame on that target is a full-screen triangle. It has depth test ALWAYS with depth writes on, and on both faces stencil compare ALWAYS, pass op REPLACE, reference 0 and write mask 0xff.
DB_RENDER_CONTROLis 0x60 and the scissor is the target extent. On the console that draw overwrites every sample, so the guest bytes under the planes no longer matter. But the registers alone cannot show that the geometry covers every sample.This change proves it after the draw instead:
DepthSurfaceViewWithStencilWriteIntenttakes the stencil value that the draw writes to every sample it covers.Draw.cpppasses it only for depth ALWAYS with writes and no depth bounds, plus stencil ALWAYS/REPLACE with write mask 0xff and one reference on both faces. If such a draw creates an owner whose import was refused only because the planes are uneven, the owner starts with stencil~referencein every sample. The refusal stays recorded.CheckCurrent, or a guest access over its planes inRequireNoResidentDepthRead_nid_no_patch. The driver syncs the recorder and stores pending storage results over the planes. Then it reads the stencil samples back, with the readbackPublishToGuestuses (now a shared helper). If every sample holds the reference, every sample passed that draw's tests, so its depth was written too.~reference), another stencil value, guest writes, and storage results stored over the planes since the import.The debt entry for D32S8 without HTILE now says which uneven planes are imported.
Cost: one proof per created owner, which is a recorder sync plus a readback of the stencil plane (7 MB at 1772x996x4).
Tested
Linux 7.2.11, AMD Radeon RX 9070 XT, RADV (Mesa 26.2.6), Release with tests.
agc_driver_native_depth_overwritten_planes(--overwritten-planes), at 2, 4 and 8 samples, on a 200x130 D32S8 target without HTILE. Its planes hold mixed words (5.5e7 and NaN patterns among them) and mixed stencil bytes.RequireNoMultisampleTarget) comes first. It publishes the first draw's samples.DepthSurfaceViewWithStencilWriteIntent, so it cannot build on #15688 alone. A mutation of the fix stands in for the base instead. Each was made locally and reverted, and each fails the test at the expected case: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"):fa590e435a): 54 of 54;VUID-line or "was not found but was requested". Both have the same 20WARNING-VkImageSubresourceRange-layerCount-compatibilitylines.tools/check_conventions.py --base fa590e435a: passes.main5299939ecf+ #13963 (7d548223bd) + #15707 (a8c5df4e69, with #15690 and #15688), 720 s each:compute shader 0x10b4c8ad00: AGC graphics: native multisample depth plane without HTILE does not hold one depth value in [0, 1].AGC graphics: a native multisample depth attachment over the planes of a host-written owner of another identity is not implemented, a separate stop;7d377e40ba) in place of the fourth change, two runs, neither stops on the title message:compute shader 0x10009c9600: AGC graphics: a texture read of 0x13bc1a0000+0x800000 overlaps multisampled color target 0x13bada0000+0x1860000 (4 samples), whose samples are only on the host: guest access to it is not implemented, a separate multisampled colour stop;7d377e40ba) retired a published owner at the storage access that leaves results pending over its planes. Since9452ca6e35(headd4583e9ccd), #15941 retires an owner at aReuseaccess only when that access's publication took a guest byte. An owner that was already published has nothing to publish there, so #15941 keeps it, and the next bind reuses it:DepthReadCause::Reuse, now fails on #15941 without the fourth change:an overwriting draw over a published owner under storage results did not start a new owner.main6b58dfa474+ #13963 + #16364 + this PR + #16365 + #15941 (d4583e9ccd) + #16974: 5 of 5 runs stopped at 73-77 s, before the title screen, oncompute shader 0x1000810a00: AGC graphics: native multisample depth publication over pending storage image writes is not implemented. With the fourth change added, 6 of 6 runs got through the title and the menu into New Game. They stopped later (448-573 s) on other messages or the local VRAM guard.main6719b01bf3+ #13963 + this PR + #16364 + #16365): 3 of 3 runs stopped at 73-81 s on the same message. With #17890, 3 of 3 ran their full 300 s through New Game, Assassin and Full Synchronization Off into the opening scene.main5b1d381d5a: stops at 497 s and 456 s on the attachment message, the VRAM guard at 470 s, and the multisampled colour stop at 485 s. A rerun of that earlier build here stopped at 464 s on the colour stop.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 gabichuuuuu on 2026-11-07T17:40:03Z.
Review: COMMENTED
Windows check of head
92ff7c307f, merged ontomain4e44ed59b2(clean merge), withmainfrom the same build directory as the control.Setup: Windows 11 x64, WinLibs GCC 15.2.0 r7, Release, full build.
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 ctest -R '^agc_driver_native_depth_', 3 runs per GPU on each side.mainstencil_view,uniform_planesandpublicationpublication_without_htile, 3 of 3agc_driver_native_depth_overwritten_planespasses in every run on both GPUs.publication_without_htileis not from this change: it comes with the #15688 commits this branch merges. On the Intel iGPU it fails witha written D32S8 owner without HTILE did not publish its stencil samples and padding, the same D32S8 stencil pattern as the three tests that already fail onmainthere, and it passes on the NVIDIA GPU. I'm looking into that Intel failure separately; it doesn't block this PR.VK_LAYER_KHRONOS_validation.AI-assisted: yes.