feat(agc): sample sRGB images through UNORM views for SKIP_DEGAMMA #20728
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/20728"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by JJenkx on 2026-11-15T13:54:43Z.
What
A sampler with SKIP_DEGAMMA currently refuses an sRGB texture. Direct sampled bindings now select a compatible UNORM view of the same image, so point and bilinear filtering read encoded values without sRGB conversion. The alias preserves the image swizzle, mip/layer range, minimum LOD and recorded-resource lifetime. Owning sampled and block-copy sRGB images retain their pre-PR creation flags for ordinary sampling; a SKIP request selects a separate mutable-capable cache entry. Already-mutable storage-backed images can provide both views without changing their allocation flags.
Local native gfx1032 measurements cover all seven sRGB/UNORM format pairs (R8, RG8, RGBA8, BC1/2/3/7), both filters, SKIP alone and SKIP plus FORCE: 70 modes, two fixed repeats each, 64 lanes. SKIP equals UNORM in every lane; FORCE takes precedence when both bits are set. The implementation preserves that precedence. This is local RDNA2 evidence; PS5 gfx1013 equivalence is unverified.
An sRGB image paired with samplers requesting conflicting decode modes still throws, as do bindless images requiring SKIP_DEGAMMA and images without a compatible view. The shader fallback for devices without native R8/RG8 sRGB sampling is not extended. No title unblock or performance gain is claimed.
Tested
Linux, Ryzen 7950X, AMD Radeon RX 6650 XT (RADV NAVI23, Mesa 26.2.7), kernel 7.2.14; Vulkan validation 1.4.363 (headers 1.4.335).
Full SDK/relinker and the focused executables build on both pinned trees. The identical fixtures on main
e74dd5b992cd92b9e4e489feabc465df27bb63f6(test-only control0e1c0744329f2c995e66a3309e1b577a67615668) and change89c4ce3dffa3c47f68de03ba6b93e43b288b683fgive:Eight gates per arm execute on the physical GPU, with eight successful validation-layer insertions and eight RX6650XT selections; the ninth is the mocked graphics suite. Environment:
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer. The two uncached cases additionally setAPS5_NO_TEXTURE_CACHE=1. No missing-layer warning. Frozen bank hashes match after each arm.The regression first samples ordinary sRGB twice to populate reuse paths, then samples SKIP twice and returns to normal; it runs with and without the texture cache. A mocked allocation check observes ordinary sRGB creation flags and the mutable-capable replacement on a subsequent SKIP request. The regression compares point/bilinear samples to UNORM values, checks that normal sRGB sampling still decodes, switches back after SKIP to catch stale view selection, checks SKIP on UNORM, and checks measured FORCE precedence. Existing FORCE_DEGAMMA, sRGB loads, multisample sRGB twins, alpha-to-coverage and graphics tests remain passing.
Full native hardware inputs, results and replay script · revised main/change logs, allocation/transition fixtures and source pins. Windows/macOS and native title gameplay are not tested for this change.
Names and branch overlap checks were run. Failed-closed comparisons were retained and the updated shared-file patches scanned alongside the prior review. #7085 adjusts minimum LOD in the same view helper; #5371 adds unsupported-native-format shader fallback. #17255 changes the imported-upload constructor from one import pointer to an import-copy span, so combining them requires retaining that span and this PR's final capability parameter. #9508 moves sampler construction and must retain FORCE-over-SKIP precedence when rebased. These are separate behavior, not dependencies. Conventions and diff checks pass; the branch merges cleanly with
37646cd2caa0eb5edef99bc9bfacf19b2b089c6d. Graphics sources and the existing mocked graphics test file are unchanged between the focused main baseline and that latest-main snapshot.Contributor-reported additional coverage (not rerun on this machine):
89c4ce3dff, driver 617.42, SDK validation 1.4.363.0. Both arms include #19899 on mainbb4181136f. Baseline 1779 passed versus 1783 passed with the change,0 failures/0 VUIDs,18 skipped on each; the same 64 validation messages on both. All four new SKIP_DEGAMMA cases pass. No title or frame-time result.e9cfe038c1, driver 595.99.02 and validation 1.4.341. Ten focused cases pass with 9 confirmed layer insertions and 0 new VUIDs. Reverting the Graphics implementation to main fails all four new SKIP_DEGAMMA cases.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T19:17:36Z.
Review: COMMENTED
Reviewed — no blocking findings
No verified blocking defect was found in the inspected changes; repository checks were not run, and several changed line ranges remain unread.
What I ran
Reviewed PR head
89c4ce3dffa3c47f68de03ba6b93e43b288b683fusing the pinned reader. No build or test commands were run.Results
Negative control
Not run by this reviewer. The description reports a contributor-run reverted implementation check; that result was not independently verified.
Findings
Blocking
None identified in the inspected code.
Non-blocking
None.
Sources
Reviewed the prepared description, commits, manifest, diff, and review README. Inspected changed code in
Sampler.cpp,Texture.hpp,Texture.cpp,ShaderResources.cpp,tests/Graphics.cpp,tests/cmake/agc_driver_image_sample_skip_degamma_tests.cmake,tests/execution/ImageSampleForceDegamma.cpp, anddocs/dev/debt/changes/agc-skip-degamma-sampled-views.mdat the pinned head.Not verified
The review folder excluded full text for
ShaderResources.cpp,Texture.cpp, andtests/Graphics.cpp; only selected ranges from those files were read through the reader. Added lines outside those ranges were not verified. The remaining included changed lines were also not all read. Builds, tests, physical console behavior, and contributor-reported runs were not independently verified.To get this to a good state
Nothing is required. Optionally, complete review of the unread changed lines and run the focused checks on this head.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T13:02:53Z.
Review: COMMENTED
Reviewed — no blocking findings
The change at
17193c160c39d442cf5e69352026617b409af687implements sampled sRGB UNORM views forSKIP_DEGAMMA; no verified blocking defect was found in the code inspected.What I ran
No build or tests were run. I read the prepared description, commits, manifest and diff, plus targeted code at the pinned head. The description reports local Linux/RADV GPU and mock-suite results; those were not rerun here.
Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read changed-file context for
Sampler.hpp,ShaderResources.hpp,Texture.hpp,Sampler.cpp,ShaderResources.cpp,Texture.cpp,Graphics.cpp,agc_driver_image_sample_skip_degamma_tests.cmake,ImageSampleForceDegamma.cpp, andagc-skip-degamma-sampled-views.md. Full texts forShaderResources.cpp,Texture.cpp, andGraphics.cppwere excluded from the review folder as too large; I inspected targeted ranges throughrepo_read.py. The supplied manifest did not includefiles.json, so I could not verify its separate reviewed/excluded listing. I did not run builds or tests, verify native console behavior, or independently validate the contributor-reported and linked hardware results.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by Jazeupoi on 2026-11-21T01:00:57Z.
Review: COMMENTED
Tested on an Apple M4 (MacBook Air, macOS 27.0.1, MoltenVK 1.4.2 from Vulkan SDK 1.4.363.1, x86-64 Release under Rosetta 2); this is the first macOS/MoltenVK run here. Base:
main0a025bd3c6with #17425 and #11049. I applied the diff of head17193c160con top; it applies cleanly. Every run usedANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1and the Khronos validation layer loaded (VK_LOADER_DEBUG=layer); noVUID-message appeared.agc_driver_image_sample_skip_degamma_*guest sampler descriptor disables degamma with an sRGB texture, which is not implementedagc_driver_graphicsimage_sample_force_degamma,image_srgb_load,image_srgb_sample_copy(_forced),multisample_srgb_twin,srgb8_color_target,msaa_dcc_srgb_clear_2/4/8,emulated_color_compare_srgb_decode,recover_srgb_allocation)The skipped one is
msaa_dcc_srgb_clear_8, on both sides. So MoltenVK provides the mutable UNORM views of sRGB images this change relies on.SuperTuxKart (PPSA69421), race on Subsea, seconds 40 to 60, warm cache, alternated runs: frame p50 104.5 and 108.0 ms with this PR, 105.8 and 105.9 ms on the base; GPU busy about 21 ms on both. It draws the same. I saw no change.
AI-assisted: yes (Claude Code)
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-29T02:51:21Z.
Review: COMMENTED
7194cff1-5b25-4c52-84a7-22ed0b95c0a3Reviewing files that changed from the base of the PR and between
b850727449andcc42526e4b.core/libs/prx/libSceAgcDriver/Graphics/include/Sampler.hppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/include/Texture.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Sampler.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Texture.cppcore/libs/prx/libSceAgcDriver/tests/Graphics.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_image_sample_skip_degamma_tests.cmakecore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sampled_cache_budget_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/ImageSampleForceDegamma.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cppdocs/dev/debt/changes/agc-skip-degamma-sampled-views.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-29T03:26:11Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: ensure every sRGB SKIP_DEGAMMA binding receives a texture with a UNORM view, including textures reused through precollected image records and multisample shortcuts.
What I ran
Reviewed head
cc42526e4b461df520393f2414c3b58391a5928busing the prepared diff and the pinned repository reader,repo_read.py. No build or test commands were run in this review.Results
Findings
Blocking
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:6376— WhenprecollectImages()records an existing sampled-cache entry,resolveImageBinding()can accept it throughfastTexture(*record)for SKIP_DEGAMMA without checkingHasUnormView(). The new guard at line 6368 only checks that the cached texture pointer is non-null;fastTexture()revalidates and returns that same entry, and the later descriptor selection callsSampledGammaView(..., false), which throws if the ordinary cached image lacks a UNORM view. This occurs when ordinary sRGB sampling populates the cache before a SKIP request, precisely the reuse order the new regression intends to cover. Apply the UNORM-view capability check to the precollected-record fast path (or force the cache lookup to create the mutable-capable entry).core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp:6374— The first-sample multisample shortcut returns a texture without passingskippedSrgbor validatingHasUnormView(). A multisampled sRGB image requested with SKIP_DEGAMMA can therefore reach UNORM descriptor selection without a prepared UNORM view and throw. Route this case through a compatible view or reject it explicitly before descriptor creation.Non-blocking
None.
Sources
Not verified
No build, automated test, hardware run, or physical-console behavior was verified. The full source text was read for changed files
Sampler.cpp,ShaderResources.cpp, andTexture.cpp; changed-line context was inspected in the prepared diff. Other changed files were not read in full. The author-reported Linux/GPU runs and contributor reports in the description were not rerun. Files excluded from the review folder as too large wereShaderResources.cpp,Texture.cpp, andtests/Graphics.cpp; targeted portions of the first two were read through the pinned reader.To get this to a good state
Ensure cached-record reuse and the first-sample shortcut provide a compatible UNORM view for sRGB SKIP_DEGAMMA requests, then rerun the focused regression tests on the new head.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-12-01T21:25:48Z.
Review: COMMENTED
🏛️ Architecture findings (1)
Advisory architecture findings (1)
f3c2a5ec-a91a-469c-b52a-e0ce7d20ae5eReviewing files that changed from the base of the PR and between
cc42526e4band729856e9dd.core/libs/prx/libSceAgcDriver/Graphics/src/MultisampleTarget.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampleMultisampleTarget.cppdocs/dev/debt/changes/agc-skip-degamma-sampled-views.mdIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-12-02T00:18:31Z.
Review: APPROVED
Reviewed — looks good
The change adds UNORM sampled views for sRGB textures when SKIP_DEGAMMA is effective; I found no verified blocking defect in the changed code.
What I ran
Reviewed head
729856e9ddf26a2f2e779b87dffa73c9c7d72c78, the prepared diff and manifest, and changed source ranges throughrepo_read.py. No build or tests were run. The PR description reports GPU and mocked graphics test results; I did not rerun them. No merged-preview check was run by me; the description reports a clean merge with37646cd2caa0eb5edef99bc9bfacf19b2b089c6d.Results
Negative control
Not run by me. The description reports that reverting the Graphics implementation causes all four new SKIP_DEGAMMA cases to fail on a GTX 1660 SUPER/Linux setup.
Findings
Blocking
None.
Non-blocking
None.
Sources
Not verified
I reviewed the changed portions of all 14 files listed in the manifest; no files were excluded. I did not independently verify the author-reported test results, physical PS5 gfx1013 behavior, Windows/macOS behavior, or native title gameplay. The large implementation and graphics test files were reviewed through targeted ranges rather than read in full.
To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T16:26:00Z.
Review: COMMENTED
On Linux/lavapipe,
agc_driver_image_sample_force_degammaandagc_driver_gcn_scalar_buffer_basepassed on main atba0ff896612band with this head integrated. The four branch cases for point and linear sampling also passed with shader caching disabled, including both uncached variants. All eight test invocations loaded Khronos validation 1.4.369 with Vulkan required. The logs contain no missing-layer warnings or VUIDs.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.