Skip to content

fix(agc): give a block-copied BC texture an sRGB view for FORCE_DEGAMMA samplers - #7799

Merged
adriadam10 merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/bc-block-copy-srgb-view
Oct 23, 2026
Merged

adriadam10 merged 1 commit into
boykopovar:mainfrom
thuanquang:fix/bc-block-copy-srgb-view

Conversation

@thuanquang

@thuanquang thuanquang commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

What

A sampler with FORCE_DEGAMMA samples a BC1, BC2, BC3 or BC7 UNORM texture through an sRGB view of the same image (#4487). That works when the texture is read from guest memory. It does not work while the texture is a block copy of a storage image a shader wrote, before those blocks are stored back. Then the draw is skipped, or the dispatch refused:

a texture of guest format 181, which is not sRGB and has no sRGB view, is sampled through a sampler that forces sRGB decoding, which is not implemented

The block-copy constructor in Texture.cpp creates its image without VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT and never prepares the sRGB view. So the same texture and sampler are refused or served depending only on whether the blocks have been stored back yet. It now does what the upload path does:

  • it sets the mutable flag when SrgbTwinFormat has a twin for the block format (BC4, BC5 and BC6H have none and stay as they are);
  • it calls prepareSrgbView.

The view is still made on first use, and a plain sampler uses the block copy as before. The technical debt is unchanged: its FORCE_DEGAMMA entry never listed block copies.

I found this while checking Ghost of Tsushima's report on #5166. Its format-56 case (8_8_8_8 UNORM) already gets an sRGB view on main; the block-copy path is the one left out. On main, only BC textures whose blocks are still pending in a 32x2 or 32x4 uint storage image take this path. @savvaniss reports in #8159 (closed as a duplicate of this PR, with the same two Texture.cpp lines) that the PS4 path of #6977 also block-copies a smaller view of a render target, and that Trivial Pursuit Live! (CUSA03312, #7198) samples such an 8_8_8_8_UNORM view with FORCE_DEGAMMA before its language menu and stops at the error above.

Tested

Windows 11 26200, AMD Radeon RX 6700 XT (gfx1031), driver 32.0.21045.5002, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on main 1e774a3b2. Runs below use VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation (Vulkan-ValidationLayers vulkan-sdk-1.4.363.0, built locally), ANYPS5_NO_SHADER_CACHE=1, ANYPS5_REQUIRE_VULKAN=1 and ctest -V, with the implicit overlay layers on this PC switched off (VK_LOADER_LAYERS_DISABLE=~implicit~); no log reports the layer as not found.

Checklist

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

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 1368 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 1395 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 4448 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 5609 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6187 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6188 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6192 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6197 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6202 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6209 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6280 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6481 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6539 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6960 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6971 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 6977 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7048 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7085 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7256 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7604 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7642 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 7800 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8246 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8484 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 8998 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9400 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9431 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9432 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9508 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9521 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9672 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9673 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9674 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9675 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9676 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9891 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9892 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9893 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 9895 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp
PR 10193 core/libs/prx/libSceAgcDriver/Graphics/src/Texture.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.

Apple GPU / MoltenVK run, as a second vendor. The block-copy sRGB view works on Metal. agc_driver_bc_block_copy passes with the new FORCE_DEGAMMA cases, and with Texture.cpp reverted it fails with the message from the description.

Machine: Apple M2 Max, macOS 27.2, x86-64 build under Rosetta. Drivers: MoltenVK 1.4.2 (Vulkan SDK 1.4.363.0) and MoltenVK main + SPIRV-Cross #2704. Head d130092, PR diff applied cleanly.

Tested: the tree is main a373e85 + mugurc's macOS series (ci/macos-series-2) + the PRs needed to build on macOS (#6667, #6668, #7524, #6969, and two files of #7332), not plain main (it doesn't build on macOS yet). Applied together in the same build: #7666, #7811, #7799 and #7803, plus a test-only patch that lets nine AGC fixtures load the Vulkan loader on macOS (branch jotitadev:fix/agc-tests-vulkan-loader-macos). Base on that tree: 40 ^agc failures with MoltenVK 1.4.2 and 26 with MoltenVK main + #2704, plus agc_driver_pooled_buffer_range and agc_performance_overlay, which only run because of the loader patch.

  • With the PR: agc_driver_bc_block_copy (BC7 through 32x4 uint blocks, BC1 through 32x2 uint blocks) and agc_driver_image_sample_force_degamma pass 3 of 3 on both drivers. The log shows the block copy of the storage image (guest format 75 -> vk 145, 62 -> vk 133).
  • With only Texture.cpp reverted (test kept), agc_driver_bc_block_copy fails on both drivers: a texture of guest format 181, which is not sRGB and has no sRGB view, is sampled through a sampler that forces sRGB decoding, which is not implemented.
  • Full ^agc suite with the stack: the base failures on each driver, nothing new and nothing gone.

GPUs tested: Apple M2 Max (MoltenVK 1.4.2; MoltenVK main + SPIRV-Cross #2704)

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

@fogydes fogydes 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.

Verified the diff, conventions, and test coverage in PR #7799:

  • Logic: In core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp, setting VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT when SrgbTwinFormat exists and calling prepareSrgbView for block-copied compressed textures aligns the block-copy constructor with the upload path, allowing samplers configured with FORCE_DEGAMMA to sample BC1/BC2/BC3/BC7 formats without rejection.
  • Unit Testing & Debt: Updated test fixtures in tests/execution/BcBlockCopy.cpp verify that pending block copies match stored blocks under forced degamma and remain pending afterwards. Debt entry in docs/dev/debt/libSceAgcDriver.md updated cleanly.
  • Conventions & CI: Zero code comments introduced. All CI checks pass 100% green (conventions, eligibility, labels, report).

@savvaniss

Copy link
Copy Markdown
Contributor

AMD and Intel Windows data: with this PR's test change, agc_driver_bc_block_copy fails on main and passes with the PR, on an AMD RX 9070 XT and an Intel UHD 770.

Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, every execution test built, ANYPS5_NO_SHADER_CACHE=1, serial CTest. Intel UHD Graphics 770 (8086:a780), driver 32.0.101.7088. AMD Radeon RX 9070 XT (1002:7550), driver 32.0.31041.1004, with VkCache emptied first. This head 12c62ebc6 merged into main 85029a00f. "Without" means only this PR's diff to tests/execution/BcBlockCopy.cpp, applied to main 85029a00f.

Tests, ×3 UHD 770 RX 9070 XT
This head: agc_driver_bc_block_copy passes passes
Without fails: a texture of guest format 181, which is not sRGB and has no sRGB view, is sampled through a sampler that forces sRGB decoding, which is not implemented same

AI-assisted: yes (Claude Code)

@adriadam10 adriadam10 self-assigned this Oct 19, 2026
…MA samplers

Co-Authored-By: Claude <noreply@anthropic.com>
@savvaniss

Copy link
Copy Markdown
Contributor

@oneandonlydean asked me to bring my results from #8159 (closed as a duplicate of this PR) here, so here they are. I reran them on this PR's current head 3c905ee2d, since my earlier comment tested 12c62ebc6.

Setup: Windows 11 Pro 26300, WinLibs GCC 15.2.0 r7, Release, AMD Radeon RX 9070 XT (1002:7550, driver 32.0.31041.1004). Every run used ANYPS5_GPU=AMD, ANYPS5_REQUIRE_VULKAN=1 and ANYPS5_NO_SHADER_CACHE=1, and the validation runs added VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation. "With the PR" is 3c905ee2d merged into main 56b299c3a.

agc_driver_bc_block_copy and agc_driver_image_sample_force_degamma, ×3 Result
main 56b299c3a, validation layer both pass, 3 of 3
With the PR, validation layer both pass, 3 of 3
This PR's test with main's Texture.cpp agc_driver_bc_block_copy fails: a texture of guest format 181, which is not sRGB and has no sRGB view, is sampled through a sampler that forces sRGB decoding, which is not implemented

None of the validation logs contains a VUID- line, and none contains was not found but was requested by env var VK_INSTANCE_LAYERS. Each log's Selected GPU line names the RX 9070 XT.

A title: #8159's code change was the same two lines in Texture.cpp as this PR's: the MUTABLE_FORMAT flag when the block format has an sRGB twin, and prepareSrgbView. Ported onto #6977's branch, it let Trivial Pursuit Live! (CUSA03312, a PS4 title) get past this error to its language menu and title screen, at 60 fps on the RX 9070 XT. Without the change, the title stopped at the error above.

I did not rerun the UHD 770 on this head.

AI-assisted: yes (Claude Code)

@thuanquang

Copy link
Copy Markdown
Contributor Author

@savvaniss thanks for bringing these over and rerunning them on this head. I've added your RX 9070 XT runs and the Trivial Pursuit Live! result to the description, with Unblocks: CUSA03312 #7198.

@github-actions github-actions Bot added the unblocks title Names a title ID on the Unblocks line label Oct 20, 2026

@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.

Adds NVIDIA and lavapipe (native Linux) to the devices here: the existing runs are AMD RX 6700 XT / RX 9070 XT and Intel UHD 770 on Windows, plus an Apple M2 Max MoltenVK run. red→green holds on both of mine too.

Tested

Ubuntu 26.04, GCC 15.2.0, Release, BUILD_TESTING=ON, ANYPS5_NO_SHADER_CACHE=1 and ANYPS5_REQUIRE_VULKAN=1, device selected with VK_ICD_FILENAMES, serial CTest, on main a6dcea927 (this PR applies cleanly on it; head 3c905ee2d).

agc_driver_bc_block_copy NVIDIA RTX 3070 (595.99.02) lavapipe (Mesa 26.0.3, LLVM 21.1.8)
main a6dcea927 + the PR's test only (Texture.cpp reverted) fail fail
this PR pass pass

With Texture.cpp reverted and the PR's BcBlockCopy.cpp change kept, both devices exit non-zero with the message this PR removes:

AGC graphics: a texture of guest format 181, which is not sRGB and has no sRGB view, is sampled through a sampler that forces sRGB decoding, which is not implemented

The log shows the block copy landing as a storage image (block copy of storage image (guest format 75 -> vk 145)) and the sample then reaching Texture with guest format 181 and no sRGB view. With the full PR both devices pass. agc_driver_image_sample_force_degamma (the pre-existing force-degamma test) passes with and without the change, so the new path is specific to the block-copied BC case.

The rest of the guarded ^agc suite is unchanged from main on both devices (NVIDIA 858/861, lavapipe 860/861; the deltas are the same pre-existing sample_order / multisample_retirement failures main already has here).

GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8), Ubuntu 26.04.

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

@adriadam10
adriadam10 merged commit 37cb4c8 into boykopovar:main Oct 23, 2026
12 checks passed
@adriadam10

Copy link
Copy Markdown
Collaborator

Re-checked the interdiff: the test now covers both block patterns through a FORCE_DEGAMMA sampler and the pending-blocks store; the mutable-format flag and prepareSrgbView in the block-copy constructor are unchanged. The debt entry is not needed since main already documents the BC sRGB view for this bit. Runs from @jotitadev (NVIDIA, lavapipe) and @savvaniss (RX 9070 XT) cover the claim; merged.

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

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants