feat(agc): expand a CMASK fast clear that matches the DCC clear of its target #13147
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/13147"
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 Prophet069 on 2026-10-30T04:15:59Z.
What
A CMASK fast clear of a color target that also has DCC keys threw
CMASK fast clear of a DCC color target, whose clear belongs in its DCC keys. When the target's current DCC keys are one clear whose texel equals the texelCB_COLOR_CLEAR_WORDencodes, both readings give the same texels, so the CMASK is now stored as expanded (0xF) without writing texels. Every other CMASK fast clear of a DCC target still throws, and the message now names the target address, size, element bytes, tile mode, samples, the number of cleared tiles, the DCC keys and the clear words. Whether the console's CB reads CMASK under DCC remains unknown (Mesa uses single-sample CMASK only without DCC on GFX10); the debt entry says so.Tested
ANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(VVL vulkan-sdk-1.4.321.0; neither log containswas not found but was requested by env var VK_INSTANCE_LAYERS),ctest --test-dir build -R <the 63 tests of agc_shader_memory_tests, agc_driver_cmask_fast_clear_tests, agc_driver_graphics_tests and agc_driver_sample_multisample_target_tests> -Von main8c8b998620and on this branch, same machine and GPU: main 63/63 passed, 0VUID-; this branch 63/63 passed, 0VUID-.CmaskFastClear.cppcovers the matching DCC clear (expanded, texels unchanged) and a mismatching one (throws with the details).0xc2de370000, 1920x1080, 4-byte elements, tile mode 27, 4 samples, 32400 of 32400 tiles cleared, DCC keys 0x00, clear words 0. With the change it reached 14800 dispatches (previously at most 1800) with no CMASK stop and 0VUID-, until an unrelated device loss after 1051 s.tools/check_conventions.pyreports onedebt-lengthwarning on the CMASK fast clear entry, which was already over 1000 characters on main.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-02T20:54:51Z.
Review: APPROVED
Reviewed — approved
The PR accepts a CMASK fast clear of a DCC target only when the DCC keys are one clear of the same texel as
CB_COLOR_CLEAR_WORD, and it throws a detailed message in every other case. The build is clean, the focused tests pass, the new test fails withmain'sDraw.cpp, and the validation comparison shows no new VUIDs.What I ran
Head
a29ca0375bd4d50d1cfab0a03e2229d17cc07814,main9090972b7e91fd266819cbd77a8b058e177b5682, merged tree69cd5cee0ad9afcf41fd4bd047ebcef0075b4e1f(Debian 13 VM, GCC 14.2.0, lavapipe Mesa 26.1.6).Results
git diff --checkcheck_conventions.pydebt-lengthwarning on the CMASK fast clears entry (1962 characters). The entry was already over the limit onmain, as the description says.libs(script)agc_driver_division, the denormal tests,unwrap_self,vector_constant_factor_tininess) also fail onmain.VUID-agc_driver_cmask_fast_clear,agc_recorder_cmaskgit status --porcelainemptyNegative control
I restored
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cppfrommainand rebuilt.agc_driver_cmask_fast_clearthen failed on the first new case:output with main's Draw.cpp
After I restored the merged file and rebuilt, the test passed again.
This failure also answers the first point in oneandonlydean's comment (that excluding DCC targets from the GPU path could make titles stop that get through today). On
main, the test's eliminate took the resident/recorder GPU path for the DCC target, and nothing was thrown in that call. That path never accepted a cleared tile of a DCC target, though. It calledDispatchCmaskClearwithwrite = color.dccAddress == 0(Draw.cpp:590). Withwritefalse,CmaskClear.comp:33-37setserrors.codes |= 1for each cleared tile, and the nextmaterializeCmaskClearthrows throughrequireCmaskCodes(Draw.cpp:510). The message is "a CMASK fast clear of a DCC color target, whose clear belongs in its DCC keys, was recorded", which is the stop mrfelek reported for PPSA02015 onmain.So on
main, the GPU branch only delayed the throw. Moving DCC targets to the CPU path (Draw.cpp:607) loses no case that worked before. The one difference is cost: a DCC target whose CMASK is already expanded now goes throughreadCmask, which may wait for a pending write to the CMASK. That happens once per target, becausecmaskProvedskips later calls.Findings
Blocking
None.
Non-blocking
DispatchCmaskClearis now always called withwrite == true, because its only caller needscolor.dccAddress == 0(Draw.cpp:590,Draw.cpp:607). As a result, theerrorsbranch ofCmaskClear.comp:37,TextureDetiler::CmaskErrorsandrequireCmaskCodes(Draw.cpp:510, with its DCC message) can no longer be reached. Suggestion: remove thewriteparameter, the error buffer andrequireCmaskCodesin a follow-up. Otherwise a reader may think a DCC target can still take the GPU path.Draw.cpp:623), the second point in oneandonlydean's comment. I confirm thatCurrentDccKeys(addr, bytes)readsDccKeyBytes(bytes), whilecolorKeyCountreturns the larger console extent for pipe-aligned 4-byte R64KBX targets. However, the same metadata pass then picks the target's texels from the same short read (Draw.cpp:3976, alsomaterializeRegisterClearatDraw.cpp:457). The new acceptance therefore agrees with what the pass already does, and the gap is not new. ReadingCurrentDccKeys(color.dccAddress, color.bytes, colorKeyCount(color, color.bytes))here would still be cheap and stricter, and it would be needed before the rest of the pass is extended to the full extent.docs/dev/debt/libSceAgcDriver.md:239still says "a cleared tile of a DCC target … throw", while the new sentence at the end of the same entry says a matching one is expanded. Suggestion: cut the earlier clause to "a cleared tile of a DCC target whose keys are not a matching clear". The CONTRIBUTING rules also ask entries to be cut rather than grown, and this entry is already flagged at 1962 characters.Not verified
Imported from boykopovar/AnyPS5. Originally posted by gabichuuuuu on 2026-11-08T15:31:20Z.
Review: COMMENTED
Ran
a29ca0375bmerged onmain302864d48con Windows 11 x64 (WinLibs GCC 15.2), on an NVIDIA laptop GPU (Turing, driver 621) and an Intel iGPU (driver 101.70xx), withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Khronos validation layer 1.4.368),ctest -R '^agc_driver_cmask_fast_clear' -V:mainmain+ only this PR'sCmaskFastClear.cppmainsince the branch point, so the middle column is the PR's own test onmain's code.was not found but was requested by env var VK_INSTANCE_LAYERS, and no log on either side has aVUID-, so the expanded clear draws without validation errors on either driver. To be sure validation messages reach these logs, the same layer with best practices on printed 28BestPractices-warnings into anagc_driver_recorderlog on each GPU.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-11-09T20:14:16Z.
Review: COMMENTED
Read at
a29ca0375bagainstmain. The match rule and the new message look right to me. One cost the change adds, inmaterializeCmaskClear(Draw.cpp):On
main, a DCC color target with a resident image, an import and the device lock takes the GPU path,recordCmaskClear. That path dispatchesDispatchCmaskClearwithcolor.dccAddress == 0as the last argument and notes the write as pending. A CMASK that earlier recorded GPU work wrote is read on the GPU, in order, with no CPU wait.With this head,
color.dccAddress == 0in the first condition sends every DCC target to the CPU path, including the common case where the CMASK is already expanded. There,readCmaskcallsrecorder->SyncThrough(address, bytes)wheneverPendingWriteOverlapsthe CMASK. So when a title clears its CMASK with its own compute kernel in the same submission, the first draw into that DCC target now waits for the recorder. If that happens every frame, it's a GPU sync in the middle of every frame.Two ways to keep the old cost:
A
Recorder::CountSyncreading from the PPSA02015 run,mainagainst this head, would show whether it matters there.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T06:53:51Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the matching-clear case is limited to DCC clear keys whose texel matches the CMASK clear value, and other cleared CMASK/DCC combinations still throw.
What I ran
Reviewed head
a29ca0375bd4d50d1cfab0a03e2229d17cc07814. I did not run commands or tests;repo_read.pywas unavailable as a shell command, so I used the provided review reader. The author reports 63/63 tests passed on main and this branch, and a Windows integration run reached 14,800 dispatches before an unrelated device loss.Read changed files:
core/libs/prx/libSceAgcDriver/Graphics/src/Draw.cpp(lines 365–475, 500–650, 3899–3945);core/libs/prx/libSceAgcDriver/tests/CmaskFastClear.cpp(full file);docs/dev/debt/libSceAgcDriver.md(lines 192–204). No changed files were excluded in the manifest.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
The reported test and integration runs were not independently reproduced. Console behavior when CMASK is read under DCC remains unverified, as the updated debt entry states.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T06:04:07Z.
Review: APPROVED
I read the diff at
a29ca0375b. Windows 11, GCC 15.2, merged intomainatcf556db18c3together with other open PRs (so not an isolated build), withANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1andVK_LAYER_KHRONOS_validationon an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).agc_driver_cmask_fast_clear: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has aVUID-orSYNC-HAZARDline.main's): fails on both GPUs: "a DCC target with a fast-cleared CMASK tile: was not refused".Not checked: a title.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:54:29Z.
Review: COMMENTED
The DCC clear comparison preserves the existing refusal for a different clear color. The fixture checks that refusal and also covers both a whole CMASK clear and a partial clear when the colors match. Could the refusal check also snapshot and compare both metadata regions across the failed eliminate? That would catch moving the CMASK write ahead of the DCC equality check. The trial merge is clean. Please put the debt update in a fragment in
docs/dev/debt/changes/. I have no paired Vulkan result for this head yet.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.