fix(agc): bind a multisampled sRGB target as a storage image in its UNORM twin #9260

Merged
klosixgaming-arch merged 2 commits from upstream-pr/9260 into main 2026-10-24 02:27:22 +00:00
klosixgaming-arch commented 2026-10-21 16:50:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-21T16:50:23Z.


What

MultisampleTargetStorageView matched a rendered multisampled target only when its VkFormat equalled the requested one. A 4x R8G8B8A8_SRGB target asked for as guest format 56 (R8G8B8A8_UNORM) therefore threw, although both are the same bytes and the target already creates a UNORM storage view for exactly this access. The lookup now matches when both formats resolve to the same host storage format, which holds only for identical formats or an sRGB format and its UNORM twin. An unrelated format of the same size is still refused.

A second commit removes a spec violation the first one makes reachable: after promotion to storage the target's own color view in the sRGB format inherited VK_IMAGE_USAGE_STORAGE_BIT, which sRGB formats do not support (VUID-VkImageViewCreateInfo-usage-02275). The view now excludes the storage usage whenever the image has it, as it already did for targets created with a sample-order storage form.

Cyberpunk 2077 (PPSA03974) stops with this on a 128x64, 4 sample target in character creation, about 21 minutes into a session:
AGC graphics: storage image access to multisampled color target 0x1cca530000 (128x64, 4 samples, vk format 43) as a 128x64 texture of 4 samples and guest format 56 (vk 37) is not implemented

Related, not the same: #8847 matches sRGB twins for resolve and render and says storage-image access in the twin format "still throws as before"; this PR is that case. #9186 rewrites the same if in MultisampleTargetStorageView into a block, so the second of the two to merge needs a trivial rebase.

Tested

Windows 11 (10.0.26200), NVIDIA GeForce RTX 5090, driver 617.42, Vulkan validation layer 1.4.363.0 (VK_LAYER_KHRONOS_validation, inserted for the instance and the device in every test).

New case StorageSrgbTwin in agc_driver_multisample_retirement: renders a 4x R8G8B8A8_SRGB target, asks for a guest format 56 storage view, checks the view is stable on a repeated lookup, and checks guest format 60 is still refused.

  • main cecb540a6 plus the test only: fails with the message above (vk format 43 / guest 56 / vk 37).
  • This PR: passes.

Focused set, ctest -R 'multisample|multisampled|msaa|^agc_recorder|agc_driver_recorder|sampled_cache_budget' with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:

  • main: 25/29 pass, 0 VUID-.
  • First commit only: 25/29 pass, 1 VUID-VkImageViewCreateInfo-usage-02275 (in the new case).
  • This PR: 25/29 pass, 0 VUID-.
  • The 4 that do not pass are agc_driver_msaa_dcc_state (exit 0xc0000139) and agc_driver_msaa_dcc_clear_2/4/8 (not run). They fail identically on main and have no executable in my build directory.

tools/check_conventions.py --base origin/main: passed.

Cyberpunk 2077 (PPSA03974), same machine, a build of this branch merged with #6218 and #7048 (both still open): the session passed character creation and ran past 29 minutes (1767 s in the summary file when this was written) with no driver stop; the storage image access to multisampled color target message did not appear in the log. On main plus #6218, an earlier session with the same kind of play stopped with it at +1253 s. I have not traced whether the new lookup ran in that session, so the unit test above is the direct evidence for the change itself; the game run only shows that this scene no longer stops with it.

Checklist

  • Based on current main; no other open PR implements the same functions (#9186 and #8847 touch nearby lines, neither implements this)
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw; no silent stubs
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: PPSA03974, discussion #8045
  • GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 10.0.26200
  • AI-assisted: yes

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4955176085 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9260). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-21T16:50:23Z. --- ### What `MultisampleTargetStorageView` matched a rendered multisampled target only when its `VkFormat` equalled the requested one. A 4x `R8G8B8A8_SRGB` target asked for as guest format 56 (`R8G8B8A8_UNORM`) therefore threw, although both are the same bytes and the target already creates a UNORM storage view for exactly this access. The lookup now matches when both formats resolve to the same host storage format, which holds only for identical formats or an sRGB format and its UNORM twin. An unrelated format of the same size is still refused. A second commit removes a spec violation the first one makes reachable: after promotion to storage the target's own color view in the sRGB format inherited `VK_IMAGE_USAGE_STORAGE_BIT`, which sRGB formats do not support (`VUID-VkImageViewCreateInfo-usage-02275`). The view now excludes the storage usage whenever the image has it, as it already did for targets created with a sample-order storage form. Cyberpunk 2077 (PPSA03974) stops with this on a 128x64, 4 sample target in character creation, about 21 minutes into a session: `AGC graphics: storage image access to multisampled color target 0x1cca530000 (128x64, 4 samples, vk format 43) as a 128x64 texture of 4 samples and guest format 56 (vk 37) is not implemented` Related, not the same: #8847 matches sRGB twins for resolve and render and says storage-image access in the twin format "still throws as before"; this PR is that case. #9186 rewrites the same `if` in `MultisampleTargetStorageView` into a block, so the second of the two to merge needs a trivial rebase. ### Tested Windows 11 (10.0.26200), NVIDIA GeForce RTX 5090, driver 617.42, Vulkan validation layer 1.4.363.0 (`VK_LAYER_KHRONOS_validation`, inserted for the instance and the device in every test). New case `StorageSrgbTwin` in `agc_driver_multisample_retirement`: renders a 4x `R8G8B8A8_SRGB` target, asks for a guest format 56 storage view, checks the view is stable on a repeated lookup, and checks guest format 60 is still refused. - `main` cecb540a6 plus the test only: fails with the message above (vk format 43 / guest 56 / vk 37). - This PR: passes. Focused set, `ctest -R 'multisample|multisampled|msaa|^agc_recorder|agc_driver_recorder|sampled_cache_budget'` with `ANYPS5_REQUIRE_VULKAN=1`, `ANYPS5_NO_SHADER_CACHE=1`, `VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation`: - `main`: 25/29 pass, 0 `VUID-`. - First commit only: 25/29 pass, 1 `VUID-VkImageViewCreateInfo-usage-02275` (in the new case). - This PR: 25/29 pass, 0 `VUID-`. - The 4 that do not pass are `agc_driver_msaa_dcc_state` (exit 0xc0000139) and `agc_driver_msaa_dcc_clear_2/4/8` (not run). They fail identically on `main` and have no executable in my build directory. `tools/check_conventions.py --base origin/main`: passed. Cyberpunk 2077 (PPSA03974), same machine, a build of this branch merged with #6218 and #7048 (both still open): the session passed character creation and ran past 29 minutes (1767 s in the summary file when this was written) with no driver stop; the `storage image access to multisampled color target` message did not appear in the log. On `main` plus #6218, an earlier session with the same kind of play stopped with it at +1253 s. I have not traced whether the new lookup ran in that session, so the unit test above is the direct evidence for the change itself; the game run only shows that this scene no longer stops with it. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions (#9186 and #8847 touch nearby lines, neither implements this) - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except technical debt - [x] Unimplemented paths throw; no silent stubs - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Fixes: none - [x] Unblocks: PPSA03974, discussion #8045 - [x] GPUs tested: NVIDIA GeForce RTX 5090, driver 617.42, Windows 11 10.0.26200 - [x] AI-assisted: yes AI-assisted: yes. Written with AI assistance and reviewed by me.
klosixgaming-arch commented 2026-10-21 17:24:35 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by klosixgaming-arch on 2026-10-21T17:24:35Z.


Real-title result for PPSA03974 (Cyberpunk 2077 v02.120.000), added after the PR body, and one correction to it.

Setup. Windows 11 (10.0.26200), NVIDIA GeForce RTX 5090, driver 617.42, Ryzen 9 9950X3D. Build: a local merge of main (f90a3f729; this PR's branch is on cecb540a6), #6218 (head 4adf40588), this PR (head 1397502db (same tree as the 23e24862a that I built and ran; the commits were re-authored afterwards to fix the author email)) and #7048 (head 2dd51172f, see my comment there for the one conflict). The game renders at 3200x1800.

Before this PR. On main plus #6218, a session that went through new game, difficulty and life path into character creation stopped about 1253 s after launch with:
AGC graphics: storage image access to multisampled color target 0x1cca530000 (128x64, 4 samples, vk format 43) as a 128x64 texture of 4 samples and guest format 56 (vk 37) is not implemented

With this PR. The same kind of session (same inputs, same scenes) went through character design and on into the first scenes after it, and ran 1878 s (31 minutes) before it stopped. The message above appears 0 times in that log, and the session passed the scene and the time at which the earlier session stopped. I did not trace the lookup in that session, so I cannot show the new code path being taken; the unit test in this PR (fails on main with exactly that message, passes here) is the direct evidence for the change, and the game session is evidence that this stop no longer ends the run.

Correction to the PR body. The body says the session "ran past 29 minutes with no driver stop". That was written while the session was still running. It later stopped at 1878 s with a different message that this PR does not touch:
AGC graphics: only normal color rendering with copy ROP is supported (CB_COLOR_CONTROL 0x005a0010, mode normal)
(ROP3 0x5a is XOR, the driver accepts only the copy ROP 0xcc; I am looking at that separately and will open its own PR if nothing covers it.) So this PR moves the title from the storage-twin stop to the next one; it does not make the title run to gameplay.

Validation layer. Khronos validation 1.4.363 was loaded in every test run (VK_LOADER_DEBUG=layer shows it inserted for the instance and the device). Focused multisample and recorder set, 29 ctest entries: main 0 VUID-, first commit alone 1 (VUID-VkImageViewCreateInfo-usage-02275, the reason for the second commit), this PR 0. The 4 non-passing entries (agc_driver_msaa_dcc_state, agc_driver_msaa_dcc_clear_2/4/8) fail the same way on main and have no executable in my build.

Logs are available if useful: the session summary lines (APS5_TRACE_SUMMARY_EVERY=10) for the session before and after, and the two log excerpts.

AI-assisted: yes. Written with AI assistance and reviewed by me.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6322210151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9260#issuecomment-6322210151). Originally posted by [klosixgaming-arch](https://github.com/klosixgaming-arch) on 2026-10-21T17:24:35Z. --- Real-title result for PPSA03974 (Cyberpunk 2077 v02.120.000), added after the PR body, and one correction to it. **Setup.** Windows 11 (10.0.26200), NVIDIA GeForce RTX 5090, driver 617.42, Ryzen 9 9950X3D. Build: a local merge of `main` (f90a3f729; this PR's branch is on cecb540a6), #6218 (head 4adf40588), this PR (head 1397502db (same tree as the 23e24862a that I built and ran; the commits were re-authored afterwards to fix the author email)) and #7048 (head 2dd51172f, see my comment there for the one conflict). The game renders at 3200x1800. **Before this PR.** On `main` plus #6218, a session that went through new game, difficulty and life path into character creation stopped about 1253 s after launch with: `AGC graphics: storage image access to multisampled color target 0x1cca530000 (128x64, 4 samples, vk format 43) as a 128x64 texture of 4 samples and guest format 56 (vk 37) is not implemented` **With this PR.** The same kind of session (same inputs, same scenes) went through character design and on into the first scenes after it, and ran 1878 s (31 minutes) before it stopped. The message above appears 0 times in that log, and the session passed the scene and the time at which the earlier session stopped. I did not trace the lookup in that session, so I cannot show the new code path being taken; the unit test in this PR (fails on `main` with exactly that message, passes here) is the direct evidence for the change, and the game session is evidence that this stop no longer ends the run. **Correction to the PR body.** The body says the session "ran past 29 minutes with no driver stop". That was written while the session was still running. It later stopped at 1878 s with a different message that this PR does not touch: `AGC graphics: only normal color rendering with copy ROP is supported (CB_COLOR_CONTROL 0x005a0010, mode normal)` (ROP3 0x5a is XOR, the driver accepts only the copy ROP 0xcc; I am looking at that separately and will open its own PR if nothing covers it.) So this PR moves the title from the storage-twin stop to the next one; it does not make the title run to gameplay. **Validation layer.** Khronos validation 1.4.363 was loaded in every test run (VK_LOADER_DEBUG=layer shows it inserted for the instance and the device). Focused multisample and recorder set, 29 ctest entries: `main` 0 `VUID-`, first commit alone 1 (`VUID-VkImageViewCreateInfo-usage-02275`, the reason for the second commit), this PR 0. The 4 non-passing entries (`agc_driver_msaa_dcc_state`, `agc_driver_msaa_dcc_clear_2/4/8`) fail the same way on `main` and have no executable in my build. Logs are available if useful: the session summary lines (`APS5_TRACE_SUMMARY_EVERY=10`) for the session before and after, and the two log excerpts. AI-assisted: yes. Written with AI assistance and reviewed by me.
jotitadev commented 2026-10-21 22:53:14 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-21T22:53:14Z.

Review: COMMENTED


Confirmed red→green on NVIDIA on Linux (the PR's run is an RTX 5090 on Windows).

Tested

Ubuntu 26.04, i7-8700, GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1, device selected with VK_ICD_FILENAMES, run as ./agc_driver_multisample_retirement_tests, on main a6dcea927 (this PR applies cleanly on it).

agc_driver_multisample_retirement NVIDIA RTX 3070 (595.99.02)
main a6dcea927 + the test only (MultisampleTarget.cpp reverted) fail
this PR pass

With MultisampleTarget.cpp reverted and the PR's test kept, the run fails with:

AGC graphics: storage image access to multisampled color target 0x... (256x256, 4 samples, vk format 43) as a 256x256 texture of 4 samples and guest format 56 (vk 37) is not implemented

vk format 43 is R8G8B8A8_SRGB and vk 37 is its R8G8B8A8_UNORM twin — the sRGB→UNORM storage binding this PR adds. With the full PR it passes.

lavapipe (Mesa, LLVM 21.1.8): not a clean signal here. agc_driver_multisample_retirement already fails on main a6dcea927 on lavapipe, with and without this PR, at MSAA storage promotion did not retain its source image — a separate, pre-existing born-storable (sample-order, grid 1x1) issue in StorageRemap, unrelated to this change.

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), Ubuntu 26.04.

Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5607201690 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/9260#pullrequestreview-5607201690). Originally posted by [jotitadev](https://github.com/jotitadev) on 2026-10-21T22:53:14Z. **Review:** COMMENTED --- Confirmed `red→green` on NVIDIA on Linux (the PR's run is an RTX 5090 on Windows). ### Tested Ubuntu 26.04, i7-8700, GCC 15.2.0, Release, `BUILD_TESTING=ON`, `ANYPS5_NO_SHADER_CACHE=1`, device selected with `VK_ICD_FILENAMES`, run as `./agc_driver_multisample_retirement_tests`, on `main` `a6dcea927` (this PR applies cleanly on it). | `agc_driver_multisample_retirement` | NVIDIA RTX 3070 (595.99.02) | |---|---| | `main` `a6dcea927` + the test only (`MultisampleTarget.cpp` reverted) | **fail** | | this PR | **pass** | With `MultisampleTarget.cpp` reverted and the PR's test kept, the run fails with: ``` AGC graphics: storage image access to multisampled color target 0x... (256x256, 4 samples, vk format 43) as a 256x256 texture of 4 samples and guest format 56 (vk 37) is not implemented ``` vk format 43 is `R8G8B8A8_SRGB` and vk 37 is its `R8G8B8A8_UNORM` twin — the sRGB→UNORM storage binding this PR adds. With the full PR it passes. lavapipe (Mesa, LLVM 21.1.8): not a clean signal here. `agc_driver_multisample_retirement` already fails on `main` `a6dcea927` on lavapipe, with and without this PR, at `MSAA storage promotion did not retain its source image` — a separate, pre-existing born-storable (sample-order, grid 1x1) issue in `StorageRemap`, unrelated to this change. GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), Ubuntu 26.04. Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
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!9260
No description provided.