fix(agc): settle host imports under a native depth fill before its watch check #26034
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/26034"
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 birdmarty on 2026-11-23T04:53:41Z.
What
A fill of a native multisampled depth target's whole HTILE refused with
native multisample depth metadata fill over unwatched memory is not implementedwhile a host import of that HTILE was still waiting for its deferred settle. On Windows an import under 1 MiB is unwatched until it settles, soGuestMemory::Watchedwas false only for that moment: once the import settles, the memory is watched again. The native FMASK path inMultisampleTarget.cppalready settles before it checks (WatchedAfterSettle).NoteDepthMetadataFillnow settles the host imports under the fill, for each device that has a sampled native depth target there, before its watch checks. The host imports belong to one device at a time, andWatchedAfterSettleadopts the device it is given: for a device that does not own them it would park the owner's imports and drop their pending settles. The fill therefore settles throughSettleOwnImports, which checks under the imports lock that the device owns the imports and otherwise does nothing. It does so after takingGpuMutex, which settling requires, and before taking the depth surface lock: the settle path takes the imports lock and then the surface lock (rewatchSettledImports→DepthSurfacePendingResultsOverlap), so settling under the surface lock would reverse that order. Memory that is still unwatched after the settle refuses as before.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/DepthSurface.cpp:settleImportsUnderFill, called at the start ofNoteDepthMetadataFill.core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp,Graphics/include/GuestBufferMemory.hpp:SettleOwnImports, a settle that never changes which device owns the host imports.core/libs/prx/libSceAgcDriver/tests/execution/NativeMultisampleDepth.cpp,tests/cmake/agc_driver_native_multisample_depth_tests.cmake:agc_driver_native_depth_fill_over_pending_import, for 2, 4 and 8 samples, on the driver's device (the fixture device has no host imports). A native D32 target with HTILE is sampled, then a host import of its HTILE is made under the unwatch policy, so it waits for its settle and the HTILE reads as unwatched; the policy is restored right after, so only the HTILE is affected. A whole-HTILE fill follows, and sampling must still succeed and return a texture. A second Vulkan device then checks the ownership: with a pending import on the driver's device,SettleOwnImportsfor the other device must leave it, and the driver's device must then settle it. If no case gets a pending import, the test skips withskipped, the device does not defer the settle of a small host import. The test is registered on Windows only (048218f1e1, by oneandonlydean): the deferred settle exists only there.No debt entry changes: the change closes no recorded gap and adds none.
Tested
Windows 11 Pro (build 26300), Intel Core i9-9900K, AMD Radeon RX 6800 (AMD driver 26.10.1, Windows driver 32.0.21045.16010, Vulkan 1.4.315), MinGW-w64 GCC 15.3.0, Release,
main03a717f38e.Focused set (
agc_driver_graphics,agc_shader_memory,agc_driver_sample_multisample_target,agc_driver_recorder,agc_driver_cached_image_multisample_guard,agc_driver_cmask_fast_clear,agc_driver_pipelined_metadata_pass*,agc_driver_native_*,agc_driver_fmask_*,agc_driver_msaa_*,agc_driver_multisample*,agc_driver_sampled_cache*,image_msaa*,agc_driver_depth*,agc_driver_htile*,agc_driver_stencil*,agc_driver_dispatch*,agc_driver_*fill*) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363) andVK_LOADER_DEBUG=layer, plusagc_*import*andagc_driver_settle*:main03a717f38e15c841ab73)agc_driver_native_depth_fill_over_pending_import)VUID-linesagc_driver_native_depth_driver_queued_fillskips on both (host imports are compared here). Without the fix (main'sDepthSurface.cppwith this branch's test), the new test fails withAGC graphics: native multisample depth metadata fill over unwatched memory is not implemented. Without the owner check inSettleOwnImports, it fails witha pending host import did not settle when another device settled the same range first.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs:
0xd20a1b0000+0x8000, pattern 0) while a host import of that HTILE waits for its settle. A diagnostic print at the refusal showedaccessible=1 watched=0 watchedAfterSettle=1.6c4114784f, none with it. Two ran the full 610 s with no AGC error and got further into the intro than before; one stopped at a later, unrelated stop.15c841ab73was not run in the game; the game uses one device.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-settle-imports-before-depth-fill(2,503 open PRs): all 61 mergeable PRs that share files merge cleanly. The 35 PRs that conflict withmainwere searched by hand; #1368 and #7256 only callNoteDepthMetadataFillfrom tests, #6808 adds the original check, #20315 usesWatchedAfterSettlefor vertex inputs, and #4448 and #6197 callrefreshImportson other import paths. None settles before this check or adds an owner-checked settle.Not tested: Linux and macOS, where
WatchedAfterSettleonly reads the watch state and the test is not registered, a fill that two devices' active sampled surfaces cover at once (in every sequence I could build, the new device's surface over the same memory deactivates the old device's surface first), other GPUs, console behaviour.Related
Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. It was found on the stack of open PRs the game needs (#24960, #24994, #25151, #23688, #23545, #21479, #11825, #23778, #21155, #22306, #21199 and #25867–#25874) and stands alone: it applies to
mainby itself and needs none of them to build or pass its tests.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, 0 VUIDs🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T04:57:26Z.
Review: APPROVED
Reviewed — looks good
Nothing in the reviewed changes blocks merging; the targeted code and regression test support the described import-settling behavior.
What I ran
6c4114784f8e38317760668f18cc65c35f31906d.WatchedAfterSettleimplementation and the existing native FMASK call pattern.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
files.jsonwas not available through the review reader; the review folder listing and manifest identify three changed files, and all three were read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T05:49:42Z.
Review: APPROVED
Reviewed — looks good
The reviewed change at
048218f1e10e98574286a2efd3b6a4fb6c7462bbaddresses the pending Windows host-import case by settling matching imports before the depth-fill watch check; I found no verified blocking defects.What I ran
Read the prepared description, commit summary, manifest, and diff, then inspected the changed functions and relevant import-settle and fill call paths through
repo_read.py. No commands or tests were run during this review; the Windows hardware tests and other runs listed in the PR description are author-reported.Results
files.jsonwas unavailable in the review bundleFindings
Blocking
None.
Non-blocking
None.
Sources
Inspected
DepthSurface.cpp,GuestBufferMemory.cpp,MultisampleTarget.cpp,BufferFill.cpp,PacketMemory.cpp,NativeMultisampleDepth.cpp, andagc_driver_native_multisample_depth_tests.cmakeat the pinned head. The changed code collects contexts whose sampled depth ranges overlap the fill, callsWatchedAfterSettlewhile holding the GPU mutex, and only then takes the surface mutex and checks watch state. The settle implementation takes the imports mutex and checks pending depth results before rewatching, consistent with the ordering described in the PR.Not verified
The review bundle did not provide
files.json, so I could not independently confirm its exclusion list. No tests were run here, and Linux, macOS, other GPUs, and console behavior were not verified. The PR description reports Windows 11 / RX 6800 validation and game runs; those results were not reproduced during this review.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T07:10:24Z.
Review: CHANGES_REQUESTED
Reviewed exact head
048218f1e10e98574286a2efd3b6a4fb6c7462bb. The lock order is sound, but calling the state-adoptingWatchedAfterSettleonce per cached surface device is destructive when depth surfaces from two Vulkan devices coexist.HostImportshas one activestate.device. A window attachment keeps the previous device inreplacedDevices, andPrepareForReplacementdoes not clear its depth surfaces. If a fill overlaps sampled surfaces from old device A and current device B,settleImportsUnderFillcan enumerate A first while B owns the live pending import.WatchedAfterSettle(A)sees a stale owner and callsrefreshImports(A): on Windows that drains and clears B's pending/wanted/ready settle state, extracts every live B import intoparked[B], and switches the active cache to A. The later call for B switches back with an empty live map; parked imports are not restored. The valid pending B import is therefore no longer available to settle, its guest range remains unwatched, and B's metadata-fill check can still refuse. This also churns the entire import cache merely because an old surface overlaps.Please make this an owner-checked settle operation under the imports mutex (settle only when the requested/current device owns the active import cache), or otherwise select the actual current import owner once instead of adopting every surface device. Add an ownership-switch regression. The new runtime test should also require the post-fill
CachedSampledTextureresult to be non-null; currently discarding it lets a null result pass as long as no exception is thrown.Both exact changed translation units passed WinLibs C++20 syntax checks. A CPU model embedding the exact new helper and the production owner-switch behavior passed the single-owner control and reproduced the A→B loss (B import parked, pending state cleared, range still unwatched). This is host-model evidence, not a two-device Vulkan execution. Hosted Windows is green but its job log skipped
agc_driver_native_depth_fill_over_pending_import; the author RX 6800 run covers the single-device case. I did not run a local GPU workload.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-23T08:29:47Z.
Review: APPROVED
Re-reviewed fix head
15c841ab7326310ea1c56cd5ceae647b1cc2258e. This resolves my multi-device blocker. The fill path collects/deduplicates surface devices without holdingsurfacesMutexacross the settle.SettleOwnImportsthen checks ownership atomically under the import mutex before any stale refresh or settle, so a foreign device can no longer park/drain imports or switch the active device; the owning device retains the generation refresh and synchronous settle.The regression now keeps the post-fill
CachedSampledTextureresult and requires it to be non-null. Its two-logical-device subcase establishes pending/unwatched preconditions, calls the foreign helper first, then the owner helper and verifies rewatch. The author reports that removing only the owner guard reproduces the expected failure on RX 6800, while this head passes; their complete run changes 235/235 to 236/236 with validation enabled and 0 VUIDs.Scope is recorded accurately: the two-device ownership transition is exercised directly and the full fill path is covered in the single-device case; the author could not construct simultaneous overlapping sampled surfaces for the full two-device fill path. I found no blocking gap in that boundary. I did not run a local GPU test. The exact-head hosted Windows job is still queued and remains under watch.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T08:38:41Z.
Review: COMMENTED
Reviewed — no blocking findings
The changed depth-fill path and its focused test were reviewed at head
15c841ab7326310ea1c56cd5ceae647b1cc2258e; no concrete blocking defect was verified, but the complete changed-file set was not read, so approval is not justified.What I ran
No commands were run. I read the prepared description, commit list, diff, manifest, and targeted source ranges through
repo_read.py.Results
Findings
Blocking
None verified in the source inspected.
Non-blocking
None.
Not verified
GuestBufferMemory.cppis listed in the manifest as excluded because it was too large for the review folder. Its changed implementation was inspected through the reader, but the full file was not read.files.jsonwas not available through the reader interface, so I could not confirm its excluded-file inventory. No tests or prechecks were run. The description’s platform, hardware, and game results are author-reported, not independently verified.To get this to a good state
Nothing is required.