fix(agc): read a multisampled target's CMASK by its MSAA codes #6669
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6669"
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 milescoviello on 2026-10-16T03:34:54Z.
What
A multisampled color target with a CMASK fast clear (
CB_COLOR_INFO.FAST_CLEAR) seeds its CMASK state when it is first used, and fills of its CMASK update it later.mainreads those bytes as DCC keys:0x00is a fast clear,0xffis uncompressed, and anything else is refused:An MSAA CMASK nibble is not a DCC key, though. It is
fmask | color << 2(MesaCMASK_MSAA_CODE):main0x00FMASK_CLEAR_0_COLOR_CLEAR_REG0xccFMASK_CLEAR_0_COLOR_EXPANDED0xdd,0xeeFMASK_UNCOMPRESSED_COLOR_EXPANDED0xffFMASK_UNCOMPRESSED_COLOR_EXPANDEDSo a CMASK whose color is expanded, with no fast clear pending, is refused unless it happens to be the 8x code. The host image of a multisampled target starts cleared to zero. A uniform fill of its color memory can give it a clear value, but it never reads other guest color data. "No fast clear" is therefore what
0xffalready does, whatever the FMASK code.Ruffle (PPSA68091) clears its target's CMASK to
0xccevery frame, with a compute dispatch. Onmainthat dispatch is address-based, so the target's first use usually reads the CMASK before the clear has landed, sees zeros and runs. When the clear landed first, it stopped on the line above, in 2 of my 6 earlier sweep runs on oldermainbuilds (11 to 12 s in). #6543 runs that kernel as a buffer fill, so the clear is always ordered before the read, and Ruffle then stops there every time.The seed now reads the uniform CMASK byte, after pending writes as the key read does (
CurrentUniformMetadataByte). The seed and CMASK fills both classify it withMultisampledCmaskKeys.Tested
Linux (Ubuntu 24.04, GCC 13.3, Release), RTX 4070 Ti, NVIDIA 595.99.
agc_driver_graphics: seeds and whole-CMASK fills of0xcc,0xdd,0xeeand0xffgive no fast clear,0x00still clears once, and0x11,0x33,0x44,0x88,0xcd, an uneven pattern and an unknown (mixed) seed are refused. Withmain's fill classification the test fails ona fill of the CMASK ... with 0xcccccccc leaves its tiles mixed. It passes 3 of 3 with this change.^agc_driver_|^agc_vertex_barrier|recompiler|shader_cache|request_serializer|spirv, 469 tests), with this change plus a local match of the same fill kernel, which I'm not opening since #6543 has it: 468 pass.agc_driver_store_over_untrackedfails the same way onmain5d9dcc42d; #6385 addresses it.Ruffle (PPSA68091), 60 s with scripted pad input, three runs each:
main5d9dcc42d2fc4fe5e0)@Amoenus checked this PR together with #5939 and #6543 on
main5d9dcc42d. The one conflict, inMultisampleTarget::acquire, resolves by keeping #5939's guard argument and DCC exclusion along with this PR's raw CMASK reader. On Windows they ran the MSAA DCC, fill and sample tests on an RTX 5080 (610.62) and an AMD Radeon iGPU, 70 processes passing, and on Linux with llvmpipe 20 processes passing. Their test commit, c8950bb7c (cherry-picked with their authorship), enumerates all 256 uniform CMASK bytes: 00 is a clear, cc/dd/ee/ff are expanded, and the other 251 are unmodeled. It passes 3 of 3 here.@screamm reproduced the Ruffle table on Windows (RTX 4070, NVIDIA 596.21) with #6543 on
main5d9dcc42d.mainruns to the 125 s limit 3 of 3. With #6543, Ruffle stops 2 of 2 on the CMASK line as the demo starts. With #6543 and this PR, 2 of 2 run to the limit. vkQuake (PPSA99010) with both also runs to the limit 2 of 2. The tests pass 3 of 3, and fail withMultisampledCmaskKeysset back tomain's codes.Update after #5939 merged: Ruffle's target carries DCC, so on current
mainthe title stops earlier, as the demo starts, on #5939'smultisampled DCC CMASK compression or register clear is not implemented. That happens with or without this PR, and the seed this PR changes (dccAddress == 0) is not reached. @screamm's recheck on Windows shows this. So the Ruffle table above predates #5939 and no longer applies; theagc_driver_graphicsandagc_driver_covered_centroid_statechecks above still cover the change, and pass 3 of 3 there.Not checked on Intel or on a console.
#5939 changes the seed line, adding a DCC condition, and #6215 changes the lines next to it. Whichever lands second needs a small rebase.
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)main(Ruffle stops earlier since #5939; see Tested)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T04:34:51Z.
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/DccMetadata.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppImported from boykopovar/AnyPS5. Originally posted by Amoenus on 2026-10-16T07:43:42Z.
Independent component check of #5939 + #6543 + this PR, on main
5d9dcc42d2ec5401aebd089028b8d4d7410a77b4:Merge: composition 13ed9df uses #5939
3851b712c, #65432fc4fe5e0, this head5fb0245a6, and separate #6452 for Windows test-build alignment. There was one conflict inMultisampleTarget::acquire. The combined resolution preserves both the fourth guard argument/DCC exclusion from #5939 and the raw CMASK reader/SeedCode from this PR:Windows: full application/libs build, library/convention/test-registration checks pass. Five repetitions each of CPU groups
agc_driver_graphicsandagc_driver_msaa_dcc_state, plus five repetitions per physical GPU ofagc_driver_msaa_dcc_clear_2,_4,_8,agc_driver_clamped_global_fill,agc_driver_multisample_fill_host_only, andagc_driver_sample_multisample_target: 70 passing processes, no skips/timeouts, maximum 5.02 seconds. All six runtime groups' device-selection logs confirm NVIDIA RTX 5080 (10de:2c02, driver 610.62) and AMD Radeon(TM) Graphics (1002:13c0, driver 32.0.21036.18), Windows 11 Enterprise 10.0.26200. CPU groups are not GPU coverage.Small optional test addition: 036b7f0 adds only seven lines to the existing graphics fixture. It enumerates all 256 byte values, expecting 00 as clear, cc/dd/ee/ff as expanded and the other 251 inputs as unmodeled. Its patch also applies cleanly to your original
5fb0245a6head, independently checked with a temporary index; you can cherry-pick the test commit without the composition commits.The expanded fixture passed five Windows processes, failed five times at input 204/0xcc with a narrowed-classification control, then passed five times after restoring the exact positive head. The control retains the new reader/API and only narrows expanded recognition back to ff; it is not unmodified main. This checks the proposed classifier contract, not hardware semantics for every possible CMASK state.
Linux: at test head
036b7f0, selected targets build on Ubuntu 24.04/WSL2, GCC 13.3.graphics,msaa_dcc_state,msaa_dcc_clear_4, andclamped_global_filleach pass five repetitions: 20 processes, no skips, maximum 3.29 seconds. Runtime selections confirm Mesa 25.2.8 llvmpipe, LLVM 20.1.2; 2x/8x hardware coverage remains the Windows result. This is not a full Linux application build.Cppcheck 2.20.0 then clang-tidy 23.1.3 completed for
MultisampleTarget.cpp,DccMetadata.cpp, andtests/Graphics.cpp(53.13 seconds; no timeouts/parser failures). Clang-tidy has no selected diagnostics. Cppcheck retains four warnings at locations unchanged by this PR: recorder/batch null-check reasoning and three fixture pass-by-value advisories. The recorder-null branch constructs its batch before dereference; no unrelated source rewrites or suppressions were made.This confirms the component combination and preserves the DCC exclusion; it does not independently reproduce Ruffle, Rush 2, Wave Race or Sonic. The resident-target/metadata-write refusal is unchanged. AI-assisted validation/test/report: yes.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T08:00:41Z.
Thanks @Amoenus, for the combination check and for the test. I cherry-picked 036b7f0 as c8950bb7c with your authorship, and it passes 3 of 3 here. Your Windows and llvmpipe runs are in the description now.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-16T08:33:41Z.
Windows cross-check on
main5d9dcc42dwith #6543 (2fc4fe5e0) and this PR (5fb0245a6) merged on top, no conflicts. Windows 11 Pro 26220, RTX 4070, NVIDIA 596.21, WinLibs GCC 15.2.0, Release. Titles relinked per run, 125 s limit.Ruffle (PPSA68091), Cross pressed at 8, 11 and 14 s ("Play the demo"):
mainwhat(): AGC graphics: the CMASK 0x4004600000 of a multisampled color target reads as mixed, which is not modeledSo your Linux table reproduces on Windows/NVIDIA. With both, the demo's presents match
main's (on this busy host the demo runs at about 4 fps and presents black onmainas well, unrelated to either PR). vkQuake (PPSA99010) with both runs to the limit 2 of 2 with 0 of 500 black dumps, against 48 and 53 onmain.Tests:
agc_driver_graphicsandagc_driver_covered_centroid_state3 of 3. WithMultisampledCmaskKeyschanged back tomain's codes (only0xffas expanded) both fail onthe CMASK 0x30000 of a multisampled color target reads as code 0xcc, which is not modeled, and pass again restored. 12 relatedagc_driver_tests (fills, DCC keys, CMASK, multisample) pass 3 of 3 on the stack;agc_driver_store_over_untrackedis flaky here onmaintoo (46 of 65 onmain, 23 of 45 on the stack, 13 vs 12 of 20 interleaved). Non-GPU suite on the stack: 834 of 837, 2 skipped,hardware_oracle_comparetimed out once at its 20 s limit and passed on rerun.check_conventions.pyandgit diff --checkclean.The head moved to
c8950bb7cwhile I ran this; the only new commit is the testcheck all uniform MSAA CMASK byte codes, which I did not run.Not checked: this PR without #6543 on a title, AMD or Intel, Linux, the full GPU
agc_driver_suite, the merge with #5939 or #6215.Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T08:37:46Z.
Thanks @screamm, good to have the Ruffle result on Windows too. I added it to the description.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-16T23:13:56Z.
Rebased onto
main40255d774b(e54508dffa, 8455a5cceb). #5939'sa0c51d5778(uniform multisampled DCC fast clears) changed the same line inacquire. I kept its form: the CMASK seed now runs only when the target has no DCC (use.cmaskFastClear && use.dccAddress == 0), and passescreated.metadataValidtoguard.MultisampledDccClearalready reads the CMASK byte with the same expanded codes (0xcc, or 0xdd/0xee/0xff by sample count), so the DCC path is unchanged.agc_driver_graphicspasses. The 905 area tests pass exceptagc_driver_store_over_untracked, which fails onmainas well.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by screamm on 2026-10-17T10:07:48Z.
Rechecked on head
8455a5cce(rebased over #5939), Windows 11 Pro 26220, RTX 4070 (596.21), WinLibs GCC 15.2. Stacked as main5f61879a9+ #6530 + #6639 + this PR, merged cleanly. Full build: no failures.agc_driver_graphicsandagc_driver_covered_centroid_statepass 3 of 3, and the latter printsAll 256 MSAA CMASK byte classifications passed. The GPU pass-R '^agc_driver_'passes 484 of 487 with 2 skipped. The one failure,agc_driver_f16_fma_denormal_modes, also fails on plain main here.agc_driver_store_over_untrackedpassed this time.reads as mixed, which is not modeledstop from my earlier run did not appear in any of 8 runs. However, Ruffle now stops on current main itself, as the demo starts. Main3b10c7ef0stops 2 of 2 (13.9 s, 17.9 s), and the stack stops 2 of 2, onAGC graphics: multisampled DCC CMASK compression or register clear is not implemented. With #6543 added, it stops 2 of 2 onAGC graphics: writes to a resident multisampled DCC target or its metadata are not implemented. I got the same result with #6543 and this PR's four source files reverted. Both lines come from #5939's DCC path. Ruffle's target has DCC, so after the rebase the seed this PR changes (dccAddress == 0) is not reached in Ruffle. On current main this PR therefore shows no effect in Ruffle either way, and the title check I posted earlier no longer applies.Not checked: this PR alone, AMD/Intel, Linux.
Written with Claude Code assistance (validation by a subagent, reviewed in this session).
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-17T10:13:23Z.
Thanks @screamm for rechecking after the rebase. You are right that the Ruffle evidence no longer applies now that #5939 gives its target DCC; I marked the table as predating #5939 and changed Unblocks to none.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:46:20Z.
Checked the MSAA CMASK nibble classification against Mesa's
CMASK_MSAA_CODE(0x00 register clear, 0xcc/0xdd/0xee/0xff color-expanded, everything else refused), the seed's read after pending writes, and the test (256-byte sweep plus seed/fill cases; it pins values only the new classification produces). Unmodeled codes still throw. Merged.