fix(agc): settle queued HTILE clears before native depth use #7371
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7371"
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-18T03:10:59Z.
What
Register a recognized queued native-depth HTILE clear's exact range as a pending write, then settle that producer before cached-owner, sampled-texture or attachment consumption. Copy the range under the surface mutex and release it before
SyncThrough. Retain CPU-race, complete-coverage, clear-value and unknown-writer refusals.#7233 is merged. Head
d62377dd75ebb86eeac6bd3f4d6be986ba84c8cbis one focused commit on main3ca07d086d5f44fbe3c00370e7f03953ab46ca1b: five files, +68/-3. Its added/removed line sequences are identical to our prior delta against adapted #7233. The prior published head is preserved; MarcZX10's prerequisite and Jan Slegl's tracker-test attribution remain in merged #7233.Sonic Unleashed Recompiled PPSA99902, #4443, encountered this stop in the earlier composed bring-up:
This refresh has no new title replay or performance claim. Agreed order: this PR before #9533; #9533 also follows #6973. The new metadata-fill composition refusal in EagleBearerYS's 5e8a1cdb83 stays with that fill capability. Main still refuses metadata fills over this native owner.
Tested
Frozen source: main
3ca07d086d5f44fbe3c00370e7f03953ab46ca1b; fixture-only controlb11525c34ca7da4456bc6b0c281619c7e80192bc; final headd62377dd75ebb86eeac6bd3f4d6be986ba84c8cb. Windows 11 Enterprise 26200, WinLibs GCC15.2r7/UCRT Release, SPIRV-Tools enabled (confirmed from the retained production compile commands).NativeDepthBdaClear.cppfails 3/3 per physical GPU atthe recognized HTILE clear is missing its pending write range. Final head passes 3/3 per GPU. Each process checks owner, sampled texture and attachment consumption before explicit WaitIdle, settled pending ranges, exact 32768-byte metadata and complete 1MiB allocation readback. The unrecognized-pending-write refusal also passes.checked=27 unavailable=0, on both main and head. That refusal does not prove completed-clear output or fix #8759.10de:2c02, 610.62 /32.0.16.1062; Radeon Graphics1002:13c0, 32.0.21036.18. Required Vulkan,ANYPS5_NO_SHADER_CACHE=1,APS5_NO_PIPELINE_JOURNAL=1, loaded Khronos1.4.363, verbose serial CTest with 30s timeout. Across 84 processes: zero VUIDs, validation errors/warnings, whole-test skips or timeouts; maximum 6.949s. Driver caches uncontrolled.8b3e39832af85f404c6195418d11b3e1ebd1924dfor source compatibility: its sRGB twin, video-init and directory-link changes do not change this handoff delta. That newer composition is not runtime-tested here. Maintainer-triggered CI remains separate.Reproduce the primary check:
ctest --test-dir <build> -V -j1 --timeout 30 -R '^agc_driver_native_depth_bda_clear$'with the settings above.Attributed external evidence at its reported pins
jotitadev retested older head
989764414on Apple M2 Max, macOS27.2, x86_64/Rosetta2, composed with macOS port #8658ee0a438415. On MoltenVK1.4.2 and MoltenVK main + SPIRV-Cross #2704, all five focused depth groups pass 3/3; reverting the handoff production files preserves the prerequisite and makes BDA clear fail at the missing pending range. The earlier clear-test timeout is gone in that composition.CheckImportWindowstill fails with and without this PR; the full AGC suites retain base failures, plus an intermittent colour-target result on MoltenVK1.4.2. These are the reviewer's results, not local/current-head totals.EagleBearerYS's composed-branch report preserves Note -> Arm after imports -> completion, and keeps
SyncThroughoutsidesurfacesMutex. Its lavapipe imports are not write-watched: BDA clear skips there, so it is not coverage of our watched-import regression. MarcZX10 withdrew the earlier deadlock concern.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 MarcZX10 on 2026-10-18T03:21:48Z.
Review: COMMENTED
I found a likely deadlock in the consumer handoff.
DepthSurfaceView,DepthSurfaceTexture, andDepthSurfaceHoldsacquireGuestMemory::GpuMutex()before callingsettlePendingHtileClear(), which can callRecorder::SyncThrough()while that mutex is still held. The queued dispatch is executed by Queue0 and its dispatch lambda takes the same GPU mutex (the prerequisite #7233 report also identifies this lock as the Driver-worker timeout cause). If the pending write belongs to that queued clear, the consumer waits for the batch while its worker cannot acquire the mutex to record/submit it. Could the handoff arrange to wait outside the GPU mutex, or otherwise prove the pending batch is already submitted before this path waits? The surface mutex is released, but the GPU mutex remains held.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T03:22:45Z.
Review: COMMENTED
Follow-up to my earlier comment: I could not establish the deadlock from the current synchronization path.
PendingWriteOverlapsonly becomes true afterrecordDispatchhas queued the HTILE completion and registered the recorder range; that recording path itself runs underGpuMutex. So the specific queued worker I was concerned about has already passed the mutex before this consumer can observe the pending range. Please disregard my deadlock concern. I found no concrete defect in the reviewed handoff.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T03:32:31Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Graphics/include/DepthSurface.hppcore/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppcore/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cppImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-19T09:00:44Z.
Review: COMMENTED
Apple GPU / MoltenVK run, as a third vendor for the dependency note. The handoff works on Metal:
agc_driver_native_depth_bda_clearpasses, and it fails with your handoff commit reverted.agc_driver_native_depth_clearstimes out at 30 s here too, as on your RTX 5080 and Radeon. It passes without #7233, so on Apple it is also new with the prerequisite. On this tree it passes in 0.3 s.Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704. Head 3ca97c756. The diff from the merge base includes #7233 (42cbe0c33). One hunk in
NoteHtileDepthClearconflicted because this tree predates main'ssampling.Refuse(...). I kept the tree'ssampling.refusal = ...for the two refusals and took your newelseblock unchanged.Tested: the tree is
maina373e85e5+ mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plainmain(it doesn't build on macOS yet). Applied together in the same build: #7371, #7535, #7684, #7746 and #7759, plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branchjotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40^agcfailures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, plusagc_driver_pooled_buffer_rangeandagc_performance_overlay, which only run because of the loader patch.agc_driver_native_depth_bda_clearandagc_driver_native_multisample_depthpass 3 of 3 on both drivers.agc_write_trackingis a base failure on macOS, atCheckImportWindow(a block the import window did not touch reads as written). That check runs after the new possible-write checks, and the test still stops there, so the new checks pass.VulkanDevice.cpp,DepthSurface.hppandDepthSurface.cppchanges reverted (#7233 kept),agc_driver_native_depth_bda_clearfails on both drivers withthe recognized HTILE clear is missing its pending write range, the same as your control.agc_driver_native_depth_clearsstill times out.agc_driver_native_depth_clears,agc_driver_native_multisample_depthandagc_driver_native_depth_bda_clearpass 3 of 3 on both drivers.^agcsuite with the stack: the base failures plusagc_driver_native_depth_clears(timeout) on both drivers. #7746 in the same build removes one base failure. Nothing else changes.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-20T22:38:32Z.
Updated in place after #7233 merged: #7371 is now the focused five-file handoff delta at
d62377dd75, on main3ca07d086d, with Depends on: none. The PR description holds the current validation matrix, hardware, reproduction and external-review scope.Current local qualification: 78 passes (39 main, 39 refreshed head) and six expected fixture-only control failures, across RTX5080 and Radeon Graphics. No VUIDs, validation errors/warnings, whole-test skips or timeouts. All runtime libraries/relinker and focused targets build; the full-default target was intentionally stopped, not claimed complete. All27 analyzer diagnostic contexts match main. No new game replay or FPS claim.
The older
9897644145/cd700fe9ec198-process qualification is historical at those pins; its published source is preserved. The latest attributed Apple review supersedes the earlier timeout report only for its stated macOS-port composition. #8759 remains a separate tracking gap.AI-assisted maintenance: yes.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T02:03:40Z.
@Amoenus a merge-order note: #9533 changes
NoteHtileDepthClearinDepthSurface.cppand the native multisample depth tests, where this PR settles queued HTILE clears, for native multisample D32S8 targets with a separate stencil plane. #9533 goes after #7233, as this one does, and proposes going before this PR, which would then rebase over it. If you'd rather this one went first, say so and #9533 will list it under Depends on.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-22T07:56:39Z.
@EagleBearerYS I prefer #7233 -> #7371 -> #9533. #7371 is the focused queued-clear completion/handoff correction; #9533 adds the separate-stencil and depth-only-HTILE shapes. Landing the handoff first keeps that correction reviewable without pulling the wider stencil capability into it, and matches the order we previously discussed on #7233.
Please list #7371 in your merge-order dependencies and rebase after it. In the composition, keep the pending/armed/completion ordering and the range-limited
SyncThroughoutsidesurfacesMutex; the clear-aspect/plane proofs from your changes must also survive. This is a source-level merge-order preference, not validation of the combined branch. #7371 remains mergeable on current maind6eafa54d0and still depends on #7233. AI-assisted: yes.Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T08:26:07Z.
Review: COMMENTED
Re-ran 989764414 on the M2. The
agc_driver_native_depth_clearstimeout I reported on 3ca97c756 is gone on Apple: it passes in about 0.7 s on both drivers, with the refreshed #7233 included.Machine: Apple M2 Max, macOS 27.2, x86_64 under Rosetta 2. Release,
BUILD_TESTING=ON.Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0), and MoltenVK main + SPIRV-Cross #2704.
Base/method: PR #8658
feat/macos-port@ee0a438415(currentmainplus the macOS port), notmain, which does not build on macOS. This head merged into it (git merge-tree, no conflicts), diff withoutdocs/. Full rebuild before each run. No other PRs stacked this time.agc_driver_native_depth_bda_clear,agc_driver_native_multisample_depth,agc_driver_native_depth_clears,agc_driver_native_depth_retirementandagc_driver_native_depth_clear_refusalspass.agc_write_trackingfails here with or without the PR, atCheckImportWindow(a block the import window did not touch reads as written). That is a macOS base failure. The newCheckStoredOverUsesPageEvidenceruns before it and passes.VulkanDevice.cpp,DepthSurface.hpp,DepthSurface.cppback to 01248f46b6, prerequisite kept):agc_driver_native_depth_bda_clearfails on both drivers withthe recognized HTILE clear is missing its pending write range, the same as your control.agc_driver_native_depth_clearspasses in this state too.^agcsuite (-j1 --timeout 30, 857 tests): MoltenVK main + #2704 matches the base exactly (16 failures). MoltenVK 1.4.2 has the base's 17 plusagc_driver_uint8x4_color_target. That test is intermittent on this machine without this PR too (UINT16_ABGR export byte mismatch), and it does not touch HTILE or depth. No timeouts on either driver.GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T09:12:20Z.
@Amoenus thanks, agreed: #9533 lists #7371 under Depends on and rebases after it (#7233 → #7371 → #9533). A
git merge-treeof #9533's next head over this PR isn't clean, inDepthSurface.cppand the native multisample depth tests, so the rebase composes the two and keeps:SyncThroughoutsidesurfacesMutex;A composed branch will be on my fork for you to look at if you want to check the handoff; I'll link it here when it's up.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-22T10:16:08Z.
@Amoenus the composed branch is up:
compose/9533-on-7371(5e8a1cdb83). It's #9533's 11 commits replayed on a merge of this PR's 9897644145, plus one commit for a gap the two only have together.NoteHtileDepthClearonly marks the clear pending; the generation is taken inArmHtileDepthClearafter the dispatch's imports; the clear is proved onceCompleteHtileDepthClearmarks it written.CheckCurrentrefuses a pending clear before #9533's plane checks. An HTILE dispatch clear takes this PR's branch whole, and fills keep #9533's.--clear-refusals: red with the hunk reverted, green on the head.SyncThroughinsettlePendingHtileClearstill runs after its lock block, outsidesurfacesMutex.^agc_driver_native|^agc_driver_msaa_dcc_clear_4$, and the head passes it ×5.^agcsuite gives 877 of 878 on the head. The one failure,agc_driver_sgpr_pattern_fill_keys, passes ×20 alone and also fails intermittently in parallel^agcruns onmain.agc_driver_native_depth_bda_clearskips and theDriverDispatchcase takes its unwatched branch.71decdc752and 2b5d9eba09 had no red there, and need a device whose imports stay watched.#9533 takes this branch, with
mainmerged in, once this PR merges.Imported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-22T13:07:27Z.
Merged update, 2026-10-22: #7371 landed as
329efe1bfdaff116c57cdf62718026ee4f5521aeat 14:14 UTC, containing qualified headd62377dd75. #9533 can now take the agreed main-based composition; its separate dependency on #6973 remains. That root is refreshed at9290696549after #8847. The validation below retains its stated source pins.@EagleBearerYS Thanks for the composed branch and the separate red/green control. I inspected
5e8a1cdb83: the pending-dispatch/fill refusal belongs with the new fill support in #9533. On current main, metadata fills over the live native owner still refuse; I will keep #7371 focused on the queued-clear handoff. The agreed order remains #7371 before #9533, with #9533 also following #6973 as confirmed there.#7233 has now merged. The published head is preserved on the fork. The same five-file delta is now pushed at
d62377dd75, directly on main3ca07d086d, with Depends on: none. Current-main and refreshed-head checks give 78 passes total on RTX 5080 and Radeon Graphics; the fixture-only negative control fails at the expected missing pending range 3/3 per GPU. The maintained description has full scope and reproduction. Newer main8b3e39832amerges cleanly with this source; that newer composition was source-checked, not runtime-tested. Your lavapipe skip limitation remains separate from watched-import coverage on these devices.@jotitadev Thank you for re-running
989764414and the production-revert control. I updated the maintained report to reflect that the earlier clear-test timeout is gone in your reported macOS-port composition. The baseCheckImportWindowfailure and intermittent colour-target result remain scoped to your report; they are not counted as our local rebase results.