fix(agc): materialise cold native FMASK pages before tracking #25867
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/25867"
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-22T19:38:20Z.
What
A resident multisampled DCC target with native FMASK takes the FMASK range's write generation when it is created (
initialDccClear). On Windows, guest pages that are committed but never touched are known-zero. When such FMASK pages were touched for the first time after that generation was taken (an overlapping watched import, or any read), write watch reported every one of them as stored, and the next reuse of the target threwwrites to a resident native FMASK are not implementedalthough nothing had written the bytes.Texture imports already materialise known-zero pages before they track them (
Texture.cpp); #20534 does the same for the DCC color range of this function. The FMASK range now callsGuestMemory::MaterializeKnownZerobeforeCollectWritesUncached, so only real stores to it refuse.Changes
core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp: materialise the FMASK range's known-zero pages before taking its write generation.core/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cpp,tests/cmake/agc_driver_sample_multisample_target_tests.cmake:agc_driver_cold_native_fmask_{2,8}. A resident 2- or 8-sample DCC target with CMASK and native FMASK whose FMASK pages were never touched stays reusable after an overlapping watched import of those pages, and a real zero or nonzero store to the FMASK still refuses.Blocktakes aninitialiseflag so a test can keep its pages untouched.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,
main66668ebb8b.Focused set (
agc_driver_graphics,agc_shader_memory,agc_driver_native_fmask_*,agc_driver_cold_native_fmask_*,agc_driver_fmask_*,agc_driver_msaa_*,agc_driver_multisample*,agc_driver_native_multisample*,agc_driver_native_color*,agc_driver_native_msaa*,agc_driver_sampled_cache*,image_msaa*) withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1,VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(1.4.363) andVK_LOADER_DEBUG=layer:main66668ebb8bagc_driver_cold_native_fmask_2,_8)VUID-linesWithout the fix (
main'sMultisampleTarget.cppwith this branch's test):--cold-native-fmask 2fails withAGC graphics: writes to a resident native FMASK are not implemented (FMASK range 0x200060000+0x10000, 2 samples), and--cold-native-fmask 8with the same message for 8 samples.Forza Horizon 5 (PPSA22327 01.685.672), local stack of open PRs (#21155, #21479, #22306, #23545, #21199 and others) without this change:
0xd1f72d0000+0x80000, of which only the 64 pages that were known-zero when the target was created read back as stored. All of their bytes were zero, and no driver or host write had touched them.py -3 tools/check_conventions.py --base origin/mainandpy -3 tools/debt_fold.py --checkpass.py -3 tools/pr_overlap.py --branch fix/agc-materialize-cold-native-fmask(2,355 open PRs): #21155 conflicts with this change only in the test helperBlock, because it adds the sameinitialiseparameter (from #20534); whichever merges second keeps one copy. Eleven PRs that conflict withmainwere searched by hand; only #20534 and #21155 touch this function, on the DCC color range, not on FMASK.Not tested: 4-sample FMASK on
main(native 4-sample FMASK is #23545; Forza covered it on the local stack), FMASK pages inside an already imported resident run (the committed-page case #21155 handles for color), other GPUs, Linux (MaterializeKnownZerodoes nothing there), console behaviour.Rebased onto
mainf220c22162(394 commits, none touching the files this PR changes, no conflicts). On the rebased commitcheck_conventionsanddebt_fold --checkpass. All eight PRs merged together onf220c22162, the focused tests of all eight with the same environment:main182 passed / 0 failed, validation layer inserted 242 times, 0VUID-lines; the eight together 188 passed / 0 failed (the six new tests added), inserted 250 times, 0VUID-lines.Related
Part of the Forza Horizon 5 (PPSA22327) bring-up, #25152. The game hits these stops one after another, so these PRs were found and tested together on one stack: the other open PRs the game needs (#24960, #24994, #25151, #23688, #23545, #21479, #11825, #23778, #21155, #22306, #21199) plus the PRs below. Each one stands alone: it applies to
mainby itself, needs none of the others to build or pass its tests, and merges cleanly with every other one.fix/agc-multisample-read-single-sample-depth: multisampled read over a single-sample depth surfacefix/agc-claim-retires-memory-backed-msaa-copy: memory-backed multisampled copy treated as a host-only aliasfix/agc-skip-no-op-htile-hiz-patch: HTILE Hi-Z patch dispatch that writes nothingfix/agc-sample-htile-stencil-after-expand: stencil kept in HTILE read without metadata after an expandfix/agc-expanded-after-whole-depth-publication: a whole native depth publication taken as an expandfix/agc-htile-clear-supersedes-plane-writes: plane writes before a whole HTILE clearfix/agc-read-unwritten-htile-stencil-from-memory: stencil plane read from memory for an unwritten native targetChecklist
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 mihiii1337 on 2026-11-22T19:50:06Z.
Review: CHANGES_REQUESTED
I reproduced a blocking Linux CI failure on exact head
1dece71a02547bb24d0cede32a9bf027cd9bb5d4.Ubuntu 24.04, GCC 13.3 Release, software llvmpipe (LLVM 20.1.2) advertises framebuffer color sample counts 1x and 4x, not 2x or 8x. I built
agc_driver_sample_multisample_target_testsand ran the two existing native-FMASK controls and the two new cold-FMASK cases with forced Vulkan, no shader cache, and Khronos Validation 1.4.363 inserted.All four processes returned skip code 77, so CTest exited 0. The existing
agc_driver_native_fmask_2and_8cases print the recognized unsupported-sample reason and pass the job's skip policy. The newagc_driver_cold_native_fmask_2and_8cases return 77 without a recognized reason. On the exact resulting JUnit file:The checker exits 1. The
userfaultfdfallback is present in every process but is not the reason these cases skip; the sample-count guard returns first. Khronos was loaded and there were no missing-layer messages, VUIDs or synchronization diagnostics.Please print the same recognized unsupported-sample reason as the existing native-FMASK path before the new return-77 branch, or limit registration to a platform where the production behavior is applicable. If the cases remain cross-platform, a device that supports 2x/8x but lacks write watch may need a separate availability skip; I am testing that configuration independently rather than claiming it from this run.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T20:24:01Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and tests support merging.
What I ran
Reviewed head
56764e605e9b4cf7ff675de7d1aa0d9ca6ed49a2. I did not run commands or tests; I inspected the prepared diff and read the changed files and theMaterializeKnownZeroimplementation throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No build or tests were run. Hardware, console behavior, Linux behavior, and the four-sample case on
mainwere not verified. The description reports Windows 11 and RX 6800 test results, but these were not run as part of this review.review/files.jsonwas unavailable; all three entries markedincluded: trueinreview/manifest.jsonwere read.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by mihiii1337 on 2026-11-22T20:39:12Z.
Review: APPROVED
The requested test-availability fixes are resolved on exact head
a4634a9b6489d56a7b624d729523fee86699abc6.I replayed the cold native-FMASK 2x and 8x cases on the RTX 4070 Laptop (
10de:2860, NVIDIA 621.01). Both default runs reached their full success marker and passed. WithAPS5_NO_WRITE_WATCH=1, both now return the recognized compared-not-watched skip instead of failing in the watched block constructor; CTest and the Windows skip-policy check both exit 0.On Ubuntu 24.04 with pinned llvmpipe (subgroup 8), all four native/cold 2x/8x cases report the expected unsupported-sample reason. CTest and
check_skips.py --job linux --require-testsboth exit 0.Khronos Validation 1.4.369 was inserted in all four Windows invocations and 1.4.363 in all four Linux invocations. There were no missing-layer messages, VUIDs, or synchronization diagnostics. Static review also confirms the new preflight is before every watched block allocation while the post-import transition check remains in place.
AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-22T22:29:26Z.
Review: COMMENTED
Reviewed — no blocking findings
The targeted code supports the stated fix, but the review is incomplete because I did not read every changed file in full or run the tests.
What I ran
Reviewed head
a4634a9b6489d56a7b624d729523fee86699abc6. I inspected the prepared description, commits, manifest and diff, plus relevant source ranges and references for known-zero materialization. No commands or tests were run; the author-reported test results were not independently verified.Results
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Sources
The prepared diff adds known-zero materialization before collecting the native FMASK write generation (
MultisampleTarget.cpp:1115) and adds cold-FMASK tests for overlapping imports and real stores (SampleMultisampleTarget.cpp:2087-2127). The existing texture upload path also materializes known-zero pages before collecting writes.Not verified
I read the prepared
description.md,commits.md,manifest.json, anddiff.patch. From changed files, I read the relevant ranges inMultisampleTarget.cpp,SampleMultisampleTarget.cpp, andagc_driver_sample_multisample_target_tests.cmake; I did not read their full text. I also inspected relevant ranges inGuestMemory.cppandTexture.cpp. The manifest marks all three changed files as included; no changed files were excluded by the manifest. Tests, prechecks, 4-sample behavior on main, other GPUs, Linux behavior, and console behavior were not independently verified.To get this to a good state
Nothing is required. Optional: complete full-file review and run the focused tests and prechecks on this head.