Repository navigation
feat(agc): take RADV's comp-to-single clear of a multisampled DCC target - #7600
Conversation
|
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.
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.
|
|
Pushed de1f5e5. I decoded the clear shader with AI-assisted: yes (Claude Code) |
|
Verified at head |
|
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 AI-assisted: yes (Claude Code) |
|
I checked the clear record's lifetime as well as the shader match. 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 |
|
@MarcZX10 yes, that sequence is possible, and the record should be tied to the image. I have a fix (038f050) that I'm testing now and will push with the results:
Regression in AI-assisted: yes (Claude Code) |
|
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 |
|
@MarcZX10 that's how the regression is written. After AI-assisted: yes (Claude Code) |
|
@MarcZX10 pushed 038f050 (it fast-forwards from de1f5e5):
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) |
|
@MarcZX10 the separate red run: on 038f050 with only AI-assisted: yes (Claude Code) |
|
Intel and AMD Windows data: with this PR the 18 tests built from Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built,
The test file doesn't build on AI-assisted: yes (Claude Code) |
|
Thanks @savvaniss for the Intel and AMD runs on the current head. Added to the description. AI-assisted: yes (Claude Code) |
RADV clears a multisampled DCC target to a color other than 0000, 0001, 1110 or 1111 with radv_clear_dcc_comp_to_single: a compute dispatch stores the color at the first pixel of every DCC block through a uint storage view, and the DCC keys become 0x10. The driver refused that view of a resident target, made a separate target in the view's format otherwise, and couldn't import 0x10 keys. The dispatch is now recognized by its code and not run. Its clear color is recorded for the surface its image descriptor names, and 0x10 keys on a multisampled target of that surface, size and sample count import as a clear to that color, for texels up to 32 bits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RADV's comp-to-single shader stores user data 5 to 8 as the four dwords of sample 0's texel: v0 from s5, v1 and v2 from s[6:7] through a 64-bit shift by zero, and v3 from s8. RADV binds the image through a uint view of the texel's size, up to R32G32B32A32_UINT, so a 64-bit texel takes the first two dwords and a 128-bit texel all four. 0x10 keys of RGBA16F and RGBA32F targets now import as a clear to the recorded color instead of being refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A recorded comp-to-single clear stayed valid for its surface address, size and sample count until another recognized clear replaced it, so a surface freed and reallocated on the same memory could import the old color for its 0x10 DCC keys. The record now also carries the image's pipe-bank XOR, which RADV assigns per image, and is dropped when an unmap or allocation removal covers the surface's base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
038f050 to
d6cd6de
Compare
|
Rebased onto AI-assisted: yes (Claude Code) |
|
Related: #8123 adds DCC register-clear key AI-assisted: yes. |
|
@JJenkx thanks for checking. I have no preference on the order. The two keys are independent (comp-to-single AI-assisted: yes (Claude Code) |
|
Thanks @adriadam10 for rechecking it against the newer AI-assisted: yes (Claude Code) |
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 (de1f5e5) 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 de1f5e5'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 fix(shader): leave the BDA lookup functions through one return #7571 works around).mainbf2c63f (d6cd6de; the only conflict was an include next to perf(agc): read DCC keys behind a pattern fill kernel's fast clear without a wait #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), onmainbf2c63f and 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 onmainf29546a and onmain+ this PR (d6cd6de, 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 fix(agc): give copied guest buffer regions transfer-source usage #7961, 04553 fix(shader): point-filter direct samplers paired with unsigned integer images #7707, 07285 fix(agc): copy a linked pipeline's color sample counts only when it has color attachments #7985, 01158 and 09543 fix(agc): hold a pending producer batch with a timeline semaphore #7913, 00605 fix(agc): enable independentBlend for color targets with different blend states #6782, 02275 fix(agc): restrict sampled storage texture view usage #862.tests/tests/swfs/visual), each the only game in the library, 32 s. The stack ismain385ed71 + fix(agc): take RADV's fill-memory kernel as a buffer fill #6543 + feat(agc): take a full DCC fill of a resident multisampled target as its fast clear #7250 + fix(agc): separate possible writes from complete coverage #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.mainf305942, 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 8345be6, 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