feat(agc): take RADV's comp-to-single clear of a multisampled DCC target #7600
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/7600"
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-18T16:34:52Z.
What
PS5 Mesa's RADV fast-clears a multisampled DCC color target to a color other than 0000/0001/1110/1111 with a comp-to-single clear (#7582).
radv_clear_dcc_comp_to_singledispatchesmeta_clear_dcc_comp_to_single. That shader stores the clear color in sample 0 of the first pixel of every DCC block, through a storage view in a uint format of the texel's size (R32_UINTfor 4-byte texels). RADV then sets the DCC keys toGFX9_DCC_CLEAR_SINGLE(0x10). The driver handles comp-to-single keys of single-sample surfaces (#2939, #4700) but not of multisampled targets:R32_UINTstorage view (storage image access to multisampled color target ... guest format 20 (vk 98) is not implemented).MultisampledDccClearrefuses 0x10 keys (initial multisampled DCC contents are not a supported uniform fast clear).This PR:
MatchMultisampledSingleClearrecognizes the multisampled variant of that shader by its 22 code words, taken from a dump of PPSA68091's, with 8x8 groups and 9 user data dwords. The image descriptor is at(2 << 32) | user[2], because the shader sets the high dword to 2. The block size is inuser[3..4]and the color inuser[5..8].TakeMultisampledSingleClearreads and decodes the descriptor, records the color for that surface (address, pipe-bank XOR, size and sample count), and skips the dispatch, counted as a fill HLE. In the resolve-ahead path the dispatch returns early, as the fill kernels do.retireUnmapped) drops every record whose surface base the removed range covers, and it is installed while any record exists. RADV writes 0x10 keys only in a fast clear that runs this dispatch for the same image right after, and initializes DCC to 0x00 or 0xff on an image's first use, so a new image gets its own record before it can show 0x10 keys.MultisampledDccCleartakes 0x10 keys as a clear to the recorded color when the target's surface, pipe-bank XOR, size and sample count match a recorded clear. This covers texels of 1 to 16 bytes. The shader storesuser[5..8]as the four dwords of sample 0's texel:v_mov_b32 v0, s5,v_lshrrev_b64 v[1:2], 0, s[6:7]andv_mov_b32 v3, s8. RADV binds the image through a uint view of the texel's size,R8_UINTup toR32G32B32A32_UINT, so a texel takes as many of those dwords as it holds. 0x10 keys with no recorded clear are refused with their own message.With #7250, the same import path takes a whole-range 0x10 fill of a resident target's DCC, since
absorbDccFillcallsMultisampledDccClear. That is how the resident-target cases below clear.Tested
Ubuntu 24.04 (Linux 6.8), GCC 13.3, NVIDIA RTX 4070 Ti (595.99.02).
agc_driver_graphics, newmultisampledSingleClearTests:agc_driver_graphics, newMultisampledDccClearcases with 0x10 keys of a 4x 581x729 RGBA8 target:MultisampleTarget.cppand the new tests,agc_driver_graphicsfails withmultisampled DCC comp-to-single clears of texels wider than 32 bits are not implemented. With the head (de1f5e5278) it passes 3 of 3.agc_driver_graphicsalso checks that a target with another pipe-bank XOR is refused, and that a surface on real guest memory imports its recorded color, is removed throughGuestAllocationsRemove, is mapped again at the same tuple, and is then refused when presented with the same 0x10 keys and no new recorded clear. Another surface's record survives the removal. It passes 3 of 3. With de1f5e5278'sMultisampleTarget.cppunder the new test it fails withexpected graphics rejection: comp-to-single keys without a recorded clear color. With onlyretireUnmapped'sforgetSingleClearscall removed (the XOR still recorded), it fails the same way, at the remapped surface. The 38 tests matching^agc_driver_graphics$|msaa|multisample|dcc|cmask|fmask|alpha_to_coverage|fill|dispatchpass.^agc_driver_graphics$|msaa|multisample|dcc|cmask|fmask|alpha_to_coverage|fill|dispatchpass. Full^agc_: 712 of 713 pass.agc_driver_bda_devicefails as it does onmainwith this driver (the 595.99 hang #7571 works around).mainbf2c63f853(d6cd6de586; the only conflict was an include next to #5497's inDispatch.cpp). Khronos validation layer (LunarG SDK 1.4.363), same machine:VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1 ctest -Vover the same expression (54 tests on thismain), onmainbf2c63f853and on this PR. 52 of 54 pass on each. The other two,agc_driver_image_msaa_address_on_planeandagc_driver_sgpr_pattern_fill_keys, are newer tests my script didn't build, so they show asNot Runon both. Neither log reports the layer missing, and neither has aVUID-error.ctest -R '^agc_' -Vunder the same layer onmainf29546ac4eand onmain+ this PR (d6cd6de586, a local merge). 812 of 812 pass on each, the two tests above included. Neither log reports the layer missing. Both show the same seven VUIDs, and none is new with this PR. Each ofmain's is the subject of an open PR: 00118 #7961, 04553 #7707, 07285 #7985, 01158 and 09543 #7913, 00605 #6782, 02275 #862.tests/tests/swfs/visual), each the only game in the library, 32 s. The stack ismain385ed71f2c+ #6543 + #7250 + #7233 (Ruffle stops earlier without the first two; #7233 covers a neighbouring-store case). "Coarse" is the mean difference of 32x24-cell averages between the last frame and the test'soutput.expected.png, 0 to 255.opaque_backgroundinitial multisampled DCC contents are not a supported uniform fast clearcolor_transform_issue_9698,gradient_issue_9892,blend_modes__masked_layer_cached_children,blend_modes__overlay_onto_stagecompute shader 0x201d95e00: AGC graphics: storage image access to multisampled color target 0x40023a0000 (1920x1080, 4 samples, vk format 37) as a 1920x1080 texture of 4 samples and guest format 20 (vk 98) is not implementedOn
mainalone Ruffle doesn't reach these: it stops at RADV's fill kernel, which #6543 takes.@akkadbakkad89 ran
agc_driver_graphicsat 8345be67c on Windows (RTX 3070, 617.42, WinLibs GCC 15.2.0): it passes, the matcher cases included.tools/check_conventions.py --base upstream/mainpasses.tools/pr_overlap.pylists #5497 and #6804, which add includes near the sameDispatch.cppline. It also lists open pull requests that conflict withmainand touchtests/Graphics.cppor the debt file; the debt entry sits away from the lines those edit.mainf3059421f, the 18 tests built fromtests/Graphics.cpppass three times each on an Intel UHD 770 (32.0.101.7088) and an AMD RX 9070 XT (32.0.31041.1004).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)agc_driver_graphicsat 8345be67c, by @akkadbakkad89); Intel UHD 770, 32.0.101.7088, and AMD RX 9070 XT, 32.0.31041.1004, Windows 11 (by @savvaniss)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-18T16:43:39Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/debt/libSceAgcDriver.mdL68-69core/libs/prx/libSceAgcDriver/tests/Graphics.cppL2429, L10876core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppL533-534, L705Some 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.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Execution/src/Driver/Dispatch/Dispatch.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/Graphics/include/MultisampleTarget.hppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mddocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdcore/libs/prx/libSceAgcDriver/tests/Graphics.cppdocs/dev/debt/libSceAgcDriver.mdImported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:26:02Z.
Pushed de1f5e5278. I decoded the clear shader with
agc_shader_replay --asm. It storesuser[5..8]as the four dwords of sample 0's texel:v0froms5,v[1:2]froms[6:7]throughv_lshrrev_b64by 0, andv3froms8. The address is(x * user[3], y * user[4], group z, sample 0). RADV binds the image through a uint view of the texel's size, so 8- and 16-byte texels take the first two dwords or all four. 0x10 keys of such targets now import as the recorded color instead of being refused. The unit test checks RGBA16F and RGBA32F, and the description is updated.agc_driver_graphicspasses 3 of 3 and the 38 area tests pass. With the first commit'sMultisampleTarget.cpp, the new cases fail with the old refusal.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by akkadbakkad89 on 2026-10-18T18:44:10Z.
Verified at head
8345be67c:agc_driver_graphicspasses on NVIDIA RTX 3070 (driver 617.42), Windows 11, MinGW (WinLibs GCC 15.2.0), Release - including the newmultisampledSingleClearTestsmatcher cases (recognized kernel/userdata, and all negative variants). The runtime fast-clear path itself is RADV-only, so NVIDIA coverage here is the matcher plus no-regression of the surrounding suite.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T18:46:30Z.
Thanks @akkadbakkad89, I added it to the description. One note: the clear dispatch comes from the guest's RADV, but AnyPS5's side runs on any host GPU. So the
MultisampledDccClearcases with 0x10 keys in that test, which don't need a device, are covered by your run too. Since then de1f5e5278 has extended them to RGBA16F and RGBA32F targets (64- and 128-bit texels).AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T20:29:40Z.
I checked the clear record's lifetime as well as the shader match.
singleClearsis static andNoteMultisampledSingleClearremoves an entry only when another recognized clear reuses the same base address. I do not see this record invalidated when the guest range/target is unmapped or reused;recordedSingleClearthen accepts a matching address, extent and sample count.Could a freed multisampled surface be reallocated at the same address with the same shape, but without this recognized clear, and later expose 0x10 DCC keys? In that case the new allocation could inherit the old recorded color. If that sequence is possible, please tie the record to the target/allocation lifetime or add an invalidation path, with a regression that retires and reuses the same surface tuple. If 0x10 provenance or allocator invariants rule it out, documenting that would answer the concern.
AI-assisted: yes
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T20:38:39Z.
@MarcZX10 yes, that sequence is possible, and the record should be tied to the image. I have a fix (038f050c75) that I'm testing now and will push with the results:
retireUnmapped, the unmap/allocation-removal observer, now drops every record whose surface base the removed range covers. The observer is also installed while any record exists.radv_clear_dcc, thenradv_clear_dcc_comp_to_single). It initializes DCC to 0x00 or 0xff on an image's first use (radv_init_color_image_metadata). So a new image gets a new record before it can show 0x10 keys again. The one case left: the same address, XOR, size and sample count, plus a clear whose shader isn't the recognized one. The debt entry will state that.Regression in
agc_driver_graphics: a mismatched XOR is refused. A surface on real guest memory is recorded and imported, then removed throughGuestAllocationsRemoveand mapped again at the same tuple, and the import must now be refused. Another surface's record must survive that removal.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-18T20:39:02Z.
Thanks, the RADV metadata initialization detail narrows the concern, and the remaining unrecognized-clear/reused-tuple case is the one that matters. For the reuse regression, please make sure the remapped target is presented with 0x10 DCC keys before the import attempt and without a new
NoteMultisampledSingleClear; otherwise default 0x00/0xff metadata would not exercise consumption of a stale record. Keeping another surface record valid is a useful control for range-specific invalidation.Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T20:40:50Z.
@MarcZX10 that's how the regression is written. After
GuestAllocationsRemoveand a newGuestAllocationsAddof the same block, the remapped target is the same tuple: address, XOR 0, 581x729, 4 samples. It's presented with the same all-0x10 key buffer, and there's noNoteMultisampledSingleClearin between. The import must then refuse withcomp-to-single keys without a recorded clear color. Before the removal, the same call on the same keys must import the recorded color, so the refusal comes from the invalidation. The control is the earlier surface at 0x40010000: it's outside the removed block and must still import its color afterwards. I'll post red and green runs when the build is through.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T20:52:13Z.
@MarcZX10 pushed 038f050c75 (it fast-forwards from de1f5e5278):
agc_driver_graphicswith it: 3 of 3.MultisampleTarget.cppunder the new test, it fails withexpected graphics rejection: comp-to-single keys without a recorded clear color. That's the first new check, the XOR mismatch.A separate red run that keeps the XOR in the record and removes only the unmap drop is queued, so the remap regression is shown failing on its own. I'll add it here when it's done. The description now covers the record's lifetime and the one case left in the debt entry.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T21:07:55Z.
@MarcZX10 the separate red run: on 038f050c75 with only
retireUnmapped'sforgetSingleClearscall removed, the record still carries the XOR.agc_driver_graphicsthen fails withexpected graphics rejection: comp-to-single keys without a recorded clear color, which is the remapped surface importing the stale color. So the unmap drop is what the remap regression tests, independently of the XOR. Added to the description.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by savvaniss on 2026-10-18T21:53:05Z.
Intel and AMD Windows data: with this PR the 18 tests built from
tests/Graphics.cpppass on an Intel UHD 770 and an AMD RX 9070 XT.Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, withVkCacheemptied first. This head038f050c7merged intomainf3059421f.tests/Graphics.cppThe test file doesn't build on
mainwithout the rest of the PR, so there is no before-run. The previous headde1f5e527also passed all 18 on both GPUs. I also ran full CTest withde1f5e527and the 14 other open AGC PRs I tested in the same batch merged together (#7647, #7641, #7630, #7627, #7603, #7591, #7579, #7535, #7533, #7474, #7462, #7050, #7048, #7650). Neither GPU showed a failure beyondmain's own, except #7650's new test.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T01:06:16Z.
Thanks @savvaniss for the Intel and AMD runs on the current head. Added to the description.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T21:43:54Z.
Rebased onto
mainbf2c63f853(d6cd6de586). The only conflict was an include inDispatch.cpp, next to theRecorder.hppinclude #5497 added. The Khronos validation comparison CONTRIBUTING.md now asks for is in the description: the PR's focused tests onmainand on this head. 52 of 54 pass on each; the other two are newer tests my script didn't build (Not Runon both), and a rerun with them is queued. Neither log has aVUID-error.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-10-21T01:40:10Z.
Related: #8123 adds DCC register-clear key
0x20; this PR adds the separate comp-to-single key0x10. I checked the current diff atd6cd6de586b44fbee6d344b9f51a5607fd52333d: thesingleClearColordispatch is immediately above the switch where #8123 adds its case, and the debt entries are adjacent. Neither implementation depends on the other. I can rebase #8123 and rerun its focused tests if this lands first. Please let me know if you prefer a different order.AI-assisted: yes.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T01:42:06Z.
@JJenkx thanks for checking. I have no preference on the order. The two keys are independent (comp-to-single
0x10here, register clear0x20in #8123), and the overlap is only neighbouring lines in that switch and the debt file. If #8123 lands first, I'll rebase this one and rerun its tests. If this lands first, your offer to rebase #8123 works for me.AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-21T11:08:10Z.
Rechecked against current main (#7650, #7683, #7862 and the sample-order change landed in the same files): the merge is clean, the XOR-keyed record and the unmap drop don't interact with them, and the matcher, 0x10 import and debt entry are unchanged. Merged.
Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-21T11:34:40Z.
Thanks @adriadam10 for rechecking it against the newer
mainchanges and merging.AI-assisted: yes (Claude Code)