fix(agc): draw a one-fragment multisampled color target as one sample with sample 0's coverage #9450

Merged
fma-rc merged 8 commits from upstream-pr/9450 into main 2026-10-24 18:22:29 +00:00
fma-rc commented 2026-10-21 22:27:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-21T22:27:54Z.


What

A color target whose CB_COLOR_ATTRIB has 4 samples and 1 fragment (EQAA) threw color targets with fewer fragments than samples (EQAA) are unsupported. PPSA02015 draws its scene into such a target beside a 4x depth target (CB_COLOR_INFO 0x10046710, CB_COLOR_ATTRIB 0x2000, DB_EQAA 0x112202).

With one fragment, a pixel keeps what sample 0 covers. That is the truncated coverage path of #8115, so this decodes the target as one sample, keeps its coverage sample count, and draws it there. Measured with radeonsi GL on a 4-sample, 1-storage-sample framebuffer (Radeon 610M, Mesa 26.2.5, and Radeon 680M, Mesa 26.2.4): green drawn on sample 0 alone is kept, green on samples 1-3 is dropped, and a later draw on sample 0 replaces it. With 2 or 4 storage samples the same draws resolve to blends, so the one-fragment case is distinct.

radeonsi GL, GL_AMD_framebuffer_multisample_advanced, 4 color samples, 1 storage sample, mask by glSampleMaski
clear red                                    pixel(2,2) = 255   0   0 255
full green                                   pixel(2,2) =   0 255   0 255
green on sample 0 only                       pixel(2,2) =   0 255   0 255
green on sample 1 only                       pixel(2,2) = 255   0   0 255
green on samples 1-3                         pixel(2,2) = 255   0   0 255
green on 0-1, then blue on 2-3               pixel(2,2) =   0 255   0 255
blue on 2-3, then green on 0-1               pixel(2,2) =   0 255   0 255
green on 0, then blue on 0                   pixel(2,2) =   0   0 255 255
full green, then blue on sample 1            pixel(2,2) =   0 255   0 255

What stays refused, so unknown behaviour still throws:

  • more than one but fewer fragments than samples, and more fragments than samples;
  • DB_EQAA without static anchors at the depth target's sample count (the measured configuration);
  • CMASK codes other than 0 and 0xc-0xf. Code 0 is materialized like a one-sample fast clear, which is how radeonsi's CMASK fast clear marks a tile whose single fragment holds the clear color (si_clear.c);
  • any guest read of the FMASK of such a target once the host has drawn it. The host does not write FMASK, so its range (64 KiB-aligned, at least one bit per sample) is added to the guarded host-only ranges: texture, storage, DMA and CPU reads throw, cached lookups included, and the guard is dropped on unmap.

The first version of the decode idea is mrfelek's (#5424, c19078289).

ColorTarget::fmaskAddress comes from #7948 (address without the pipe-bank XOR); this sets it for one-fragment targets, which #7948's multi-fragment path leaves at 0.

Tested

Linux (Arch), on main 5ed5427bac.

test NVIDIA RTX 5080 RADV Radeon 610M lavapipe
agc_driver_graphics pass pass pass
agc_driver_pixel_sample_coverage pass pass pass (one-fragment case skipped: no mixed-sample extension)
agc_driver_cmask_fast_clear pass pass pass
agc_multisample_guest_access pass pass pass

Each new case fails without its change (decode, anchors, CMASK codes, FMASK guard). agc_driver_pixel_sample_coverage also passes on a Radeon 680M (RADV) and refuses the target without this change. Windows: build, ctest, tools tests and conventions show no failure that the merge base lacks.

Validation layer, as CONTRIBUTING asks: the four tests above on main 5ed5427bac and on this head 5d418de02d (the head after it changes only the debt doc), same machine, NVIDIA RTX 5080, driver 615.78.08, Vulkan 1.4.351, Arch Linux 7.2.11, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V, Khronos layers 1.4.363. The loader reports Insert instance layer "VK_LAYER_KHRONOS_validation" on both sides; both pass 4 of 4 with no VUID- message on either side.

PPSA02015 (on the pre-rebase head, with the open PRs it needed to reach this point) gets past this stop and next stops at 89 s on sampling a multisampled texture no draw rendered to, a separate change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA02015 #5424 (past the EQAA stop; next stop is separate)
  • GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 610M (RADV, Mesa), lavapipe, AMD Radeon 680M (RADV, Mesa), all Arch Linux
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4959208059 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9450). Originally posted by [fma-rc](https://github.com/fma-rc) on 2026-10-21T22:27:54Z. --- ### What A color target whose `CB_COLOR_ATTRIB` has 4 samples and 1 fragment (EQAA) threw `color targets with fewer fragments than samples (EQAA) are unsupported`. PPSA02015 draws its scene into such a target beside a 4x depth target (`CB_COLOR_INFO` 0x10046710, `CB_COLOR_ATTRIB` 0x2000, `DB_EQAA` 0x112202). With one fragment, a pixel keeps what sample 0 covers. That is the truncated coverage path of #8115, so this decodes the target as one sample, keeps its coverage sample count, and draws it there. Measured with radeonsi GL on a 4-sample, 1-storage-sample framebuffer (Radeon 610M, Mesa 26.2.5, and Radeon 680M, Mesa 26.2.4): green drawn on sample 0 alone is kept, green on samples 1-3 is dropped, and a later draw on sample 0 replaces it. With 2 or 4 storage samples the same draws resolve to blends, so the one-fragment case is distinct. <details><summary>radeonsi GL, <code>GL_AMD_framebuffer_multisample_advanced</code>, 4 color samples, 1 storage sample, mask by <code>glSampleMaski</code></summary> ``` clear red pixel(2,2) = 255 0 0 255 full green pixel(2,2) = 0 255 0 255 green on sample 0 only pixel(2,2) = 0 255 0 255 green on sample 1 only pixel(2,2) = 255 0 0 255 green on samples 1-3 pixel(2,2) = 255 0 0 255 green on 0-1, then blue on 2-3 pixel(2,2) = 0 255 0 255 blue on 2-3, then green on 0-1 pixel(2,2) = 0 255 0 255 green on 0, then blue on 0 pixel(2,2) = 0 0 255 255 full green, then blue on sample 1 pixel(2,2) = 0 255 0 255 ``` </details> What stays refused, so unknown behaviour still throws: - more than one but fewer fragments than samples, and more fragments than samples; - `DB_EQAA` without static anchors at the depth target's sample count (the measured configuration); - CMASK codes other than 0 and 0xc-0xf. Code 0 is materialized like a one-sample fast clear, which is how radeonsi's CMASK fast clear marks a tile whose single fragment holds the clear color (`si_clear.c`); - any guest read of the FMASK of such a target once the host has drawn it. The host does not write FMASK, so its range (64 KiB-aligned, at least one bit per sample) is added to the guarded host-only ranges: texture, storage, DMA and CPU reads throw, cached lookups included, and the guard is dropped on unmap. The first version of the decode idea is mrfelek's (#5424, c19078289). `ColorTarget::fmaskAddress` comes from #7948 (address without the pipe-bank XOR); this sets it for one-fragment targets, which #7948's multi-fragment path leaves at 0. ### Tested Linux (Arch), on `main` 5ed5427bac. | test | NVIDIA RTX 5080 | RADV Radeon 610M | lavapipe | |---|---|---|---| | `agc_driver_graphics` | pass | pass | pass | | `agc_driver_pixel_sample_coverage` | pass | pass | pass (one-fragment case skipped: no mixed-sample extension) | | `agc_driver_cmask_fast_clear` | pass | pass | pass | | `agc_multisample_guest_access` | pass | pass | pass | Each new case fails without its change (decode, anchors, CMASK codes, FMASK guard). `agc_driver_pixel_sample_coverage` also passes on a Radeon 680M (RADV) and refuses the target without this change. Windows: build, ctest, tools tests and conventions show no failure that the merge base lacks. Validation layer, as CONTRIBUTING asks: the four tests above on `main` 5ed5427bac and on this head 5d418de02d (the head after it changes only the debt doc), same machine, NVIDIA RTX 5080, driver 615.78.08, Vulkan 1.4.351, Arch Linux 7.2.11, `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ctest -V`, Khronos layers 1.4.363. The loader reports `Insert instance layer "VK_LAYER_KHRONOS_validation"` on both sides; both pass 4 of 4 with no `VUID-` message on either side. PPSA02015 (on the pre-rebase head, with the open PRs it needed to reach this point) gets past this stop and next stops at 89 s on sampling a multisampled texture no draw rendered to, a separate change. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA02015 #5424 (past the EQAA stop; next stop is separate) - [x] GPUs tested: NVIDIA RTX 5080 (driver 615.78.08), AMD Radeon 610M (RADV, Mesa), lavapipe, AMD Radeon 680M (RADV, Mesa), all Arch Linux - [x] AI-assisted: yes
MarcZX10 commented 2026-10-22 01:55:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:55:59Z.

Review: CHANGES_REQUESTED


The one-fragment implementation is narrowly described and the report includes useful Radeon hardware measurements and functional cases. The PR is based on current main, declares the #8115 prerequisite, and its eligibility, conventions, intake, labels and report checks pass. The product and relinker jobs were skipped; I did not run local tests.

I’m requesting changes for two repository/evidence items before approval:

  1. This changes AGC rendering and pipeline creation, so CONTRIBUTING.md requires the same focused tests on main and the PR head, on the same machine and GPU, with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, and ctest -V. Please report both runs, confirm the requested validation layer was found, compare for newly introduced VUID- messages, and include vendor/model/driver/OS. The current report provides useful multi-vendor rendering tests but not this required validation-layer comparison.
  2. The checklist currently says Unblocks: PPSA02015 without its Game bring-up discussion. The repository has Death Stranding 2 discussion #5424. Please update the line to Unblocks: PPSA02015 #5424 (or use none if the PR should not carry a title unblock).

I reviewed the new sample-count flow: coverageSamples retains the coverage count, samples becomes the one fragment/storage count, and truncatedCoverage carries the mixed color/depth path into pipeline keys and both attachment creation modes. I have not found a substantiated functional defect in that path during this review; the requests above are for required validation evidence and the checklist rule. The exact overlap bot output lists several same-file AGC changes, but my spot comparison found the reported PipelineJournal.cpp hunks update layout-size guards alongside distinct state fields; please keep merge coordination in view if later rebases reveal a real shared implementation hunk.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5608385152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9450#pullrequestreview-5608385152). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:55:59Z. **Review:** CHANGES_REQUESTED --- The one-fragment implementation is narrowly described and the report includes useful Radeon hardware measurements and functional cases. The PR is based on current `main`, declares the #8115 prerequisite, and its eligibility, conventions, intake, labels and report checks pass. The product and relinker jobs were skipped; I did not run local tests. I’m requesting changes for two repository/evidence items before approval: 1. This changes AGC rendering and pipeline creation, so `CONTRIBUTING.md` requires the same focused tests on `main` and the PR head, on the same machine and GPU, with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`, and `ctest -V`. Please report both runs, confirm the requested validation layer was found, compare for newly introduced `VUID-` messages, and include vendor/model/driver/OS. The current report provides useful multi-vendor rendering tests but not this required validation-layer comparison. 2. The checklist currently says `Unblocks: PPSA02015` without its Game bring-up discussion. The repository has Death Stranding 2 discussion #5424. Please update the line to `Unblocks: PPSA02015 #5424` (or use `none` if the PR should not carry a title unblock). I reviewed the new sample-count flow: `coverageSamples` retains the coverage count, `samples` becomes the one fragment/storage count, and `truncatedCoverage` carries the mixed color/depth path into pipeline keys and both attachment creation modes. I have not found a substantiated functional defect in that path during this review; the requests above are for required validation evidence and the checklist rule. The exact overlap bot output lists several same-file AGC changes, but my spot comparison found the reported `PipelineJournal.cpp` hunks update layout-size guards alongside distinct state fields; please keep merge coordination in view if later rebases reveal a real shared implementation hunk.
MarcZX10 commented 2026-10-22 01:56:00 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T01:56:00Z.


I reviewed the current one-fragment path and its live checks. The PR declares #8115 and its policy checks pass; product/relinker jobs were skipped. Because this is an AGC change, I requested the required same-machine/GPU main-vs-PR Vulkan validation-layer comparison, including confirming layer availability and comparing VUIDs. I also found the existing Death Stranding 2 Game bring-up discussion #5424; please pair it with PPSA02015 in Unblocks.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6330810844 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9450#issuecomment-6330810844). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T01:56:00Z. --- I reviewed the current one-fragment path and its live checks. The PR declares #8115 and its policy checks pass; product/relinker jobs were skipped. Because this is an AGC change, I requested the required same-machine/GPU main-vs-PR Vulkan validation-layer comparison, including confirming layer availability and comparing VUIDs. I also found the existing Death Stranding 2 Game bring-up discussion #5424; please pair it with PPSA02015 in `Unblocks`.
MarcZX10 commented 2026-10-22 04:36:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-22T04:36:03Z.

Review: DISMISSED


The existing blocking items remain outstanding: the required validation-layer main/change pair and the Unblocks: PPSA02015 #5424 discussion reference. Since the prior review, current main has advanced: this head’s merge base is 275e896797, while current main is 110a18ba01. Please rebase and rerun the required paired focused validation on the same hardware, then refresh conventions/overlap and the checklist. The existing hardware coverage is valuable, but it does not replace the repository’s specified VUID comparison.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5609311840 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9450#pullrequestreview-5609311840). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-22T04:36:03Z. **Review:** DISMISSED --- The existing blocking items remain outstanding: the required validation-layer main/change pair and the `Unblocks: PPSA02015 #5424` discussion reference. Since the prior review, current `main` has advanced: this head’s merge base is `275e896797`, while current main is `110a18ba01`. Please rebase and rerun the required paired focused validation on the same hardware, then refresh conventions/overlap and the checklist. The existing hardware coverage is valuable, but it does not replace the repository’s specified VUID comparison.
Sign in to join this conversation.
No reviewers
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!9450
No description provided.