feat(agc): publish a written native multisample D32 depth surface to its guest planes on access #9950
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9950"
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 ebarr24 on 2026-10-22T23:39:25Z.
What
A guest read, DMA copy source or texture, storage, index or vertex read over a native multisample depth surface that a draw had written threw sample-preserving guest publication of native multisample depth is not implemented (Sonic Superstars PPSA06888 #5382, Monster Hunter Wilds PPSA24191 #7972, Onimusha PPSA27836 #6570). The access now completes the pending fast clear and recorder work, reads the samples back in the guest layer, row, column, fragment order with the merged multisample readback, retiles them into the Z_X plane with the descriptor pipe-bank XOR through MultisampleTextureLayout, and rewrites every HTILE word to the expanded clear word (Mesa radv_get_htile_initial_value: 0xfffc000f without stencil, ZMask 0xf with the full Z range otherwise) before retiring the surface like an unwritten one. Written D16 surfaces, surfaces the device stores in another format and surfaces it cannot sample still throw with their own messages. The console HTILE after a DB decompress and its compressed plane bytes are not measured.
Tested
Windows 11, MinGW-w64 GCC 15.2, Release build with tests.
agc_driver_native_multisample_depthpasses with this change; the new test fails onmain.Validation layer (vulkan-sdk-1.4.363.0), on
mainfcd455870cand on this change, withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,VK_ADD_LAYER_PATHset to the layer,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1:ctest -V -R "agc_driver_native_multisample_depth$". Neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS; the change adds noVUID-errors (0 with the change, 0 onmain).ctest -V log, main
The
***Failedresult and the failure line at its end are the new regression test failing onmain, as intended; they are not an unrelated baseline failure.ctest -V log, this change
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)mainand this change, no new VUIDs🤖 Generated with Claude Code
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T23:51:39Z.
Review: APPROVED
Reviewed the complete implementation, retirement flow, regression tests and debt update. Publication waits for recorder work, reads D32 samples with the descriptor layout/XOR, preserves untouched guest padding, expands HTILE metadata, then retires the guarded surface. The added cases cover 2/4/8 samples, non-aligned extents, depth-only metadata, XOR, sample values, padding and clear transitions. The author reports the focused Vulkan test passing on Windows/NVIDIA and a paired validation-layer run with zero VUIDs on both the test branch and baseline. I checked the seven commits from that baseline (
fcd4558) to currentmain(895f47f); none changes the implementation, tests or layout files reviewed here. Hosted policy checks pass; product build jobs are skipped by repository policy. I found no blocking defect.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T00:32:01Z.
Review: APPROVED
Reviewed the publication path and regression coverage. The access path syncs pending recorder work, reads the native multisample image into a linear staging buffer, retiles samples using the guest Z_X layout and pipe-bank XOR, expands the HTILE words, writes guest memory, then retires the resident surface. The implementation explicitly keeps D16, host-format conversion, and unsampleable devices unsupported. The test checks 2x/4x/8x D32 publication, both HTILE shapes, a nonzero pipe-bank XOR, every sample location, and untouched padding; the author reports zero validation-layer VUIDs on both main and the change. The required policy/conventions/intake/labels/report checks pass; hosted product jobs are skipped. I could not run the GPU test here because this environment has no
/dev/dridevice. The overlap with #9533/#9717 is distinct D32S8 import/stencil sampling work; if either merges first, please rebase and preserve those changes alongside this D32 guest-publication path. Approved at head875fa29033.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-23T06:08:21Z.
Review: COMMENTED
First run on Apple silicon. It goes from red to green with both drivers I tried.
Setup: Apple M2 Max (32 GB), macOS 27.2, x86_64 build under Rosetta, Release,
BUILD_TESTING=ON. Method: #8658 (feat/macos-port) @4e0468722fplus this PR's diff from its merge base (head875fa29033), notmain, sincemaindoes not build on macOS yet. Two drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVKmainwith SPIRV-Cross #2704.ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1,ctest -R 'native_multisample_depth|native_depth' -j1 --timeout 30 -V.agc_driver_native_multisample_depthfails withsample-preserving guest publication of native multisample depth is not implemented;_clears,_clear_refusalsand_retirementfail because they expect the new refusal messagesWith this PR, the new publication case checks samples, HTILE and padding for 2 and 4 samples, at 5x3 (
depthOnly=0) and 70x67 (depthOnly=1,xor=0x8c00).GPUs tested: Apple M2 Max (MoltenVK 1.4.2 from Vulkan SDK 1.4.363.0, and MoltenVK main + SPIRV-Cross #2704), macOS 27.2.
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T03:14:37Z.
Review: DISMISSED
Reviewed — changes requested
On its own base the D32 publication path builds and its focused tests pass with no validation errors. However, the branch no longer merges into
main,main's newer tests still expect the refusal this PR removes, and the guard can now retire a written surface without publishing it.What I ran
875fa29033c500a0f49af4c50cf3970d37fd2229(merge basefcd455870cb9610d929f744719a4d20ffd544499)main:3a2b91981651569163768854a1fcdc7193b6667bResults
main3a2b919816core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp;DepthSurface.cppand the debt file merge without conflictgit diff --checkcheck_conventions.pydebt-length,docs/dev/debt/libSceAgcDriver.md:30, 2196 characters)agc_driver_native_multisample_depth_tests,libs)agc_driver_native_multisample_depthdepthOnly=0and 70x67depthOnly=1 xor=0x8c00)agc_driver_native_depth_retirement/_clears/_clear_refusalsVUID-linesDepthSurface.cppwas not found but was requested by env var VK_INSTANCE_LAYERSVK_LAYER_KHRONOS_validationBecause of the conflict, all results above come from the PR head on its own base (
fcd455870c), not from a merge with currentmain.Conflict
PR head, focused tests
The regex in that run also matched
agc_driver_multisample_retirementandagc_driver_native_depth_bda_clear. Their executables are separate targets that were not rebuilt for this head, so I don't count their results.Negative control
I restored
Graphics/src/DepthSurface.cppfrom the merge basefcd455870c, kept this PR's test, and rebuilt. All four tests then failed:Base DepthSurface.cpp with this PR's test
This matches the earlier reports from Windows and macOS on this PR, now on Linux with NVIDIA.
Findings
Blocking
Conflict with
main, plusmaintests that would fail after a text-only resolution. The textual conflict is inmain()oftests/execution/NativeMultisampleDepth.cpp(above). A rebase also has to handle code that merges without a conflict but no longer agrees with this PR:main'sCheckDepthTarget(lines 1087 and 1090 onmain) asserts thatDepthSurfaceView(context, alias)over a written surface refuses with"sample-preserving guest publication". These asserts came in with #10375. This PR removes that message from production. The aliased bind now reachesPublishToGuest, which throws "needs the texture detiler" in this fixture (or the D16 message). Keeping both sides of the conflict therefore leaves two asserts that fail. I found this by reading the code; I did not build the merged tree.main, two more callers now reachRequireNoResidentDepthRead_nid_no_patch. These areDepthSurfaceView's retire-before-rebinding of an overlapping layout (#10375,DepthSurface.cpparound lines 2115–2117 onmain) and the GPU buffer write path inGuestBufferMemory.cpp(#11369). With this PR, both would publish a written surface: they would runrecorder->Sync()and aCommandBatch::SubmitAndWaitfrom the attachment-bind and buffer-write paths. Please rebase, then test or at least describe the behaviour for those two callers.mainhas since applied the same policy (609f4f1205, "Tests keep to implemented behaviour"). The rebased test should follow it.RequireNoResidentDepthRead_nid_no_patchcan retire a written surface without publishing it (Graphics/src/DepthSurface.cpp:1917-1934at the head).main, thehostWrittencheck and the guard deactivation run under the same uniquedepthGuardMutex, and a written surface throws.publishWrittenDepththen waits forGpuMutex, which the graphics worker holds while it draws. The guards are deactivated later under the unique lock, and every overlapping guard is deactivated without re-checkinghostWritten.NoteDepthSurfaceWrite(:1940-1945) setshostWrittenundersurfacesMutexonly. Suppose a draw writes an overlapping surface after the collection, or afterpublishWrittenDepthreturns but before the deactivation. That surface is then retired, and the guest reads stale bytes with no error. Before, that path threw.GpuMutexandsurfacesMutexbefore collecting, and collect, publish and deactivate in one critical section. Or, under the unique lock, re-check every overlappinghostWrittenflag, and publish or throw for any flag that is not inwritten.Non-blocking
docs/dev/debt/libSceAgcDriver.md:27). The "Native multisampled depth clears" entry still says "guest depth publication ... remain unimplemented", but written D32 surfaces are published now. Narrow it to D16 publication and the other still-open cases.docs/dev/debt/libSceAgcDriver.md:30). The edited entry is 2196 characters, which triggers the conventions warning. The new sentence mostly describes the implemented behaviour, but CONVENTIONS says a PR that closes a gap "cuts it to what is still open, instead of rewriting it to describe the corrected behaviour". Suggest keeping only what is still open: the console HTILE after a DB decompress and the compressed plane bytes are unmeasured, rebinding imports nothing, and D16 publication is unimplemented.DepthSurface.cpp:1650, the PR text and the debt entry). For the Z-and-stencil HTILE layout (htileDepthOnly == false), Mesa'sradv_get_htile_initial_valuereturns0xfffff3ff, which sets SR0, SR1 and SMem to 3 ("stencil test result unknown").expandedHtileWord(word, true, VK_IMAGE_ASPECT_DEPTH_BIT)keeps the guest's bits 4–9 instead, and the test expects0xfffff00ffrom zeroed metadata. Either say that the stencil fields are kept on purpose and why, or set them as Mesa does; the citation should match whichever choice the code makes.Not verified
main; the conflict prevented it. The failing alias asserts and the new callers in finding 1 come from reading the code.To get this to a good state
main. Keep both sets ofmain()cases, updatemain's alias-rebind assertions for the new publication behaviour, and drop the asserts that only check "not implemented" refusals.NoteDepthSurfaceWrite. A test with a write between collection and deactivation would cover it.mainadded.agc_driver_native_multisample_depthand theagc_driver_native_depth_*tests with the validation layer onmainand on the rebased change.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-10-29T12:32:24Z.
Review: DISMISSED
Re-checked — changes still requested
The new commits merge
mainand stop requiring D16 publication to throw, so the conflict is gone. However, two of the four focused tests now fail on the current head, while the same tests pass onmain. The guard race from my last review is also unchanged.What changed since my last review
59f798e11f:mainmerged into the branch. Themain()conflict inNativeMultisampleDepth.cppis resolved by keeping both sides.c8fa65d134:test(agc): stop requiring D16 native depth publication to throw. This replacesPublicationRefusal(format)withPublicationRefuses(format, action), which skips D16 and expects the "needs the texture detiler" refusal for D32.DepthSurface.cppand the debt file have no changes beyond the merge. The description and checklist are unchanged. Both commits are byoneandonlydean, whose comment says "no other changes".What I ran
c8fa65d134fc6ab0c6b9b17063653368cc75bee0main:5454cd2e455994d992aca39335ce60507eeda1eb. The head already contains it, and the--no-ffmerge has the same tree as the head.Results
main5454cd2e45git diff --checkcheck_conventions.pydebt-length,docs/dev/debt/libSceAgcDriver.md:39, 2196 characters)agc_driver_native_multisample_depth_tests,libs)agc_driver_native_multisample_depthagc_driver_native_depth_clearsagc_driver_native_depth_retirement/_clear_refusalsmainVUID-linesmainwas not found but was requested by env var VK_INSTANCE_LAYERSVkLayer_khronos_validation.jsonin bothHead, focused tests
Negative control
On the merged tree, I restored only
Graphics/src/DepthSurface.cppfrommain, kept the test file, and rebuilt. All four tests failed.agc_driver_native_multisample_depthstopped at the first publication case withsample-preserving guest publication of native multisample depth is not implemented. The other three failed withrefusal did not match guest publication of a written native multisample depth needs the texture detiler. The new D32 cases therefore depend on the production change. I restored the file afterwards.Previous findings
main: Resolved. The branch now merges cleanly.main's alias-rebind asserts: Still open, and now confirmed by a run.NativeMultisampleDepth.cpp:1163and:1166still expect"sample-preserving guest publication"fromDepthSurfaceView(context, alias). Production no longer contains that string.RequireNoResidentDepthRead_nid_no_patch→publishWrittenDepthand throws the D16 refusal (or, presumably, the detiler refusal for D32). That failsagc_driver_native_multisample_depthandagc_driver_native_depth_clears(output above).c8fa65d134updated the other"sample-preserving"asserts but missed these two.main's new callers (alias retire-before-rebind,DepthSurface.cpp:2182-2184; GPU buffer writes,GuestBufferMemory.cpp:5419): Still open. They are neither covered by a passing test nor described.GpuMutexwhenpublishWrittenDepthtakes it again.GpuMutexTypeis recursive andsurfacesMutexis released first, so I see no self-deadlock there.c8fa65d134.PublicationRefusesskips D16, and the production D16 refusal stays.RequireNoResidentDepthRead_nid_no_patchis unchanged. It still collectshostWrittenunder the shared lock, publishes without that lock, and then deactivates every overlapping guard under the unique lock without re-checking. Not reproduced.docs/dev/debt/libSceAgcDriver.md:36still says "guest depth publication ... remain unimplemented".debt-lengthwarning.radv_get_htile_initial_valuecitation: Still open. The code (DepthSurface.cpp:1797) and the test's expected0xfffff00fare unchanged.New findings
Blocking
agc_driver_native_multisample_depthpassing onfcd455870c, but that test fails onc8fa65d134(above). Once the alias asserts are fixed, please re-run the four focused tests with the validation layer onmainand on the new head, and update Tested and the GPUs tested line.Non-blocking
None.
Not verified
To get this to a good state
NativeMultisampleDepth.cpp:1163and:1166for the new behaviour, for example withPublicationRefuses(format, ...)like the other call sites. Then confirm thatagc_driver_native_multisample_depthandagc_driver_native_depth_clearspass.NoteDepthSurfaceWrite, or re-checkhostWrittenunder the unique lock and publish or throw for any new writer.mainand on the new head, and update the Tested section to match.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T23:24:43Z.
Review: APPROVED
Re-checked — new head, looks good
The updated head publishes the written D32 multisample depth and HTILE data before retiring the guarded surface, with current-head Windows and NVIDIA test evidence passing.
What I ran
Reviewed exact PR head
781fdf0f20c5893c96b021e61b7a527ac0dc48a9against base5454cd2e455994d992aca39335ce60507eeda1eb; refreshed currentmainisf46f453a56f91d77e29ce0cbd7fe5bfb2fb69834. The merge preview with currentmainis clean (tree0d18e19d782b4bad781cd0c2f1cce2ee16b6ff4e). Environment: Linux 6.1.0-54-amd64 x86_64; no local compiler, build, or test run.Results
mainUnedited output from local and hosted checks
The NVIDIA run is author-reported in the current-head report; it is separate from the upstream checks above.
Negative control
main, where written-surface publication still refuses.sample-preserving guest publication of native multisample depth is not implementedrefusal.Findings
Blocking
None found in the reviewed change. The implementation restricts publication to sampled D32 surfaces stored as D32, synchronizes pending recorded work, reads back the multisample image, tiles the sample planes into the guest layout, expands HTILE, and refuses unsupported formats or missing detiler support.
Non-blocking
The behavior remains unmeasured on PS5 hardware. The upstream Linux and specialized product jobs were skipped; the GPU results are from the author-reported RTX 3080 run.
Sources
Not verified
I did not build or run tests locally, independently reproduce the NVIDIA run, test on another GPU, or verify console behavior. Linux and specialized hosted jobs were skipped.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T07:38:40Z.
Review: DISMISSED
Re-checked — changes requested
The reported focused GPU runs pass on the PR head, but their baseline predates changes to the same
DepthSurface.cpppath on currentmain, so the required current-main comparison remains unverified.What I ran
I reviewed PR head
781fdf0f20c5893c96b021e61b7a527ac0dc48a9against currentmainf7f03daf52f11191174b1be089a56e268390a707. The merge preview is clean. Environment: Linux x86_64; no local build or GPU test.Results
DepthSurface.cppand its debt entry changed; the implementation file is also changed by this PR. Current main adds an GPU-overwrite check and a depth-plane sync path inDepthSurfaceTexture.git diff --check102b7a5cf0, not currentmainf7f03daf52f11191174b1be089a56e268390a707. These are author-provided results, not local runs.Unedited local command output
Findings
Blocking
102b7a5cf0, currentmainchanged the sameDepthSurface.cppfile that this PR modifies, including a GPU-overwrite check and a depth-plane synchronization path inDepthSurfaceTexture(current-main source at the exact SHA). Please rerun the same four focused tests on currentmainand on this PR head on the same machine/GPU withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation; confirm the layer was inserted and compare VUIDs. The current report remains useful evidence for the earlier baseline, but it does not isolate this PR against today's overlapping depth-surface implementation.Non-blocking
No additional source defect found in this recheck.
Not verified
I did not run the build or GPU tests locally. I did not verify console behavior.
To get this to a good state
Please post the paired focused logs against current
mainand this exact head, including confirmation that the validation layer loaded and whether the change adds any VUIDs. I will rerun the same local source checks and recheck the logs on the updated head.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T06:48:31Z.
Review: DISMISSED
Reviewed — changes requested
This pull request does not merge cleanly into
main(d1ae628bc2): head781fdf0f20conflicts incore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppdocs/dev/debt/libSceAgcDriver.mdPlease rebase it onto current
main. I will review the change once it merges cleanly.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T17:15:10Z.
Review: COMMENTED
Reviewed — no blocking findings
The requested repository review could not be performed because the reader and workspace tools are unavailable in this session.
What I ran
Not run. No exact-head files, diff, or review folder contents were accessible.
Results
Findings
Blocking
None verified.
Non-blocking
None.
Not verified
The description, commits, diff, manifest, changed files, and repository context were not read. No files can be reported as read or reviewed.
To get this to a good state
Provide the reader/workspace access so the requested review can be completed.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T22:45:04Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing blocks this change; the points below are optional.
What I ran
Reviewed head
bd1739889aabc06013b6bbd4aa92758e82d4ff01. No commands or tests were run by me; the test results below are author-reported.Results
Findings
Blocking
None.
Non-blocking
DepthSupportedrejects. Consider ensuring CI covers at least one supported Vulkan device for each intended count.Not verified
Read the changed lines and targeted context in
DepthSurface.cpp,NativeMultisampleDepth.cpp,SampleMultisampleTarget.cpp,storage-import-touch-publication.md, andlibSceAgcDriver.md, plus the supplied description, commits, manifest, diff, and review README.files.jsonwas unavailable; the manifest and README show thatNativeMultisampleDepth.cppwas excluded from the prepared review folder, so I read its relevant ranges through the pinned reader. Did not read every line of that large test file or run tests. Console HTILE behavior and compressed plane equivalence remain unmeasured as the description states.To get this to a good state
Nothing is required. Optional: retain CI coverage on a Vulkan device that supports the tested sample counts.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T22:48:42Z.
Review: COMMENTED
Actionable comments posted: 3
Architecture findings (1)
Advisory architecture findings (1)
825e0f64-6823-4e7d-893f-a312fe2e983eReviewing files that changed from the base of the PR and between
1f27e2abfaandbd1739889a.core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppdocs/dev/debt/changes/storage-import-touch-publication.mddocs/dev/debt/libSceAgcDriver.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.