fix(agc): accept a compared host import for an initial multisampled DCC import #9940
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9940"
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:06Z.
What
Rush 2 Recompiled (PPSA69423) and Wave Race 64 Recompiled (PPSA69424) stop at their first multisampled DCC target with
AGC graphics: initial multisampled DCC contents require watched guest memory(#9724). On Linux, babyhuey saw it with lavapipe onmain8b3a6ba88: Rush 2 at 6.4 s, Wave Race 64 at 1.5 s (comment).Why Linux refuses. Linux has no deferred settle. When the write-watch probe finds that host imports lose their write protection, it compares every import instead of watching it. The probe then logs
[write-watch] host imports resolve write protection: yes (…); imported ranges are compared.initialDccCleartakes a write generation of the color, DCC and CMASK ranges and requires each one to be watched. So a target in such an import is refused at its first use.MarcZX10 asked to keep the reproductions split by that probe result (comment). This PR is his case (2), Linux comparison mode. The Windows case (1), a watched import whose deferred settle is still pending, is #9941.
The change:
ComparedHostImportCovers(context, address, bytes): true when a live host import marked unwatched covers the whole range. It returns false on Windows, so nothing changes there.initialDccClear: a range that isn't watched but lies in such an import is read once and kept as a copy, withNewestStamptaken after the read. Watched ranges take their generation as before.checkDccCurrenton reuse: a compared range is current while itsNewestStampis unchanged and its bytes equal the copy (EqualsCommittedUnsynced).ForgetSerialof the last equal compare.writes to a resident multisampled DCC target or its metadata are not implemented, and the pending-write refusal.absorbDccFill: compared metadata takes the landed key bytes of a whole fill as its new copy.use.samples == 8u), so this commit doesn't change them.GuestMemory::Unwatch;What a compared range can't see: a guest CPU store of the bytes already there. That is comparison mode's general limit, and the storage-texture compare has it too. A driver or GPU store into the range's 64 KiB blocks counts as a change through
NewestStamp, same-value stores included. The debt entry says both.Cost. Each use of a resident target with compared ranges takes one
NewestStampper compared range and at most one memcmp per range per collect epoch. That replaces a refusal at the first draw. memcmp on a cloud Xeon at 2.80 GHz:The memory cost is one copy of each compared range. A cheaper current check, such as a hash per 64 KiB block, would be follow-up work.
Commits:
fix(agc): accept a compared host import for an initial multisampled DCC import. It is on amainthat has #7948, soRecreatekeeps both resets, and the end ofinitialDccClearkeeps #7948's FMASK check.fix(agc): accept a compared host import for a multisampled target's FMASK range.test(agc): skip the watched-import control case where imports report pages written(test only). Mode 5 forces the planes' imports to stay watched, as a control. On a device whose probe reports watched pages written at the import or after a GPU read, the watched planes see those writes and the reuse check refuses, so mode 5 now runs only where the probe reports neither, the condition #10138 uses for the forced-watch shadow tests.docs(debt): shorten the native multisampled DCC fast clear entry(docs only): the entry is under the 1,000-character limit, with the same cases.Tested
agc_driver_msaa_dcc_compared_import_{2,4,8}(new,DccComparedImportTestsintests/execution/AlphaToCoverage.cpp).NewestStampUnwatched, nothing importedmainmain, passesUnwatchedDccRefillTestsmode 6, a metadata fill in forced comparison mode, used to expectrequires watched guest memory. It now expects the fill to clear the target.DccFastClearTestsmode 4 (an explicitUnwatchover the DCC metadata) is unchanged. It refuses on both trees.ANYPS5_REQUIRE_VULKAN=1 GALLIUM_OVERRIDE_CPU_CAPS=avx):main's product files with the new tests:compared_import_2,_4and_8fail with the title's text.msaa_dcc_clear_4fails withmultisampled DCC target reuse requires watched guest memory(the refill case)._4andclear_4pass, 20/20 each with--repeat until-fail:20. The 2- and 8-sample tests skip, because lavapipe renders color only at 1 and 4 samples._8fails withnative FMASK contents require watched guest memory.ComparedHostImportCoversin the FMASK check fails mode 11.agc_driver_native_fmask, which skips for the same reason.ctest -R 'msaa|dcc|fmask|multisample': 38/38, 6 skipped for sample counts.main's product files (compared_import_2,_4and_8fail), and green ×10 (13 tests; 5 skip on lavapipe for their sample counts). The libc and libkernel suites pass on Linux. On Windows it builds and passes ×10, and its Vulkan tests skip.guest_raise_in_system_callfailed on both arms, with and without this PR. It also timed out twice onmain's own Windows Build today (run, run). This PR changes nothing in libkernel.APS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.main, green ×10, suites pass; Windows builds, its Vulkan tests skip, suites pass.agc_driver_msaa_dcc_compared_import_4and_8,agc_driver_msaa_dcc_clear_4,agc_driver_sample_multisample_targetandagc_driver_native_fmask, one run on each tree. With the change,agc_driver_msaa_dcc_compared_import_4,agc_driver_msaa_dcc_clear_4andagc_driver_sample_multisample_targetpass, andagc_driver_msaa_dcc_compared_import_8andagc_driver_native_fmaskskip on llvmpipe.main's tree has three of the five:agc_driver_msaa_dcc_clear_4andagc_driver_sample_multisample_targetpass andagc_driver_native_fmaskskips. None fail. The layer loaded 3 times onmainand 5 with the change. Both logs report onlyVUID-VkDeviceCreateInfo-pNext-pNext, so the change adds noVUID-message.VUID-VkDeviceCreateInfo-pNext-pNext, on both arms.main895f47f4eeand on thatmainwith this head merged. Both arms logimported ranges are compared.initial multisampled DCC contents require watched guest memoryonmain.the device cannot render color with the target's sample count. That is lavapipe's limit: it renders color only at 1 and 4 samples.[write-watch] host imports of write-watched memory keep the write watch: yes.agc_driver_msaa_dcc_stateandagc_driver_msaa_dcc_clear_2,_4and_8pass.agc_driver_msaa_dcc_compared_import_2,_4and_8skip with their Linux-only message, as this PR intends on Windows.maineb8dcfebaa,ctest -R 'msaa|dcc|fmask|multisample', three runs without and three with the Khronos validation layer (1.4.341). The probe picks comparison mode there, with pages reported written at the import and after a GPU read.main: 35 of 35 pass in every run. 0c1f6b5571: 35 of 38, withagc_driver_msaa_dcc_compared_import_2,_4and_8failing in every run, in mode 5 alone, withwrites to a resident multisampled DCC target or its metadata are not implemented. With mode 5 skipped in a local edit, all three pass at 2, 4 and 8 samples, so the compared-import path holds on RADV.VUID-line.msaa|dcc|fmask|multisampleset's 38 tests, 32 pass 10 runs in a row and 6 skip for sample counts (agc_driver_msaa_dcc_compared_import_4passes;_2and_8skip); none fail. On Windows, 5 pass 10 runs in a row and 33 skip without a Vulkan device. 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. GitHub's runners can't show the red: it needs a device whose probe reports those writes, as the 860M's does.agc_driver_msaa_dcc_compared_import_2,_4and_8print the control-case skip line and then pass, with all five FMASK cases at 8 samples. On lavapipe on the same machine (Mesa 26.2.5),_4and_8pass without that line, so mode 5 still runs there, and_2skips for the sample count. The layer loaded in every run, and no run logs aVUID-line.main15e71dbe11(clean) and compared with thatmainon the same machine; Windows 11 Pro, WinLibs GCC 15.2.0, Release,ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1, with the Khronos validation layer (1.4.363) loaded; the 1,282 teststools/select_tests.pypicks for this diff.main, the only difference on each GPU is the 3 new tests, which skip.agc_driver_msaa_dcc_compared_import_2,_4and_8skip on both GPUs with their "Linux comparison mode only" text, as intended.agc_driver_alpha_to_coverageincluded, and the validation messages are the same asmain's on both GPUs. The failures fail onmaintoo: theagc_driver_sample_ordertrio on NVIDIA (#9056), andagc_storage_write_backandagc_driver_multisample_retirementon Intel.check_conventions.py: passes with no warning: the fourth commit shortens the multisampled DCC debt entry from 1,585 characters to 970, under the 1,000 limit. No comment lines are added.main672c38f703, after adriadam10's review (review): the four commits were replayed onmainwith no merge: 27371e9b16 → ff167c39c9, 0c1f6b5571 → 1fc53abf64, 54e2b57a66 → 0045c937eb, 4df08139c0 → e2449e2ddb.MultisampleTarget.cppas the earlier merge did. e2449e2ddb's tree is identical to that merge of 4df08139c0 withmain672c38f703, and it merges cleanly withmain00198bfcdf.main'sMultisampled CMASK stateandMultisampled DCC CMASK without fast clearsentries as they are. This PR changes only theNative multisampled DCC fast clearsentry (970 characters) and theCompressed FMASK readsentry (watched or compared planes).python3 tools/check_conventions.py --base origin/mainpasses againstmain00198bfcdf.^agc_driver_msaa_dcc_withagc_driver_native_fmask,agc_driver_sample_multisample_target,agc_driver_sample_order,agc_driver_multisample_retirementandagc_storage_write_back, ×10 on that tree (run): Linux: 12 run, 7 pass, 5 skip (agc_driver_native_fmaskand the 2- and 8-sample cases, for lavapipe's sample counts), 0 fail. Windows: 12 run, 1 pass (agc_driver_msaa_dcc_state), 11 skip (no Vulkan device), 0 fail. 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.Overlap:
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 this path.test/9724-both-main(6a9d64819f) is that resolution, and itsimport|settle|dcc|msaa|alpha_to_coverage|fmask|multisampleset passes 77/77. Merge order: this PR first.tests/Recorder.cppconflict is withmain. This PR doesn't touch that file.maincaa089fd73: clean.mainacbfd7c7fe(run).mainnow has #9941, which reads the initial multisampled DCC ranges and the native FMASK throughWatchedAfterSettle, settling a pending Windows import first. This PR's compared-import checks now askWatchedAfterSettlebefore falling back to a compared host import: Linux keeps the compared copies (the settle is Windows only) and Windows keeps #9941's settle (there are no compared imports there). The debt entry keeps both sentences. The DCC, FMASK, import-settle and host-import tests ran 10 times in a row. Linux: 15 run, 9 pass, 6 skip (the 2- and 8-sample cases, as lavapipe has no 2- or 8-sample colour, andagc_driver_native_fmaskandagc_import_settle_initial_dcc, which skip on that runner as in earlier runs), 0 fail; the before arm fails the 4-sample compared-import and clear cases. Windows: 24 run, 1 pass, 23 skip (no Vulkan device), 0 fail. Suites: libc and libkernel pass on Linux (144 and 207) and on Windows (171 and 223). The suites ran withAPS5_SKIP_TIMING_TESTS=1, which relaxesprecise_wait's median bounds on GitHub's hosted runners.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(babyhuey's lavapipe runs; their next stop there is lavapipe's sample-count limit)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:37:34Z.
Review: DISMISSED
The Linux compared-import approach is distinct from #9941’s pending-Windows-settle path, and the branch declares the intended order (this PR before #9941). Its reported lavapipe title runs and test comparison are useful for that older tree.
I cannot approve the current integration yet. The merge base is
eb8dcfebaa; this head is 618 commits behind currentmain777bdbb4f8(3 commits ahead). Since that base, currentmainhas changed the same AGC integration paths: 511 lines inGuestBufferMemory.cpp, 119 in the AGC CMake registrations, and 18 inGuestBufferMemory.hpp, along with the debt index. Please rebase and preserve the declared ordering before #9941, then rerun the focused comparison-mode/MSAA DCC tests on currentmainand the refreshed head and recheck the combined tree. The current PR’s product jobs are skipped by policy, so I am relying only on the test runs actually reported in its description for the old base.One convention warning also remains: the multisampled DCC debt entry is 1,585 characters (the prior main entry was 1,232). Please trim it to the unresolved behavior and assumptions so the refreshed conventions check no longer reports the debt-length warning.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-24T10:13:50Z.
Review: CHANGES_REQUESTED
mainmoved and this PR now conflicts with it, only indocs/dev/debt/libSceAgcDriver.md. The code inMultisampleTarget.cpp,GuestBufferMemory.*and the CMake merges cleanly, but replaying the commits one by one stops inMultisampleTarget.cpp(the #7948 merge commit is now part ofmain), so please update the branch againstmainyourself, with a single linear history.Resolution for the debt file:
main'sMultisampled CMASK stateentry as it is (it now lists the 0xcccccccc/0xdddddddd/0xeeeeeeee/0xffffffff patterns; this PR doesn't touch it);main's newMultisampled DCC CMASK without fast clearsentry;Compressed FMASK readsentry (watched or compared planes).Then re-run
python3 tools/check_conventions.py --base origin/main(the DCC entry must stay under 1,000 characters) and the focused tests on the rebased tree.@MarcZX10 your three requests on
0c1f6b5571look addressed at4df08139c0(debt entry 970 characters, RADV 860M 38/38, Windows RTX 3060 Ti / Arc againstmain). Could you re-review once the author pushes the rebased branch?Imported from boykopovar/AnyPS5. Originally posted by ahmadmuj on 2026-10-25T17:22:37Z.
Review: APPROVED
Reviewed head
438a4438c3merged onto mainb4d8e8bb3b(clean merge). Main is now7e4f6e0440; that also merges clean, and its only AGC change since (#10369) is behind#ifdef __APPLE__, so Linux behaves the same. Linux x86_64 (WSL2), GCC 13.3, Release, lavapipe (llvmpipe, LLVM 20.1.2). The probe here logsimported ranges are compared, so this machine takes the new path.What I ran:
ctest -R 'msaa|dcc|fmask|multisample|import_settle|host_import'withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1: 50/50 pass, 8 of them skip (the 2- and 8-sample cases,agc_driver_native_fmask,agc_import_settle_initial_dcc,agc_host_import_sparse,agc_driver_multisample_centered_lines). Same withVK_LAYER_KHRONOS_validation; the only VUID isVUID-VkDeviceCreateInfo-pNext-pNextat device creation.-R msaa_dcc --repeat until-fail:10: 7/7.MultisampleTarget.cppandGuestBufferMemory.{cpp,hpp}:compared_import_2,_4and_8fail withinitial multisampled DCC contents require watched guest memory, andclear_4fails withmultisampled DCC target reuse requires watched guest memory. Back to the PR: all pass.--to-intel. Release ZIPs from the homebrew catalog, sha256 matched against its records: Rush 2 Recompiled (PPSA69423, 00.003.000) and Wave Race 64 Recompiled (PPSA69424, 00.001.000).initial multisampled DCC contents require watched guest memorythe device cannot render color with the target's sample countSo babyhuey's result holds on this head and current main; the next stop is lavapipe's sample-count limit.
tools/check_conventions.py --base b4d8e8bb3b: pass.Code walk of the #9941 merge:
WatchedAfterSettlecalls from #9941 still run before the compared check: initial ranges, initial FMASK, FMASK reuse. On WindowsComparedHostImportCoversreturns false, so each one is main's settle-then-require-watched. On LinuxWatchedAfterSettleis justGuestMemory::Watched, so the compared paths are the same as ate2449e2ddb.checkDccCurrentandabsorbDccFillkeep plainWatchedfor the color and metadata, as main does.ComparedHostImportCoversneeds one import that covers the whole range (peekImport) withunwatchedset, andunwatchedis only set when the import succeeded.copyCurrentafter the import always runs the full compare (checkedstarts empty), so a store between the read and theNewestStampis still caught.Not checked: 2- and 8-sample color (lavapipe has 1 and 4), so the FMASK reuse and modes 9 and 10 didn't run here. No Windows, no real GPU, and nothing past the titles' sample-count stop.