feat(agc): upload varying guest samples of a multisampled texture no draw rendered to #13146

Merged
Prophet069 merged 2 commits from upstream-pr/13146 into main 2026-11-02 17:27:13 +00:00
Prophet069 commented 2026-10-30 04:15:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Prophet069 on 2026-10-30T04:15:56Z.


What

Sampling or storing to a multisampled R_X or Z_X color texture that no draw rendered to threw when its guest memory held more than one repeated 32-bit value. createFilled now detiles the guest samples with MultisampleTextureLayout::Detile and writes them into the host target with DispatchMultisampleImage through an unsigned storage view; the staging buffer lives only until the recorder finishes. Uniform memory keeps the exact clear as before. D_X, standard swizzles and compressed surfaces still throw. The debt entry is updated; that the console samples such a surface from its guest color memory stays inferred, not measured.

Tested

  • With ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (VVL vulkan-sdk-1.4.321.0; neither log contains was not found but was requested by env var VK_INSTANCE_LAYERS), ctest --test-dir build -R <the 63 tests of agc_shader_memory_tests, agc_driver_cmask_fast_clear_tests, agc_driver_graphics_tests and agc_driver_sample_multisample_target_tests> -V on main 8c8b998620 and on this branch, same machine and GPU: main 63/63 passed, 0 VUID-; this branch 63/63 passed, 0 VUID-. New cases in SampleMultisampleTarget.cpp compare the uploaded samples with the guest bytes.
  • PPSA02015 (Death Stranding 2), Windows, integration branch: without this change the title stopped after 131 s at sampling the 1920x1080 multisampled texture 0xc2e95f0000 of 4 samples, which no draw rendered to … does not hold one repeated 32-bit value (compute shader 0xc280055c00). With it that stop is gone; the next run reached 1800 dispatches (previously 1500) and stopped later at the CMASK/DCC fast clear handled in a separate PR. Whether the upload path itself ran in that run was not logged.
  • The commit changes only the files listed in the diff; it no longer carries the pre-#12916/#12923 tree of the first push.

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
  • GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU (8 GB), driver 616.64, Windows 10 Pro 19045
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5079377589 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13146). Originally posted by [Prophet069](https://github.com/Prophet069) on 2026-10-30T04:15:56Z. --- ### What Sampling or storing to a multisampled R_X or Z_X color texture that no draw rendered to threw when its guest memory held more than one repeated 32-bit value. `createFilled` now detiles the guest samples with `MultisampleTextureLayout::Detile` and writes them into the host target with `DispatchMultisampleImage` through an unsigned storage view; the staging buffer lives only until the recorder finishes. Uniform memory keeps the exact clear as before. D_X, standard swizzles and compressed surfaces still throw. The debt entry is updated; that the console samples such a surface from its guest color memory stays inferred, not measured. ### 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. --> - With `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1` and `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation` (VVL vulkan-sdk-1.4.321.0; neither log contains `was not found but was requested by env var VK_INSTANCE_LAYERS`), `ctest --test-dir build -R <the 63 tests of agc_shader_memory_tests, agc_driver_cmask_fast_clear_tests, agc_driver_graphics_tests and agc_driver_sample_multisample_target_tests> -V` on main `8c8b998620` and on this branch, same machine and GPU: main 63/63 passed, 0 `VUID-`; this branch 63/63 passed, 0 `VUID-`. New cases in `SampleMultisampleTarget.cpp` compare the uploaded samples with the guest bytes. - PPSA02015 (Death Stranding 2), Windows, integration branch: without this change the title stopped after 131 s at `sampling the 1920x1080 multisampled texture 0xc2e95f0000 of 4 samples, which no draw rendered to … does not hold one repeated 32-bit value` (compute shader `0xc280055c00`). With it that stop is gone; the next run reached 1800 dispatches (previously 1500) and stopped later at the CMASK/DCC fast clear handled in a separate PR. Whether the upload path itself ran in that run was not logged. - The commit changes only the files listed in the diff; it no longer carries the pre-#12916/#12923 tree of the first push. ### 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) - [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 - [x] GPUs tested: NVIDIA GeForce RTX 3080 Laptop GPU (8 GB), driver 616.64, Windows 10 Pro 19045 - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
CnRJay commented 2026-11-01 19:47:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:47:45Z.

Review: COMMENTED


The evidence is in good order (main vs branch on the same GPU with validation, no new VUIDs, Death Stranding 2 reaching it). Two points on the new upload path in MultisampleTarget.cpp:

  1. Barrier wider than needed. After the DispatchMultisampleImage loop the barrier is COMPUTE_SHADER -> ALL_COMMANDS with colour attachment, shader and transfer read/write access. The path this replaces ended with TRANSFER -> COLOR_ATTACHMENT_OUTPUT. This runs once per created target, but it is still a full drain of everything recorded after it in the batch, and it is not tied to any consumer. Please narrow the destination to the stages that actually touch the image next (fragment shader / colour attachment output / compute), or say which consumer needs transfer and ALL_COMMANDS.

  2. Whole-surface host staging at creation. guestSampleUpload builds a buffer of width * height * samples * elementBytes (for the 1920x1080, 4-sample case that is about 33 MB for a 4-byte element) and keeps it until the recorder finishes, then dispatches in maxStorageBufferRange-sized pieces. Is the buffer freed as soon as the recorder retires, and is there a cap if a title creates several of these in one frame? A counter for the bytes uploaded and the number of uploads per run in the test would show the cost is bounded.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729916776 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13146#pullrequestreview-5729916776). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T19:47:45Z. **Review:** COMMENTED --- The evidence is in good order (main vs branch on the same GPU with validation, no new VUIDs, Death Stranding 2 reaching it). Two points on the new upload path in `MultisampleTarget.cpp`: 1. **Barrier wider than needed.** After the `DispatchMultisampleImage` loop the barrier is `COMPUTE_SHADER -> ALL_COMMANDS` with colour attachment, shader and transfer read/write access. The path this replaces ended with `TRANSFER -> COLOR_ATTACHMENT_OUTPUT`. This runs once per created target, but it is still a full drain of everything recorded after it in the batch, and it is not tied to any consumer. Please narrow the destination to the stages that actually touch the image next (fragment shader / colour attachment output / compute), or say which consumer needs transfer and ALL_COMMANDS. 2. **Whole-surface host staging at creation.** `guestSampleUpload` builds a buffer of `width * height * samples * elementBytes` (for the 1920x1080, 4-sample case that is about 33 MB for a 4-byte element) and keeps it until the recorder finishes, then dispatches in `maxStorageBufferRange`-sized pieces. Is the buffer freed as soon as the recorder retires, and is there a cap if a title creates several of these in one frame? A counter for the bytes uploaded and the number of uploads per run in the test would show the cost is bounded.
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!13146
No description provided.