feat(agc): sample non-sRGB textures through FORCE_DEGAMMA samplers as sRGB views #4487
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4487"
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 Pipodi on 2026-10-12T13:21:43Z.
What
A guest sampler with FORCE_DEGAMMA makes the hardware decode the texels of a non-sRGB 8-bit texture as sRGB.
mainrefuses that binding ("…which is not sRGB, is sampled through a sampler that forces sRGB decoding, which is not implemented"). With this change the binding samples an sRGB view of the same image:Texture::SrgbViewcreates the view on first use, for the range the binding needs (full, first layer or base level). The view hasVK_IMAGE_USAGE_SAMPLED_BITusage only and carries the descriptor's minimum LOD.SrgbTwinFormatmaps R8, R8G8, RGBA8, BGRA8, ABGR8 (packed) and BC1/2/3/7 UNORM to their sRGB formats.VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT, so the view is valid. Textures viewed from storage images are already mutable.RequireDegammaFormatbecomesForcesDegammaOn, which tellsShaderResourcesto bind the sRGB view. A texture with no sRGB view (a format without an sRGB twin, or an image that isn't mutable) is still refused, and the message says so.Tested
Windows 11, RTX 4090.
agc_driver_image_sample_force_degamma. The case that expected a rejection for 8_8_8_8_UNORM now checks:On
mainthe new test fails with the old refusal.Validation layer (
VK_LAYER_KHRONOS_validation, SDK 1.4.363.0): the test passes with no errors or warnings. To check that the layer covers the change, I built it once withoutVK_IMAGE_CREATE_MUTABLE_FORMAT_BITon the image. The test still passed on this driver, but the layer reportedVUID-VkImageViewCreateInfo-image-12397(an R8G8B8A8_SRGB view of an R8G8B8A8_UNORM image).Full suite: 966/966 pass; 7 tests skip on this machine (
agc_driver_stencil_ref_export, fivevideo_out_flip_*,guest_video_out_wqhd_detection_no_vulkan).Ghost of Yōtei (PPSA26344): an earlier version of this change let its shader
0x80003fca00sample a BC1 texture through a FORCE_DEGAMMA sampler instead of stopping at the refusal. That version didn't create the image as mutable, which this one fixes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt (the remaining case is a refusal).mdfiles or images added to the repository🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:42Z.
SrgbTwinFormatmapsVK_FORMAT_R8_UNORMandVK_FORMAT_R8G8_UNORMto their sRGB formats without checking that the device can sample them (the new switch inTexture.cpp). Main already has devices that can't:srgbDecodeFormatsinTextureFormat.cppsamples the UNORM format and decodes in the shader there, so on those the forced view would be created with an unsupported format. Please keep the refusal for these two where the device lacks the format, or leave them out until a title needs them.Has this version been run on PPSA26344? The description says only an earlier one was.
Imported from boykopovar/AnyPS5. Originally posted by Tamalero on 2026-10-13T05:33:29Z.
Another data point: High on Life (PPSA15388) stops on this error in its home base (a later save):
With this PR cherry-picked onto my stack (
main3377986aplus #1077, #425, #3202 and #1418), it gets past that stop and stays in gameplay. Theagc_suite has no new failures (Linux, RTX 4090). Details on #4736.Tested and written by Claude (AI assistant) on a contributor's machine.
Imported from boykopovar/AnyPS5. Originally posted by xXPBSXx on 2026-10-13T06:56:42Z.
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main
88107b7detogether with thirteen other open GPU PRs (their own commits cherry-picked, no merge commits), so only the tests that belong to this PR say something about it:tests/execution/ImageSampleForceDegamma.cpp(agc_driver_image_sample_force_degamma): 3 of 3 runs passed.Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed.
AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-13T07:00:54Z.
@oneandonlydean thanks, you're right.
SrgbTwinFormatnow takes the context and returns no twin forR8_UNORM/R8G8_UNORMwhen the matching bit is set insrgbDecodeFormats. That covers both a device that can't sampleR8_SRGB/R8G8_SRGBandAPS5_SRGB_SHADER_DECODE=1. On those devices the image isn't createdMUTABLE_FORMATany more, and a FORCE_DEGAMMA sampler on such a texture keeps the existing refusal. The other formats are unchanged.agc_driver_graphicschecks the twin with no bits, with 8_8 only, and with both.On PPSA26344: no, this exact head hasn't run there. Our Yōtei runs (run85, about 66 minutes, intro and wolf scene, no stop on this error) used a local integration stack. It has the same forced-sRGB change plus the
MUTABLE_FORMATfix that's now in the PR, but on an older base with other unmerged work. So it's evidence for the change, not a run of this head. Tamalero's High on Life result above is on their own stack too.Tests
BUILD_TESTING=ON: 966/966 pass, 7 skipped (stencil ref export, video-out flip tests)agc_driver_graphics(new twin checks) andagc_driver_image_sample_force_degammapass.tools/check_conventions.py --base origin/mainpasses.Tested and written by Claude (AI assistant) on a contributor's machine.