feat(agc): sample native multisampled depth attachments #5496
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5496"
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 Amoenus on 2026-10-13T21:08:35Z.
What
Support numeric sampling of resident D16/D32 depth attachments with 2, 4 or 8 samples, one Z_X slice/mip, and a proven initial zero/one HTILE clear. Preserve ITERATE_256, attachment identity and image lifetime, and barrier depth writes before shader reads. Sampling an attached native depth image is refused before pipeline creation.
The existing stencil byte-format filter runs before multisample routing, so a color texture at a stencil-plane address is not claimed as a depth reader. Stencil import, comparison/raw-bit/storage/array sampling, unproven guest/external GPU changes and unsupported metadata/publication transitions remain explicit refusals. Retirement and completion-proven clears are separate follow-ups (#5524/#5554).
The conditional Sonic Unleashed Recompiled PPSA99902 need and pinned title controls are documented in #3262 and bring-up #4443. This focused PR builds independently; its current head has not been replayed on the title. The retained bring-up integration contains additional work and its progress is reported separately.
Sources: PAL ITERATE_256 bit10, descriptor construction, Addrlib dimensions. HTILE restrictions follow the Mesa sources recorded in #3262 and library debt. PS5 equivalence has not been measured on a console.
Tested
Head 008f91501, base main3c87cdfda, Windows 11 Enterprise 26200, WinLibs GCC15.2.0, Release, bundled dependencies, SPIRV-Tools enabled:
0xfffc0000/0xfffffff0with clear0.depth_surface_reuseandguest_texture_resourcecases execute throughagc_driver_graphics; they are not separate CTest registrations.The earlier stencil-ordering control and title/source history remain in #3262. Current evidence covers Windows fixtures; Linux, a full CTest suite and an isolated title replay were not run for this head. No performance claim.
Checklist
main(tested3c87; clean merge intoab9 checked); no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-13T22:30:35Z.
Checked the newly surfaced overlaps at main
bf8dc610e. #5445 imports uniform guest color memory; #5499 performs a DB depth-to-color copy. Neither duplicates descriptor-based native-depth sampling here or the release retirement in #5524.@codingreapermaps: #5499 and this PR share sampled-depth image/capability setup. I propose merging #5496 then #5524 first, so your copy path can reuse that foundation and skip inactive owners in its new lookup. If #5499 lands first, I can rebase this pair instead. The separate copy eligibility needs to remain explicit: your no-HTILE/two-sample clear0.375 fixture differs from this PR's creation-proven numeric sampling subset; this is a source composition check, not runtime validation of your PR.
@nicolasabosch: #5445 builds on #4820's color lookup. The inactive-owner correction is being validated in our existing #4820 comment. #5445's uniform import makes a no-resident lookup a supported path, so the important remap control there is selecting the new contents rather than imposing #4820's current no-draw refusal.
The functional prerequisites for this PR remain #4820; #5524 depends on this PR. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T11:50:31Z.
Review: CHANGES_REQUESTED
Thanks for the detailed validation notes. I could not review this head yet:
Graphics/src/DepthSurface.cpp:203-204and:248useGuestTextureResource::samplesandTextureDimension::k2DMsaa, which only exist in #4820.mainintests/DepthSurfaceReuse.cpp.main+ #4820 it conflicts again, inGraphics/src/DepthSurface.cpp,core/libs/prx/libSceAgcDriver/CMakeLists.txt,tests/DepthSurfaceReuse.cppandtests/GuestTextureResource.cpp. TheDepthSurface.cppconflict touches logic, so I'm not resolving it for you.Once #4820 is merged, please rebase onto
mainso the branch builds without extra commits, and re-runagc_driver_native_multisample_depth,depth_surface_reuseandguest_texture_resourceon that result. I'll review the logic, the HTILE/ITERATE_256 handling and the tests at that point.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T12:34:28Z.
Review: CHANGES_REQUESTED
Thanks for the update. The head no longer conflicts with
main, but it still does not build on its own, which is the blocker from my last comment:Graphics/src/DepthSurface.cpp:203,:204,:248and:251useGuestTextureResource::samplesandTextureDimension::k2DMsaa, which only exist in #4820 (still open).tests/GuestTextureResource.cpp.Once #4820 is merged, please rebase onto
mainso the branch builds without extra commits, and re-runagc_driver_native_multisample_depth,depth_surface_reuseandguest_texture_resourceon that result. I'll review the logic, the HTILE/ITERATE_256 handling and the tests then.Imported from boykopovar/AnyPS5. Originally posted by Gashrod1 on 2026-10-14T17:22:34Z.
A title case for the native multisample depth path: DAVE THE DIVER (PPSA19115, 01.041.000) samples a 2-sample D32S8 Z_X depth target, and this PR's refusals are its next stops. Bring-up thread: #5963.
Tested composition:
main956269ad1+ #4820 (84f636494) + this PR at 213050f32 + #5445 (556890fb3), Windows 11, MinGW-w64 GCC 15.2.0, RTX 5060. I have not run 7b5cbb814, but the refusals and the lookup below are unchanged there.To reach the game I had to bypass, in this order:
native multisample depth metadata fill transition is not implemented: the HTILE fill covers the whole target, so the result is a known clear rather than an unknown metadata state.native multisample stencil or depth format import is not implemented: the target isVK_FORMAT_D32_SFLOAT_S8_UINTwith a stencil plane.native multisample depth import requires watched accessible guest memory, then the same at sampling: on Windows, direct host imports are compared and not watched (#5596).native multisample depth fast-clear transition is not implemented: the target is fast-cleared while it is sampled.native multisample depth sampled identity or format mismatch, when the player goes back to the boat.The fifth one looks like a lookup issue rather than missing support. The texture read there is not a multisample depth read:
0x242610000is target +0x1100000(2048 x 1088 x 4 bytes x 2 samples), which is the target's stencil plane address. That is the only wayplaneSurfacematches a texture whose base is not the depth address. InDepthSurfaceTexture,base.samples != 1usends any reader of the stencil address down the multisample branch, andCheckResourcethrows. The single-sample branch would have returnednullptrfor this resource, because a stencil read needsBytesPerElement(resource.format) == 1. Locally I returnnullptrwhen the identity does not match, so the texture goes down the color path. It fires about 28,000 times per session, and the crash on the way back to the boat is gone. Rejecting non-stencil formats on the stencil address before the multisample branch would be the narrower version of that.My bypasses for items 1 to 4 (which include skipping the initial-state proof) are workarounds, not suggestions. I list them only to show what this title hits.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-14T18:37:44Z.
@adriadam10 Current standalone retest: 804c1b390, based on main411e5e6d9 with #4820 merged. Full Windows app/libs/conventions/registration and14 groups once+5 under NVIDIA/AMD selectors pass, no failures/skips, maximum5.85142s. Logs verify physical device identity for the runtime groups; CPU checks are separately identified.
agc_driver_graphicsexecutes bothRunDepthSurfaceReuseTests()andRunGuestTextureResourceTests(); the native numeric sampling fixture also ran. There are no copied foreign dependencies or child commits. The newly reported stencil-address/color-format classification bug is corrected with failing-old/passing-new CPU coverage and native-device refusal checks; its source/control/scope is in the updated PR body. The requested build/rebase/test blockers are addressed; the existing logic/HTILE/ITERATE_256 review remains pending.Previous615 retest, preserved
@adriadam10 #4820 has merged, and I rebased this PR directly onto main
f25386b90. Published head: 61546403b. It builds on its own; no copied dependency or follow-up commits are included.Full Windows app/libraries, conventions and registration pass.
agc_driver_native_multisample_depthandagc_driver_graphicspass once plus five repeats on both RTX5080 and AMD Radeon Graphics. The graphics group invokesRunDepthSurfaceReuseTests()andRunGuestTextureResourceTests(); all requested checks ran on this standalone result. Fourteen groups including depth/storage/color-MSAA regressions pass without failures/skips, maximum individual iteration5.65s with shader caches disabled. GPU/driver/OS details and source pins are in the updated description.GitHub confirms the head merges with subsequent maincb893e0f. It is ready for the logic/HTILE/ITERATE_256 review you requested. Full CI still requires maintainer dispatch; no fresh title or Linux/full-suite result is claimed. AI-assisted: Codex.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-14T19:51:26Z.
@Gashrod1 Implemented and tested the narrow ordering correction in head804c1b390, rebased onto main411e5e6d9. The existing stencil byte-format filter now runs before native multisample routing.
The CPU regression covers D16S8/D24S8/D32S8 ×2/4/8 samples:27 color aliases are declined and18 plane-reader recording checks remain. The native device fixture checks a single-sample R11G11B10 request at a D32S8 stencil address is declined while actual stencil access retains its unsupported-import refusal. Published615 production with test-only additions builds and fails on the erroneous recording requirement;804 passes.
Full Windows app/libs/checkers and14 groups once+5 under NVIDIA/AMD selectors pass without failures/skips, max5.85142s; runtime device identities are verified. Combined depth/stencil import and Windows tracking remain unsupported. This is classification validation, not a replay of DAVE THE DIVER or verification of its other bypasses. Items1/4 remain associated with #5554's completion-proven clear work.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T21:05:29Z.
Review: CHANGES_REQUESTED
Thanks for the update, the head builds on its own now. I rebuilt it merged onto current
main(the only conflict was the include list inMultisampleTarget.cpp:3, keep bothColorTargetLayout.hppandDepthSurface.hpp),agc_driver_native_multisample_depthpasses. I then mutated the code to check that the new tests pin the behaviour, and two mutants survive:Graphics/src/Draw.cpp:2115: deleting theRequireNoNativeDepthFeedback_nid_no_patch(...)call leaves every test green.tests/execution/NativeMultisampleDepth.cpp:536-547calls the function directly, so nothing checks thatDrawactually calls it before the pipeline is created. Please add a case that goes through a draw sampling the attached native depth image and expects the refusal.Graphics/src/DepthSurface.cpp:67: changingif (depth == 0u) return clearDepth == 0.0f;toreturn true;also passes. The clear-value refusals atNativeMultisampleDepth.cpp:668-674never use all-zero HTILE withclearDepth = 1.0f, which is the case that would import a wrong initial depth. Please add it (and the mirror:0xfffc0000/0xfffffff0words withclearDepth = 0).Please also rebase onto
mainfor the include conflict above and re-runagc_driver_native_multisample_depth,depth_surface_reuseandguest_texture_resource.Not covered by what I could run here: the HTILE encodings and ITERATE_256 behaviour follow Mesa/PAL, not measured on a console, and nothing ran on NVIDIA/Windows.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-15T00:00:06Z.
@adriadam10 Addressed both surviving mutants in 008f91501: the regression goes through the driver draw, and the four contradictory HTILE/clear cases are covered. All three fault controls fail for the intended assertion ×5 on NVIDIA and ×5 on AMD; production restored/rebuilt,14 groups pass once+5 per GPU. Depth-reuse/guest-texture cases run inside
agc_driver_graphics. Rebased onto main3c87; merge into later mainab9 is clean. The PR description now contains only current validation and links to the older evidence. AI-assisted: yes.Merged: #5496 landed as
c4f03522a70d0392d1426f092f712009b1d55675and is included in main0afa6a607. @adriadam10's approval and independent validation remain linked; no re-review request is pending. Our follow-up compositions and their residual import-tracking failure are separately scoped in #6060's maintained report. Earlier local evidence above retains its tested pins.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T00:40:06Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL125-126, L139-141, L863-864core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppL856-857Imported from boykopovar/AnyPS5. Originally posted by Gashrod1 on 2026-10-15T00:40:26Z.
Independent test of
008f91501on a title: DAVE THE DIVER (PPSA19115), Windows 11, NVIDIA GeForce RTX 5060 (596.36). Same session, same dump, only the libs change:mainab9a47684guest texture descriptor uses MSAA which is not implementedmain+ #5496 (008f91501)sampling the 1920x1080 multisampled texture 0x22b790000 of 2 samples, which no draw rendered to and whose tile mode 4 has no modeled multisampled color footprint, is not implementedSo this PR moves the title past the ITERATE_256 refusal on current
main; the merge ontoab9a47684was clean.The next stop is outside this PR: a 2x Z_X depth texture sampled before any draw, with an all-zero HTILE. I have a follow-up for it (undrawn Z/D 64 KiB swizzle textures, and Z ones whose HTILE is all cleared, load as a uniform value). With it on top of this PR the title reaches frame 17 and stops on the D32S8 native depth case I described on #5554. I will open it once this PR is merged, since it is only reachable after it.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T07:47:11Z.
Review: APPROVED
Checked the new head: the two surviving mutants now fail (removing the
RequireNoNativeDepthFeedback_nid_no_patchcall inDraw.cpp:2203andreturn trueatDepthSurface.cpp:74both failagc_driver_native_multisample_depth). Built merged onto currentmainwith no conflicts;agc_driver_native_multisample_depthandagc_driver_graphics(which runsdepth_surface_reuseandguest_texture_resource) pass.agc_driver_tessellationsegfaults here, but it does the same on a plainmainbuild. Merging once the full Build is green.