perf(agc): replay draws to native multisample color targets #27849

Merged
RavenCurseBurg merged 4 commits from upstream-pr/27849 into main 2026-12-04 00:14:45 +00:00
RavenCurseBurg commented 2026-11-27 15:26:52 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by RavenCurseBurg on 2026-11-27T15:26:52Z.


What

For #26599, allow direct draws to native multisampled color targets to reuse their recorded commands. Replay verifies each attachment against the live multisample registry and retains its image through command recording. Retired and replaced attachments use the ordinary draw path.

Tested

I tested the synthetic 4× MSAA scene after integrating #21479. Against 65ff3ae335ac, the integrated candidate 2e566609eeae reduced median CPU recording time on the RTX 4060 from 2.55 to 1.81 µs/draw with one color target and from 3.03 to 2.06 with two. On the UHD 770, the corresponding results were 2.61 to 1.99 and 3.51 to 2.12. Each comparison used 8,064 steady-state draws per revision and verified readback. Inline and pipelined PM4 runs both went from zero to 64 recipe hits on each GPU, with 64 draw-cache hits throughout.

For the existing single-sample fast path, the paired candidate/base recording-time ratios were 1.012 on NVIDIA (95% interval 0.935–1.097) and 0.954 on Intel (0.878–1.042). The identical-binary Intel control also varied. All 145 shared CTests retained their outcomes on each adapter, and the added regression passed. Retiring and reacquiring a DCC texture at the same address passed twice per adapter at 2×, 4× and 8×. A Snoopy capture on the reporting RX 6700 XT is still needed to measure title frame time. Both revisions' traces, measured batches and reproduction instructions

The branch merged cleanly with main at 102cad67da. The overlap checker examined 2,676 open PRs. I compared the four flagged line overlaps and 52 branches that could not merge with main. #19686, #21479 and #25802 change attachment acquisition and layout. #27273 changes draw-key ownership. #11452 adds counters. The reported patches contain no implementation of live native MSAA recipe replay. The tested counter integration is available for the reporter's Snoopy run.

I merged the upstream DCC texture import change (#21479) at 65ff3ae335ac and compared the resulting code with that main commit. All 145 shared CTests retained identical outcomes per GPU. The added recipe test passed on both. The RTX 4060 had 143 passes, two skips and one baseline failure. The UHD 770 had 142 passes, one skip and three baseline failures. Both adapters passed all six initial DCC and target takeover cases. A separate native Vulkan check reimported a DCC texture at the same address while retaining its old owner. The old attachment refused replay and the newly acquired attachment replayed. Readback preserved the expected color. This passed twice per adapter at each of 2×, 4× and 8× MSAA with Khronos validation. Integrated code

I rechecked the merge of main 80781a0e94 in 6344fbd213. Recipe creation requires a content key, and ordinary target acquisition keeps main's GCN texture ownership check. On each of the RTX 4060 and UHD 770, all 151 shared CTests retained their outcomes and the additional multisample recipe test passed. The Vulkan validation logs showed no additional diagnostics. Benchmarks and regression results for this revision

I merged upstream 363e0bed4def into the submitted branch and checked the resulting tree. The project’s code and PR conventions passed.

I checked the current GPU overlaps. #9508 changes descriptor-heap handling and #20315 changes host imports. #9897 changes the CheckBufferAliases call next to the multisample feedback guard. If #9897 merges first, I will retain the guard and pass its maxVertex argument to CheckBufferAliases when refreshing this branch.

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 and the licence notice of code adapted from upstream (see AGENTS.md)
  • 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 (Snoopy measurement pending on #26599)
  • Unblocks: none
  • GPUs tested: Windows 11 build 26100, NVIDIA RTX 4060 driver 595.79 and Intel UHD 770 driver 101.5973
  • AI-assisted: yes (Codex + GPT-6.2 Astra, xhigh)

Summary by CodeRabbit

  • New Features
    • Draw recipes now support replay with multisampled color targets when all color targets use multisampling.
    • Replayed recipes reuse their original multisample attachments. Replay is rejected if an attachment is invalid, replaced, retired, or conflicts with a rendered surface or depth feedback.
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5529118967 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27849). Originally posted by [RavenCurseBurg](https://github.com/RavenCurseBurg) on 2026-11-27T15:26:52Z. --- ### What For #26599, allow direct draws to native multisampled color targets to reuse their recorded commands. Replay verifies each attachment against the live multisample registry and retains its image through command recording. Retired and replaced attachments use the ordinary draw path. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> I tested the synthetic 4× MSAA scene after integrating #21479. Against `65ff3ae335ac`, the integrated candidate `2e566609eeae` reduced median CPU recording time on the RTX 4060 from 2.55 to 1.81 µs/draw with one color target and from 3.03 to 2.06 with two. On the UHD 770, the corresponding results were 2.61 to 1.99 and 3.51 to 2.12. Each comparison used 8,064 steady-state draws per revision and verified readback. Inline and pipelined PM4 runs both went from zero to 64 recipe hits on each GPU, with 64 draw-cache hits throughout. For the existing single-sample fast path, the paired candidate/base recording-time ratios were 1.012 on NVIDIA (95% interval 0.935–1.097) and 0.954 on Intel (0.878–1.042). The identical-binary Intel control also varied. All 145 shared CTests retained their outcomes on each adapter, and the added regression passed. Retiring and reacquiring a DCC texture at the same address passed twice per adapter at 2×, 4× and 8×. A Snoopy capture on the reporting RX 6700 XT is still needed to measure title frame time. [Both revisions' traces, measured batches and reproduction instructions](https://github.com/RavenCurseBurg/AnyPS5/tree/5714581c9fe848e63404a48f80d8dc48052791cf/.github/verify-msaa-recipe/integrated-2e566609eeae) The branch merged cleanly with main at `102cad67da`. The overlap checker examined 2,676 open PRs. I compared the four flagged line overlaps and 52 branches that could not merge with main. #19686, #21479 and #25802 change attachment acquisition and layout. #27273 changes draw-key ownership. #11452 adds counters. The reported patches contain no implementation of live native MSAA recipe replay. The tested [counter integration](https://github.com/RavenCurseBurg/AnyPS5/commit/43e2c0f296af35cee6fef4cd3427d6047d698ecf) is available for the reporter's Snoopy run. I merged the upstream DCC texture import change (#21479) at `65ff3ae335ac` and compared the resulting code with that main commit. All 145 shared CTests retained identical outcomes per GPU. The added recipe test passed on both. The RTX 4060 had 143 passes, two skips and one baseline failure. The UHD 770 had 142 passes, one skip and three baseline failures. Both adapters passed all six initial DCC and target takeover cases. A separate native Vulkan check reimported a DCC texture at the same address while retaining its old owner. The old attachment refused replay and the newly acquired attachment replayed. Readback preserved the expected color. This passed twice per adapter at each of 2×, 4× and 8× MSAA with Khronos validation. [Integrated code](https://github.com/RavenCurseBurg/AnyPS5/commit/2e566609eeaeece5236a2ae74a07daf7a76dc8d4) I rechecked the merge of main `80781a0e94` in `6344fbd213`. Recipe creation requires a content key, and ordinary target acquisition keeps main's GCN texture ownership check. On each of the RTX 4060 and UHD 770, all 151 shared CTests retained their outcomes and the additional multisample recipe test passed. The Vulkan validation logs showed no additional diagnostics. [Benchmarks and regression results for this revision](https://github.com/RavenCurseBurg/AnyPS5/tree/f0c97708a934aac8e9ba7a880ae90a0ea436743e/.github/verify-msaa-recipe/integrated-6344fbd21396) I merged upstream `363e0bed4def` into the submitted branch and checked the resulting tree. The project’s code and PR conventions passed. I checked the current GPU overlaps. #9508 changes descriptor-heap handling and #20315 changes host imports. #9897 changes the CheckBufferAliases call next to the multisample feedback guard. If #9897 merges first, I will retain the guard and pass its maxVertex argument to CheckBufferAliases when refreshing this branch. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [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) and the licence notice of code adapted from upstream (see AGENTS.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 (Snoopy measurement pending on #26599) - [x] Unblocks: none - [x] GPUs tested: Windows 11 build 26100, NVIDIA RTX 4060 driver 595.79 and Intel UHD 770 driver 101.5973 - [x] AI-assisted: yes (Codex + GPT-6.2 Astra, xhigh) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> <!-- coderabbit-ai-generated:v1 --> ## Summary by CodeRabbit * **New Features** * Draw recipes now support replay with multisampled color targets when all color targets use multisampling. * Replayed recipes reuse their original multisample attachments. Replay is rejected if an attachment is invalid, replaced, retired, or conflicts with a rendered surface or depth feedback. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
MarcZX10 commented 2026-11-27 15:33:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-27T15:33:57Z.

Review: APPROVED


Reviewed — looks good

The change at head 8eb7c6cc19024eaf73b4411f4ee2acfe91e8954d adds multisample draw recipe replay with live attachment validation; the inspected implementation and regression scenario show no verified blocking defect.

What I ran

Read the prepared diff and source context through repo_read.py; no build or test command was run. The author reports benchmark, CTest, and GPU validation results in the PR description; these were not independently run for this review.

Results

Check Result Note
Patch and changed source review passed Six changed files inspected
Build and tests not run Author reports tests; not independently verified

Findings

Blocking

None.

Non-blocking

None.

Not verified

No checks were executed. I read all six changed files marked included in the manifest: Recipe.hpp, MultisampleTarget.hpp, Draw.cpp, MultisampleTarget.cpp, TargetStateMemo.cpp, and agc_driver_target_memo_tests.cmake. The manifest lists no excluded changed files. GPU behavior and reported performance measurements were not independently confirmed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6090418201 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27849#pullrequestreview-6090418201). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-27T15:33:57Z. **Review:** APPROVED --- # Reviewed — looks good The change at head `8eb7c6cc19024eaf73b4411f4ee2acfe91e8954d` adds multisample draw recipe replay with live attachment validation; the inspected implementation and regression scenario show no verified blocking defect. ## What I ran Read the prepared diff and source context through `repo_read.py`; no build or test command was run. The author reports benchmark, CTest, and GPU validation results in the PR description; these were not independently run for this review. ## Results | Check | Result | Note | |---|---|---| | Patch and changed source review | passed | Six changed files inspected | | Build and tests | not run | Author reports tests; not independently verified | ## Findings ### Blocking None. ### Non-blocking None. ## Not verified No checks were executed. I read all six changed files marked `included` in the manifest: `Recipe.hpp`, `MultisampleTarget.hpp`, `Draw.cpp`, `MultisampleTarget.cpp`, `TargetStateMemo.cpp`, and `agc_driver_target_memo_tests.cmake`. The manifest lists no excluded changed files. GPU behavior and reported performance measurements were not independently confirmed. ## To get this to a good state Nothing is required.
Plyxen commented 2026-12-03 12:38:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Plyxen on 2026-12-03T12:38:04Z.

Review: APPROVED


I read the diff at 8eb7c6cc19. Windows 11, GCC 15.2, merged into main at daa61711afe together with other open PRs (so not an isolated build), with ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 and VK_LAYER_KHRONOS_validation on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2).

  • agc_driver_multisample_color_recipe and the multisample tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a VUID- or SYNC-HAZARD line.
  • Control (the same tree with only this PR's source change taken out): agc_driver_multisample_color_recipe fails with "the native multisample color draw did not build a recipe".

The red windows check is a cancelled run.

Not checked: the timings in the body, and a title.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6169960260 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27849#pullrequestreview-6169960260). Originally posted by [Plyxen](https://github.com/Plyxen) on 2026-12-03T12:38:04Z. **Review:** APPROVED --- I read the diff at `8eb7c6cc19`. Windows 11, GCC 15.2, merged into `main` at `daa61711afe` together with other open PRs (so not an isolated build), with `ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1` and `VK_LAYER_KHRONOS_validation` on an RTX 5080 (621.24) and a Radeon iGPU (26.11.2). - `agc_driver_multisample_color_recipe` and the multisample tests: pass on both GPUs. The loader log shows the layer inserted and no "was not found" line, and neither run has a `VUID-` or `SYNC-HAZARD` line. - Control (the same tree with only this PR's source change taken out): `agc_driver_multisample_color_recipe` fails with "the native multisample color draw did not build a recipe". The red `windows` check is a cancelled run. Not checked: the timings in the body, and a title. AI-assisted: yes (Claude Code)
ligmaSec commented 2026-12-03 20:55:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T20:55:18Z.

Review: COMMENTED


RepeatMultisampleTargetView sets drawn and increments contents while checking each attachment. A later attachment miss, resource proof miss, or expired pipeline can then return Rebuild before recording a draw, leaving earlier targets with an advanced content stamp. Could the recipe verify its attachments first and mark them drawn when it commits to recording? A two-target fixture with only the second target retired would exercise this path.

Source review at 8eb7c6cc19. The head trial-merges onto 6ef4f2f73b. Focused Linux checks are queued.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6178382509 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/27849#pullrequestreview-6178382509). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T20:55:18Z. **Review:** COMMENTED --- `RepeatMultisampleTargetView` sets `drawn` and increments `contents` while checking each attachment. A later attachment miss, resource proof miss, or expired pipeline can then return `Rebuild` before recording a draw, leaving earlier targets with an advanced content stamp. Could the recipe verify its attachments first and mark them drawn when it commits to recording? A two-target fixture with only the second target retired would exercise this path. Source review at `8eb7c6cc19`. The head trial-merges onto `6ef4f2f73b`. Focused Linux checks are queued. AI-assisted: yes.
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!27849
No description provided.