fix(agc): settle a pending import synchronously before an initial multisampled DCC import #9941
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9941"
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 EagleBearerYS on 2026-10-22T22:57:08Z.
What
On Windows, Rush 2 Recompiled (PPSA69423) and Wave Race 64 Recompiled (PPSA69424) stop within 10 s with
AGC graphics: initial multisampled DCC contents require watched guest memory(#9724, MaxLikesCode, RTX 4090,main7e2ba73e4c).The cause:
settleUnwatchedImports). The title's first draw to its multisampled target comes before that.settleFloorByteslowered locally, both titles got past this stop.0x4006200000+0xc4000, isn't a whole number of 64 KiB blocks.importRunAtneeds whole blocks).GuestMemory::Rewatchskips partial blocks.mainthat import stays compared for good.The approach: this is option 1, which MarcZX10 leaned toward (comment), and it builds on eliasbruno124-dev's #8527.
The change:
WatchedAfterSettle(context, address, bytes). On Windows, underGpuMutex, on a device with host imports and a settle queue, it:submitSettleBatchand waits for their fences;GuestMemory::Watched.Elsewhere it is
GuestMemory::Watched, so Linux is unchanged.initialDccClearcalls it instead ofGuestMemory::Watched. The refusal text is unchanged.Partial-block imports:
importRunAtmarks themsettleOnDemand, under the same conditions that give a whole-block import a deferred read. They still aren't queued, so the deferred path is unchanged for them.FMASK (second commit): #7948's two FMASK checks, at the import and at reuse, call the same helper.
Kept:
APS5_NO_DEFERRED_SETTLES;GuestMemory::Unwatch.A limit, stated in the debt file: a retired compared import that a recorder still holds through
KeepThroughHoldisn't visible to the shared-block check.Cost: one main-queue submission and a fence wait, only when an initial DCC import finds its range under a pending settle. That happens at target creation, not per draw. The wait also covers the main-queue work submitted before it. No product path holds a main-queue submission on a host semaphore:
HoldNextSubmitis test-only.Commits (adriadam10 rebased them onto
main2ace103a9cafter #8527 merged, so #8527's commits and the earlier merges ofmainare no longer here):fix(agc): settle a pending import synchronously before an initial multisampled DCC import.fix(agc): settle a pending import before the FMASK checks of an initial multisampled DCC import.test(agc): keep only the FMASK's settle pending in an eight-sample initial DCC case(test only).test(agc): cover multi-batch import settlingandfix(agc): settle every pending import batch, by @Queuse (comment), cherry-picked unchanged under their name.settleImportsNowsubmitted one settle batch, which holds at most 256 imports, so with more pending imports part of the range stayed unwatched. It now keeps submitting while a requested import is still wanted. The test's timeout drops from 60 to 30 s, as CONTRIBUTING asks.fix(agc): let Rewatch return page-aligned rangesandfix(agc): rewatch only a settled import's own pages:GuestMemory::Rewatchtakes 4 KiB-page ranges, with whole-block CPU stamps kept, and a settled import is rewatched by its own pages. Its guards (another compared import, a live storage image) stay on the 64 KiB span. The ARCHITECTURE.md line and the debt entry say so.main672c38f703(c097fca028), for the debt file (see Tested).Linux comparison mode, MarcZX10's case (2), is #9940.
Tested
A title run on Windows confirms the fix (comment): with this head merged onto
main, @babyhuey's Rush 2 Recompiled (PPSA69423) and Wave Race 64 Recompiled (PPSA69424) get pastinitial multisampled DCC contents require watched guest memory, wheremainstops. Runs before the last two commits still stopped there (below); MaxLikesCode's trace showed the cause those commits fix.agc_import_settle_initial_dcc(new,settleInitialDccTestsintests/Recorder.cpp).the device has no deferred settle of host imports: imports under 1 MiB wait for one only on Windows.writes to a resident multisampled DCC target or its metadata are not implemented, so the writes were tracked.main. Then the target is accepted as in case 1.VK_LOADER_DRIVERS_SELECT=*nv*), on the fix commit, cases 1-5:main. Case 1 is refused with the title's text, and 0 settle reads are submitted.VK_LOADER_DRIVERS_SELECT=*nv*, pass/fail only):(m) initial DCC over an eight-sample target whose FMASK has its own pending settle (import 589824 bytes): accepted; 2 settle reads submitted, 2 back in the write watch.agc_import_settle*andagc_import_watch*(#8527's included),agc_driver_native_fmaskat eight samples,agc_driver_msaa_dcc_clear_2,_4and_8, and the alpha-to-coverage and multisampled DCC state tests pass 20/20.native FMASK contents require watched guest memory, with 0 settle reads submitted;agc_import_settle_initial_dccgains 256, 257 and 1,025 adjacent pending 64 KiB imports settled by one synchronous call (Queuse's test and fix, f3eb5557eb):mainb1496678acagainst thatmainwith this head merged.initial multisampled DCC contents require watched guest memory, with and without this PR, and no[write-watch]line is printed.main0def01bcb5,test/9724-bothand this PR at f3eb5557eb all stop atinitial multisampled DCC contents require watched guest memory.rewatchSettledImportspassedGuestMemory::Rewatchthe rounded range0x4006200000-0x40062d0000, 48 KiB past the title's mapping at+0xc4000, so the walk failed and nothing was rewatched. The last two commits rewatch only the import's own pages.agc_write_tracking_rewatch_import_pagesfinds the page past a 0xc4000-byte import reserved but not committed (State 0x2000), then fails "a settled import whose size is not a whole block did not return to the write watch".agc_write_trackingfails "rewatching part of a block did not return exactly its pages to the write watch".agc_write_tracking_metadata_commit,agc_resident_direct_remapandagc_write_watch_coveragepass 10 runs in a row, none skipped.agc_write_trackingandagc_write_watch_coverage, the two of the five registered there, pass 10 runs in a row. Of the 61 tests the harness also mapped from the changed files, 54 pass ×10 and 7 skip, and none fail. On Windows, 8 of 79 pass ×10 and 71 skip without a Vulkan device. The libc suite passes on both. The Windows libkernel suite timed outguest_raise_in_system_callat the end of the suite: a runner timeout in a library this PR doesn't touch, which passed in the run below.maind187f09c93(clean) against thatmain, default relink, 60 s each,APS5_TRACE_HOST_IMPORT=1.main, Rush 2 Recompiled and Wave Race 64 Recompiled stop after 4.0 s withinitial multisampled DCC contents require watched guest memory.FMASK format is not implementedwhile a graphics shader is prepared (shader 0x20173e900 stage 5in Rush 2,shader 0x201743400 stage 5in Wave Race 64). That limit is the shader recompiler's:mainreads onlyFmask32_S8_F8, and #8429 reads the other FMASK formats of up to 8 samples.main06fd07ab4a: Rush 2 Recompiled and Wave Race 64 Recompiled get past the DCC refusal in all 8 runs and stop next atFMASK format is not implemented;main06fd07ab4astops at the DCC refusal.FMASK CMASK compression is implemented only for 8-sample, 8-fragment FMASK(shader 0x20173e900 stage 5in Rush 2,shader 0x201743400 stage 5in Wave Race 64), cold and warm.FMASK format is not implemented, with empty and with warm caches (Rush 2 Recompiled after 5.9 s and 1.4 s, Wave Race 64 Recompiled after 9.3 s and 1.4 s). No log has a[gpu] settling host imports ... failedline.main812ed15875(comment, comment, comment).main's settle code, the full suite reports synchronization hazards in 56 tests on the RTX 3060 Ti and 55 on Arc, mostly a main-queue copy writing what a settle copy on the other queue read. With #8527, those 58 tests pass with none.agc_import_settle_write_orderand_other_familypass 5 of 5 on both GPUs with and without its fix; only the layer shows the race without it. Of the 48 settle and import tests,agc_import_settle_first_usefails on the RTX 3060 Ti withmain's settle code and passes with #8527's.ctest -R 'import|settle|dcc|msaa|alpha_to_coverage|fmask|multisample': 74/74, 8 skipped.agc_import_settle_initial_dccwith them. There's nomainarm, because the new test runs only on a Windows GPU. The libc and libkernel suites pass on both, run withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners. The fix commit alone (16f5117426) also passed both runners ×10 (run).agc_import_settle_initial_dccandagc_driver_native_fmaskare in the selection but skip on llvmpipe: with the change 54 of 62 tests pass and 8 skip, and onmain54 of 61 pass and 7 skip; none fail. The layer loaded 60 times onmainand 61 with the change. Both logs report onlyVUID-VkDeviceCreateInfo-pNext-pNextandVUID-VkImageViewCreateInfo-usage-02275, so the change adds noVUID-message.check_conventions.py: passes. No comment lines are added.maine84c529d6d(clean; the PR's own diff is unchanged), on GitHub's runners:agc_write_tracking_metadata_commitfails on its 9th run with "an untouched leaf has a write stamp". That test's process runs onlyCheckMetadataCommit(--metadata-commitreturns before any other case) and makes no Vulkan device, so it reaches neitherRewatch, the one function this PR changes inGuestMemory.cpp, nor the settle code.maine84c529d6dalone (run) it andagc_write_trackingpass 60 of 60.mainagainst this head, on the Linux runner (run): 62 of 73 pass and 11 skip; the layer loaded 66 times onmainand 67 with the change, and both logs report onlyVUID-VkDeviceCreateInfo-pNext-pNext, so the change adds noVUID-message.agc_import_settle_initial_dccskips there, as on any device without the Windows deferred settle.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main83694b3db9against 67f68be9a8 merged onto it (clean), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1and the Khronos validation layer (vulkan-sdk-1.4.363.0), two runs each of the import, settle, FMASK, multisampled DCC, alpha-to-coverage and write-tracking set from this ask.main: 21 of 21 pass in both runs. With this PR: 25 of 25 in both runs.VUID-line.maindoesn't have ran on the GPU and passed, none skipped:agc_import_settle_initial_dcc,agc_write_tracking_rewatch_import_pages, and #8527'sagc_import_settle_write_orderand_other_family.c097fca028, a merge ofmain672c38f703, after adriadam10's rebase ontomain2ace103a9c, on GitHub's runners:docs/dev/debt/libSceAgcDriver.md. TheCompressed FMASK readsentry keeps this PR's clause on an FMASK import awaiting its Windows deferred read (WatchedAfterSettle), andmain'sMultisampled CMASK stateand newMultisampled DCC CMASK without fast clearsentries are kept as they are. In every other file the PR's diff has the same patch-id as before the merge.guest_raise_in_system_call, which also timed out onmain's own Windows Build (run, run); this PR changes nothing in libkernel. On this head it then passed 20 runs in a row, with the focused set ×20 (run): Linux: 69 run, 62 pass, 7 skip, 0 fail. Windows: 89 run, 10 pass, 79 skip, 0 fail, and both suites pass on both. The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.02f6f8e66f, a merge ofmain2fade7ef4e, on GitHub's runners:libSceAgcDriver/CMakeLists.txt, the write-tracking tests'ENVIRONMENT_MODIFICATIONline lists #9159'sagc_rewatched_direct_shared,agc_import_alias_sharedandagc_compared_shared_generationsas well as this PR'sagc_write_tracking_rewatch_import_pages. Intests/WriteTracking.cpp, both sides' mode constants, test functions and dispatch are kept. In every other file the PR's added and removed lines are unchanged.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.Overlap:
ea695358ee). This PR builds on its settle batch.initialDccClearand the FMASK checks. They compose with the settle first: a pending Windows settle returns the range to the watch, and anything still compared takes #9940's path.test/9724-both-main(6a9d64819f) is that resolution, and its focused set passes 77/77. Merge order: #9940 first.maincaa089fd73: clean.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)initial multisampled DCC contents require watched guest memory, as babyhuey's run shows; their next stop is an FMASK format (see Tested) (no Game bring-up discussion yet)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T05:33:16Z.
Review: CHANGES_REQUESTED
Reviewed the exact current head
f3eb5557ebbaa6afa0172177fd18d27ad76829a5, including the imported Queuse commits and the 256/257/1,025-import boundary regression. The newwhile (wanted())path submits another batch when one batch is full and waits/reaps when all device batches are busy; the PR reports red/green GPU runs for those counts. I found no issue in that specific batch-limit fix.This is still a draft and the title reproduction remains pending. Before this change is ready, please also refresh from current
main:check_main_sync.pyreports 9 ahead /353 behind and four touched files changed since merge base (CMakeLists.txt,Recorder.cpp,ARCHITECTURE.md,libSceAgcDriverdebt), although the merge is clean. Preserve the declared #8527/#9940 ordering and Queuse’s commit attribution.One validation gap: the touched behavior is Windows-only. The listed validation-layer comparison is llvmpipe/Linux, where the new Windows test skips; the RTX 3070 red/green runs are reported without the validation-layer/VUID comparison. CONTRIBUTING requires the focused AGC tests on main and the change with the Khronos layer and a VUID comparison. Please run that focused Windows test set on the same RTX 3070 with the required environment and
ctest -V, for both baseline and refreshed head, and report the layer-load confirmation and VUID delta. I could not rerun GPU tests on this host. This request is for required integration/validation and title evidence, not queue size.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:35:31Z.
Review: DISMISSED
The two new page-aligned rewatch commits address the partial-import tail visible in #9724. The added tests cover partial-block, unaligned, and adjacent imports, including checks that pages outside the settled import remain unwatched. I reviewed those changes and the exact diff is whitespace-clean.
This head still needs current-main integration evidence. Its merge base is
513ca7e558; it is 618 commits behind currentmain777bdbb4f8, with 11 commits ahead, and the branch changes the same AGC memory, write-tracking, test-registration and documentation areas. Please rebase the full stack while preserving #8527 and Queuse’s commit authorship, then rerun the focused Windows rewatch/multisampled-DCC tests on currentmainand the refreshed head with the required Khronos validation-layer comparison. The title reproduction is still listed as pending; after rebase, please run Rush 2 Recompiled (PPSA69423) and Wave Race 64 Recompiled (PPSA69424) on the refreshed head and report whether both pass the initial multisampled DCC stop. The current PR’s automatic product build jobs are skipped by policy, and I cannot dispatch the manual workflow from this account (GitHub returned 403 for an earlier PR dispatch). I am not treating the older-base evidence as validation of the current merge result.