fix(shader): sample sRGB textures as UNORM when every paired sampler disables degamma #22644
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/22644"
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-17T23:57:41Z.
What
A sampler with DISABLE_DEGAMMA (S# word 0 bit 31,
SKIP_DEGAMMAin Mesa's gfx10 register description) paired with an sRGB texture threwguest sampler descriptor disables degamma with an sRGB texture, which is not implemented(RequireDisablesDegammaOn). Destruction AllStars (PPSA02630) stops on it.The bit makes the hardware return the stored values of an sRGB texture without the sRGB-to-linear conversion, which is what the UNORM format of the same layout returns.
materializeDisabledDegamma(next tomaterializeForcedDegamma, which does the opposite for FORCE_DEGAMMA on RGBA8_UINT) rewrites a direct, sampled-only, non-comparison image of format 8_SRGB, 8_8_SRGB or 8_8_8_8_SRGB (128, 129, 130) to 8_UNORM, 8_8_UNORM or 8_8_8_8_UNORM (1, 14, 56) when every sampler it is paired with sets the bit. Mixed sampler states, the BC sRGB formats (unmeasured) and table images keep the guest format, so they still reach the existing refusal.Hardware measurement
tools/hw-oracleon an RX 6650 XT (gfx1032, RDNA2, Linux 7.2.14, hsa-rocr 10.1, clang 23.1.5; wave32, IEEE off, DX10 clamp on, denormals preserved, round to nearest even, FP16 overflow off). A 1x1 texel with bytes (40, 120, 200, 255),image_sampleandimage_sample_lzDIM 2D, point sampler00000092 00fff000 05500000 0, with and without bit 31:So with the bit, each sRGB format returns exactly what its UNORM format returns, and the bit does nothing on UNORM. This is an RDNA2 measurement, not PS5 evidence.
Tested
Linux 7.2.14, Ryzen 9 7950X, RX 6650 XT, RADV (Mesa 26.2.7), GCC 16.2.1, Release,
ANYPS5_ENABLE_SPIRV_TOOLS=OFF.agc_driver_image_disabled_degamma: draws a 1x1 texel (40, 120, 200, 255) through a point sampler for 8_8_8_8, 8 and 8_8. With the bit, the sRGB texture draws exactly what the UNORM texture draws, and the bit changes nothing on UNORM; without the bit the sRGB texture still decodes its data channels. WithmaterializeDisabledDegammadisabled the test fails with the originaldisables degamma with an sRGB texturerefusal.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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T01:40:05Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
Changes are required before merge: remove or defer the earlier sRGB/disabled-degamma refusal so execution can reach the new materialization logic.
What I ran
Reviewed head
61b4473e2c5ab779761259d1e920965e821ca624using the prepared diff andrepo_read.py; no commands or tests were run.Results
Findings
Blocking
core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp:3009applies the descriptor rewrite during materialization, butShaderResources.cpp:5994still callsRequireDisablesDegammaOnwhile processing the guest texture and sampler.Sampler.cpp:171throws for this exact pairing, so the draw is rejected before it can reach the changed materializer. Remove or update that refusal for the supported cases, while retaining it for unsupported cases.Non-blocking
None.
Not verified
Tests were not run. All three changed files listed in the manifest were included; source context was read for the materializer and the earlier refusal path. The prepared bundle does not provide a readable
files.json, so additional file exclusions were not verified. PS5 behavior is not verified; the description reports RDNA2 measurements only.To get this to a good state
Update the earlier refusal path to permit the supported direct sampled sRGB cases, then rerun the relevant tests.
Pull request closed