Decode sRGB in the shader for formats the host image cannot carry #167
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!167
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/167/head"
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?
@Death-Whispers-U on GitHub · 2026-08-04 14:39 UTC · original
Death-Whispers-U:fix/shader-srgb-decode→main· +242 −10 · 9 files · 1 commits · closed without mergingPAC-MAN WORLD 2 Re-PAC renders its cutscenes magenta. Everything is there — geometry, detail, motion — but drowned in pink.
R8_SRGBandR8G8_SRGBare optional in Vulkan and plenty of devices expose no features for them at all, sok8Srgbandk8_8Srgbare created as unorm images. That part is already here and is the right call. What is missing is the other half: nothing then supplies the sRGB decode those formats are owed, so the sampled texels stay gamma-encoded and any title that binds one gets a colour cast.PAC-MAN WORLD 2 binds exactly these — its decoded-video planes are
k8Srgbluma andk8_8Srgbchroma.Change
Emit the decode in the shader.
IsShaderDecodedSrgbTextureFormatnames the two formats. It is deliberately not a column in the format table, because this is a property of what the host can express, not of the guest format: every other guest sRGB format has a real host counterpart whose sampler already decodes it, and a shared column would sweep those in and decode them twice.Specialization carries it.
ResourceMaterializationfillssrgb_decodein from the runtime descriptor and rejects a descriptor that no longer matches the permutation that was compiled, and the flag joins the program key — two modules differing only in the decode produce different SPIR-V and must not collide. The uint check cannot stand in for it:k8UNormandk8Srgbare both non-uint and indistinguishable to it.Three details worth flagging for review:
Gather4returns one channel of four neighbouring texels, so it decides the alpha exclusion once, on that channel.Testing
Same cutscene frame, same second, mean channel values:
Red and blue pinned high with green far below them is magenta, numerically. Green minus the average of red and blue goes from −158.0 to −7.9.
Verified again after rebasing onto current main.
@Death-Whispers-U on GitHub · 2026-08-28 14:23 UTC · original
Rebased onto
c52bf450. Windows and macOS are green, Linux is still running.The diff is larger than when this was opened, +242 rather than +130, because main grew indirect image tables in the meantime. One SPIR-V module is compiled for a whole table, so two candidates that disagree about
srgb_decodemust not share one. The flag now threads throughSpecializeResourcesand the null-indirect-root check as well. The added test carries two negative controls, so it fails if the flag ever stops discriminating.One thing I would rather flag than leave implicit. For a plain sampled image with no conversion format,
shader_swizzlestays identity and the guestDstSelis applied by the host image view. The alpha exclusion therefore operates on post-swizzle slots, while Vulkan decodes before component mapping. A descriptor that swizzled the single sRGB channel into slot 3 would go undecoded. I have not seen a title do it, and correcting it needs an inverse-swizzle decision I would rather make with review input than silently.Pull request closed