AGC: RADV's comp-to-single fast clear of a multisampled DCC target stops Ruffle (PPSA68091) #7582

Closed
opened 2026-10-18 15:40:03 +00:00 by milescoviello · 4 comments
milescoviello commented 2026-10-18 15:40:03 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T15:40:03Z.


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. The AGC driver models comp-to-single for single-sample surfaces (#2939, #4700) but not for multisampled targets, so Ruffle (PPSA68091) stops when a movie clears a 4x target to such a color. I ran 36 of Ruffle's own visual tests (frame-1 tests from tests/tests/swfs/visual in ruffle-rs/ruffle):

  • 30 render like the test's output.expected.png.
  • Two differ without stopping: define_bits_lossless2_rgb15 only by the scaling of its 50x50 bitmap, and filters__bevel in its text, which the test notes depends on the default font.
  • Four stop. opaque_background stops on this clear (its DCC key shows it). Two more stop on a storage view that matches this clear's shader, though I haven't confirmed it's that shader. The fourth I haven't traced.

Setup: Linux, RTX 4070 Ti (NVIDIA 595.99.02). main 385ed71f2c + #6543 (Ruffle stops at the RADV fill kernel without it) + #7250 (it stops at the first DCC refill without that). Each SWF was the only game in /data/ruffle/games, run for 32 s.

Test SWF Stop
opaque_background initial multisampled DCC contents are not a supported uniform fast clear
color_transform_issue_9698, gradient_issue_9892 compute 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 implemented
filters__displacement_map writes to a resident multisampled DCC target or its metadata are not implemented: the DCC range 0x4004606000+0x14000 changed with no buffer fill noted for it. I haven't traced what wrote it.

What RADV does

radv_clear_dcc_comp_to_single binds the image through a storage view in a uint format of the same texel size: VK_FORMAT_R32_UINT for 4-byte texels, which is the guest format 20 above. It then dispatches meta_clear_dcc_comp_to_single. That shader stores the clear color, push constants 8 to 24, into sample 0 of the first pixel of every DCC block (block size in push constants 0 to 8). The DCC keys are then set to GFX9_DCC_CLEAR_SINGLE (0x10). The hardware then reads every block as the color stored in its first pixel.

A temporary print in MultisampledDccClear confirms it for opaque_background: DCC key 0x10, CMASK 0xcc, clear words 0, VK_FORMAT_R8G8B8A8_UNORM, 4 samples, 581x729.

What the driver does with it

  • MultisampledDccClear takes only the 0x00, 0x40, 0x80 and 0xc0 keys, so a target first used after the clear isn't imported.
  • The storage path only gives a storage view of a resident target in its own format, so a shader like the clear's can't write the resident target through an R32_UINT view. When no target is resident, it creates one in the view's format, which the later draw in the color format doesn't match.
  • With #7250, a whole-range fill of a resident target's DCC is taken as a clear only for the four keys above, not for 0x10.

A possible approach

The clear color is in the clear shader's push constants. Recognizing that dispatch on a multisampled DCC target, as #6543 recognizes RADV's fill kernel, would give the color without a storage view in another format. A following 0x10 fill of the target's DCC, or 0x10 keys at import, could then be taken as a clear to that color. The import would also have to check that the color memory holds that color at the blocks' first pixels. I haven't written this. It builds on #6543 and #7250, and I'd like to wait for those before starting.

Not checked: Windows, AMD, a console. The stops were reached only with #6543 and #7250 on top of main.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5911212372 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7582). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T15:40:03Z. --- ### 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. The AGC driver models comp-to-single for single-sample surfaces (#2939, #4700) but not for multisampled targets, so Ruffle (PPSA68091) stops when a movie clears a 4x target to such a color. I ran 36 of Ruffle's own visual tests (frame-1 tests from `tests/tests/swfs/visual` in ruffle-rs/ruffle): - 30 render like the test's `output.expected.png`. - Two differ without stopping: `define_bits_lossless2_rgb15` only by the scaling of its 50x50 bitmap, and `filters__bevel` in its text, which the test notes depends on the default font. - Four stop. `opaque_background` stops on this clear (its DCC key shows it). Two more stop on a storage view that matches this clear's shader, though I haven't confirmed it's that shader. The fourth I haven't traced. Setup: Linux, RTX 4070 Ti (NVIDIA 595.99.02). `main` 385ed71f2c + #6543 (Ruffle stops at the RADV fill kernel without it) + #7250 (it stops at the first DCC refill without that). Each SWF was the only game in `/data/ruffle/games`, run for 32 s. | Test SWF | Stop | |---|---| | `opaque_background` | `initial multisampled DCC contents are not a supported uniform fast clear` | | `color_transform_issue_9698`, `gradient_issue_9892` | `compute 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 implemented` | | `filters__displacement_map` | `writes to a resident multisampled DCC target or its metadata are not implemented`: the DCC range 0x4004606000+0x14000 changed with no buffer fill noted for it. I haven't traced what wrote it. | ### What RADV does [`radv_clear_dcc_comp_to_single`](https://github.com/mihawk-99/PS5_Mesa/blob/1ba9874f478657ccf6da72ce55f0260164cc0bd0/src/amd/vulkan/meta/radv_meta_clear.c#L954) binds the image through a storage view in a uint format of the same texel size: `VK_FORMAT_R32_UINT` for 4-byte texels, which is the `guest format 20` above. It then dispatches [`meta_clear_dcc_comp_to_single`](https://github.com/mihawk-99/PS5_Mesa/blob/1ba9874f478657ccf6da72ce55f0260164cc0bd0/src/amd/vulkan/nir/radv_meta_nir.c#L840). That shader stores the clear color, push constants 8 to 24, into sample 0 of the first pixel of every DCC block (block size in push constants 0 to 8). The DCC keys are then set to [`GFX9_DCC_CLEAR_SINGLE`](https://github.com/mihawk-99/PS5_Mesa/blob/1ba9874f478657ccf6da72ce55f0260164cc0bd0/src/amd/common/ac_descriptors.h#L38) (0x10). The hardware then reads every block as the color stored in its first pixel. A temporary print in `MultisampledDccClear` confirms it for `opaque_background`: DCC key 0x10, CMASK 0xcc, clear words 0, `VK_FORMAT_R8G8B8A8_UNORM`, 4 samples, 581x729. ### What the driver does with it - [`MultisampledDccClear`](https://github.com/boykopovar/AnyPS5/blob/91ddd9e3a616dba51fa37a1532a7e8ef00418fbd/core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp#L603-L609) takes only the 0x00, 0x40, 0x80 and 0xc0 keys, so a target first used after the clear isn't imported. - [The storage path](https://github.com/boykopovar/AnyPS5/blob/91ddd9e3a616dba51fa37a1532a7e8ef00418fbd/core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp#L731-L741) only gives a storage view of a resident target in its own format, so a shader like the clear's can't write the resident target through an `R32_UINT` view. When no target is resident, it creates one in the view's format, which the later draw in the color format doesn't match. - With #7250, a whole-range fill of a resident target's DCC is taken as a clear only for the four keys above, not for 0x10. ### A possible approach The clear color is in the clear shader's push constants. Recognizing that dispatch on a multisampled DCC target, as #6543 recognizes RADV's fill kernel, would give the color without a storage view in another format. A following 0x10 fill of the target's DCC, or 0x10 keys at import, could then be taken as a clear to that color. The import would also have to check that the color memory holds that color at the blocks' first pixels. I haven't written this. It builds on #6543 and #7250, and I'd like to wait for those before starting. Not checked: Windows, AMD, a console. The stops were reached only with #6543 and #7250 on top of `main`. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 15:55:47 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T15:55:47Z.


Confirmed for the storage-view stops. With APS5_DUMP_SHADERS, the compute shader that stops color_transform_issue_9698 (0x201d95e00) is 22 code words with an 8x8 workgroup, dispatched as 240x135 threads for the 1920x1080 target, which is one thread per 8x8 DCC block. Its body scales the thread coordinates by a user-data block size, sets the sample index to 0 (v7 = 0), and does one image_store of four user-data dwords at those coordinates. That is RADV's meta_clear_dcc_comp_to_single (multisampled variant) from the description. The clear color is in the dispatch's user data, so a driver that recognizes this shader can read it from there.

Separately, filters__displacement_map isn't the only test that stops on writes to a resident multisampled DCC target or its metadata are not implemented with no fill noted for the DCC range. blend_modes__shader_as_mask, filters__bevel_full, filters__bevel_inner, filters__bevel_outer and filters__glow_with_alpha_strength stop on it too. I'm tracing what writes those ranges.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6251961999 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7582#issuecomment-6251961999). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T15:55:47Z. --- Confirmed for the storage-view stops. With `APS5_DUMP_SHADERS`, the compute shader that stops `color_transform_issue_9698` (0x201d95e00) is 22 code words with an 8x8 workgroup, dispatched as 240x135 threads for the 1920x1080 target, which is one thread per 8x8 DCC block. Its body scales the thread coordinates by a user-data block size, sets the sample index to 0 (`v7 = 0`), and does one `image_store` of four user-data dwords at those coordinates. That is RADV's `meta_clear_dcc_comp_to_single` (multisampled variant) from the description. The clear color is in the dispatch's user data, so a driver that recognizes this shader can read it from there. Separately, `filters__displacement_map` isn't the only test that stops on `writes to a resident multisampled DCC target or its metadata are not implemented` with no fill noted for the DCC range. `blend_modes__shader_as_mask`, `filters__bevel_full`, `filters__bevel_inner`, `filters__bevel_outer` and `filters__glow_with_alpha_strength` stop on it too. I'm tracing what writes those ranges. AI-assisted: yes (Claude Code)
milescoviello commented 2026-10-18 16:35:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-18T16:35:01Z.


Opened #7600 for the comp-to-single stops. It recognizes the multisampled clear dispatch by its code, records the color from its user data for the surface its descriptor names, and imports 0x10 keys as a clear to that color, for texels up to 32 bits. With #6543, #7250 and #7233, the five tests that stopped on it run and match their expected images (32x24-cell mean difference 0.1 to 0.6 of 255).

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6252363630 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7582#issuecomment-6252363630). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-18T16:35:01Z. --- Opened #7600 for the comp-to-single stops. It recognizes the multisampled clear dispatch by its code, records the color from its user data for the surface its descriptor names, and imports 0x10 keys as a clear to that color, for texels up to 32 bits. With #6543, #7250 and #7233, the five tests that stopped on it run and match their expected images (32x24-cell mean difference 0.1 to 0.6 of 255). AI-assisted: yes (Claude Code)
wachi35676 commented 2026-10-19 00:20:48 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by wachi35676 on 2026-10-19T00:20:48Z.


Windows/NVIDIA data point for the fix stack, which the report lists as not checked. Ruffle Flash (PPSA68091, 1.2.0), relinked with --windows --windows-fixed-base 0x400000, running one of Ruffle's own visual test SWFs (ruffle-rs/ruffle, MIT/Apache-2.0) at a time from /data/ruffle/games, 30 s each.

SWF main 8e7904b20 + #6543, #7250, #6669, #7600, #7641
blend_modes/add writes to a resident multisampled DCC target or its metadata are not implemented runs, matches output.expected.png
cache_as_bitmap/avm1_color multisampled DCC CMASK compression or register clear is not implemented runs, matches
drawing_api/fills_and_lines resident DCC writes runs, matches (3 runs)
gradient_same_ratios resident DCC writes runs, matches
opaque_background CMASK compression runs, matches
simple_shapes/masks resident DCC writes runs, matches

Without #7600 and #7641, only opaque_background stops, with initial multisampled DCC contents are not a supported uniform fast clear.

#7250 conflicts with current main in NoteColorMetadataFill. I resolved it by keeping main's HTILE check and then #7250's DCC branch.

Windows 11 26300, RTX 5070 Ti (32.0.16.1742), WinLibs GCC 15.2.0, Release.

AI-assisted: yes (Claude Code); results above were run on this machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257003240 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7582#issuecomment-6257003240). Originally posted by [wachi35676](https://github.com/wachi35676) on 2026-10-19T00:20:48Z. --- Windows/NVIDIA data point for the fix stack, which the report lists as not checked. Ruffle Flash (PPSA68091, 1.2.0), relinked with `--windows --windows-fixed-base 0x400000`, running one of Ruffle's own visual test SWFs (ruffle-rs/ruffle, MIT/Apache-2.0) at a time from `/data/ruffle/games`, 30 s each. | SWF | `main` `8e7904b20` | + #6543, #7250, #6669, #7600, #7641 | |---|---|---| | blend_modes/add | `writes to a resident multisampled DCC target or its metadata are not implemented` | runs, matches `output.expected.png` | | cache_as_bitmap/avm1_color | `multisampled DCC CMASK compression or register clear is not implemented` | runs, matches | | drawing_api/fills_and_lines | resident DCC writes | runs, matches (3 runs) | | gradient_same_ratios | resident DCC writes | runs, matches | | opaque_background | CMASK compression | runs, matches | | simple_shapes/masks | resident DCC writes | runs, matches | Without #7600 and #7641, only `opaque_background` stops, with `initial multisampled DCC contents are not a supported uniform fast clear`. #7250 conflicts with current `main` in `NoteColorMetadataFill`. I resolved it by keeping `main`'s HTILE check and then #7250's DCC branch. Windows 11 26300, RTX 5070 Ti (32.0.16.1742), WinLibs GCC 15.2.0, Release. AI-assisted: yes (Claude Code); results above were run on this machine.
milescoviello commented 2026-10-19 01:06:18 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by milescoviello on 2026-10-19T01:06:18Z.


Thanks @wachi35676 for the Windows/NVIDIA run of the whole stack. Six of Ruffle's SWFs matching their expected images, and opaque_background stopping without #7600 and #7641, is just what the fixes predict. #7250 conflicted with main again after the HTILE change in NoteColorMetadataFill. I'm rebasing it now with the same resolution you used: main's HTILE check first, then #7250's DCC branch.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6257475998 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/7582#issuecomment-6257475998). Originally posted by [milescoviello](https://github.com/milescoviello) on 2026-10-19T01:06:18Z. --- Thanks @wachi35676 for the Windows/NVIDIA run of the whole stack. Six of Ruffle's SWFs matching their expected images, and `opaque_background` stopping without #7600 and #7641, is just what the fixes predict. #7250 conflicted with `main` again after the HTILE change in `NoteColorMetadataFill`. I'm rebasing it now with the same resolution you used: `main`'s HTILE check first, then #7250's DCC branch. AI-assisted: yes (Claude Code)
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#7582
No description provided.