Skip to content

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

Open
klosixgaming-arch wants to merge 2 commits into
boykopovar:mainfrom
klosixgaming-arch:fix/agc-msaa-storage-srgb-twin
Open

klosixgaming-arch wants to merge 2 commits into
boykopovar:mainfrom
klosixgaming-arch:fix/agc-msaa-storage-srgb-twin

Conversation

@klosixgaming-arch

Copy link
Copy Markdown
Contributor

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 cecb540 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

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

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 21, 2026
@klosixgaming-arch
klosixgaming-arch force-pushed the fix/agc-msaa-storage-srgb-twin branch from 23e2486 to 1397502 Compare October 21, 2026 17:24
@klosixgaming-arch

Copy link
Copy Markdown
Contributor Author

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 (f90a3f7; this PR's branch is on cecb540), #6218 (head 4adf405), this PR (head 1397502 (same tree as the 23e2486 that I built and ran; the commits were re-authored afterwards to fix the author email)) and #7048 (head 2dd5117, 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.

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 6973 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L191
PR 6987 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L190-191
PR 6989 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L190-191
PR 6995 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L190-191
PR 7002 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L190-191
PR 8604 core/libs/prx/libSceAgcDriver/tests/execution/MultisampleRetirement.cpp L576
PR 9186 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L1091
PR 9700 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp L1090-1091

Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.

Pull request Shared files not compared
PR 6808 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 7642 core/libs/prx/libSceAgcDriver/tests/execution/MultisampleRetirement.cpp
PR 7803 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 8998 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 9508 core/libs/prx/libSceAgcDriver/tests/execution/MultisampleRetirement.cpp
PR 9533 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 9717 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp
PR 9742 core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cpp

@jotitadev jotitadev left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added agc libSceAgc* needs rebase Conflicts with main, rebase needed labels Oct 21, 2026
…NORM twin

MultisampleTargetStorageView required the rendered VkFormat to equal the requested one. A 4x R8G8B8A8_SRGB target asked for as guest format 56 (R8G8B8A8_UNORM) therefore threw "storage image access to multisampled color target ... is not implemented", although the target is created with a UNORM storage view for exactly this access.

The lookup now matches when both formats resolve to the same host storage format, which only holds for an sRGB format and its UNORM twin or for identical formats. Unrelated formats of the same size are still refused.

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

A multisampled sRGB target promoted to storage gained VK_IMAGE_USAGE_STORAGE_BIT on its image, and its color view in the sRGB format inherited that usage. sRGB formats have no storage image feature, so the validation layer reported VUID-VkImageViewCreateInfo-usage-02275 on the first storage access.

The view now excludes the storage usage whenever the image has it, which is what it already did for targets created with a sample-order storage form.

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

Copy link
Copy Markdown
Contributor Author

Rebased onto main a6646f8 (two commits, same two changes). One conflict, in tests/execution/MultisampleRetirement.cpp: main's #8847 added a StorageTwin case in the same spot as this PR's StorageSrgbTwin; I kept both, and the Target(block, format) overload this PR adds. MultisampleTarget.cpp merged without conflict. jotitadev, thank you for the Linux run that showed the test fail on main and pass here.

Windows 11, RTX 5090, driver 617.42, Vulkan validation layer 1.4.363 (inserted for the instance in the run), ANYPS5_REQUIRE_VULKAN=1. ctest -R 'multisample|multisampled|msaa|^agc_recorder|agc_driver_recorder|sampled_cache_budget', 38 entries, on this head and on plain main a6646f8: 25 pass and the same 13 do not pass on both (agc_driver_msaa_layout, agc_driver_msaa_dcc_clear_2/4/8, agc_driver_multisample_centered_lines, agc_driver_multisample_srgb_twin have no executable in my build; agc_driver_native_msaa_vertex_input, agc_driver_msaa_dcc_state, agc_driver_image_msaa_address_on_plane, agc_driver_sample_multisample_target exit 0xc0000139; the three agc_driver_multisample_readback_* fail). The validation layer reports the same 6 VUID-vkDestroyShaderModule-shaderModule-parameter on both, in the resource-cache and sampled-cache-budget tests. agc_driver_multisample_retirement, which holds the new case, passes with 0 new VUID-.

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

@klosixgaming-arch
klosixgaming-arch force-pushed the fix/agc-msaa-storage-srgb-twin branch from 1397502 to 909a9ba Compare October 22, 2026 18:24
@github-actions github-actions Bot removed the needs rebase Conflicts with main, rebase needed label Oct 22, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agc libSceAgc* unblocks title Names a title ID on the Unblocks line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants