shader: convert 11_11_10 UNORM image loads and gathers to float #1115
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!1115
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1115/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?
@NeySlim on GitHub · 2026-10-06 19:44 UTC · original
NeySlim:feat/unorm-11-11-10-storage→main· +137 −14 · 2 files · 1 commits · closed without mergingGod of War Ragnarök (PPSA08332) uses a 1920x1080
k11_11_10UNorm(format 30) render target written by a compute pass.Main now backs the format with
R32_UINTand handles stores (c11254a9) and direct 2Dsample_lz(56738aa4). What is left is reading it withimage_loadand gathers: a load or gather of a sampled 11_11_10 UNORM image stops withpacked UNorm sampling requires a direct 2D sample_lz, and the shared unpack path would return the raw 11/11/10 fields instead of normalized floats.Change
image_loadand gathers of a sampled 11_11_10 UNORM image go through the usual fetch and gather paths; filtered samples still useSamplePackedUnormLz.UnpackImageTexelandUnpackImageGatherconvert each packed UNORM field tofield / (2^bits - 1)as a float, and swizzle constants give 1.0 and 0.0. The result is passed on as a float result, so D16 loads pack halves as for other float formats.The materialization checks of main (single-mip centered 2D image, direct image, bilinear clamp sampler for sampled pairs) are unchanged.
Test
Two new GPU cases next to the packed UINT ones:
ImageLoadPackedUnormConvertsToFloat: anIMAGE_LOADreturns each field divided by 2047 or 1023 as float bits, and a1swizzle returns 1.0.ImageGatherPackedUnormConvertsToFloat:IMAGE_GATHER4_LZof the 10-bit field, of an 11-bit field and of a constant1component on a 2x2 image returns the four texels in gather order as floats.Both stop with the error above on main, and fail when the conversion or the constant handling is removed.
Validation
Linux, AMD Radeon 8060S, Mesa RADV 26.2.3, rebased on
9e41d832. CPU suites pass;shader_recompiler_compute_testsone case per process: 629 of 639, the 10 failures are the same as on main (627 of 637).Not tested on Windows/macOS; the change is platform-independent SPIR-V code.
AI use
I used Claude Code (AI agent) to investigate the failure, write the change and the tests, and run the tests above on my machine. I reviewed the diff and the results before opening this PR.
@coderabbitai[bot] on GitHub · 2026-10-06 19:50 UTC · original · edited 2026-10-14 07:17 UTC
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
d62f7882-dd44-4613-916e-118c1fb69e5c📥 Commits
Reviewing files that changed from the base of the PR and between a39d5c690de48353696c0ce7c0e269e68b92ab32 and
2377f36956.📒 Files selected for processing: 2
src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review.
📝 Walkthrough
The SPIR-V image emitter now returns normalized float values for packed UNORM fields in image reads and gathers. It uses float result types and swizzle constants for these formats, while other packed fields retain their integer values. The special packed sampling path excludes image reads and raw gathers. Two compute tests cover packed UNORM image loads and gathers.
Suggested reviewers:
nmzikPriority: ➖ Normal
Change: Feature
Merge Risk: ⚪ Minimal · up to
2377fThe supported packed-UNORM image paths retain the required conversion and filtering behavior. No new merge-blocking risk is established.
Pre-merge checks:
4 ·
1
Full details: Docstring Coverage
Explanation
Docstring coverage is 18.18% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 2 files. (1 skipped: 1 too large.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@coderabbitai[bot] on GitHub · 2026-10-06 19:50 UTC · original · edited 2026-10-06 19:57 UTC
On
src/graphics/guest_gpu/gpu_format.cppline 243 (outdated):🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 12530
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 33757
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1931
Preserve UNORM filtering for sampled
k11_11_10UNormtextures.k11_11_10UNormnow usesvk::Format::eR32Uint. Linear samplers are created without format-specific rejection or emulation. The shader samples this integer image first and callsUnpackImageTexelafterward, so the UNORM component conversion cannot participate in filtering. Add a sampled-image path that filters the unpacked normalized components, or use a backing format that preserves normalized filtering.@coderabbitai[bot] on GitHub · 2026-10-06 19:51 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
89647e10-34bf-4f1f-b7b5-c0a216e1e737📥 Commits
Reviewing files that changed from the base of the PR and between
199d0a9d92and 0b14de25de3789d2de2d1c220abd8090bfa2091c.📒 Files selected for processing (2)
src/graphics/guest_gpu/gpu_format.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@NeySlim on GitHub · 2026-10-06 19:57 UTC · original
On
src/graphics/guest_gpu/gpu_format.cppline 243 (outdated):Accepted as a known limitation. Sampled use of
k11_11_10UNormwas unsupported before this change (no format info entry, so the materializer aborted); it now resolves to unfiltered reads through the UINT backing, which is the same treatment the existingk11_11_10UIntremap gets. Filtering the unpacked components in the shader can follow if a title samples this format with a linear sampler; none of the GoW Ragnarök shaders do.@coderabbitai[bot] on GitHub · 2026-10-06 19:57 UTC · original
On
src/graphics/guest_gpu/gpu_format.cppline 243 (outdated):@NeySlimThanks for clarifying. This is an accepted filtering limitation, not a regression in previously supported sampled use. Given that the GoW Ragnarök shaders do not require linear sampling of this format, I will not press for filtering support in this PR.Would you like a follow-up issue for filtering the unpacked UNORM components?
✏️ Learnings added
You are interacting with an AI system.
@NeySlim on GitHub · 2026-10-09 19:29 UTC · original
Rebased on main (
59183dbf); the change applied cleanly. Added GPU tests that were missing:ImageLoadPackedUnormConvertsToFloatandImageStorePackedUnormClampsAndRounds(a39d5c69). Both fail without the change. Full GPU suite, one case per process: 604/614, same 10 failures as main (602/612). The description now has Test, Validation and AI use sections.@coderabbitai[bot] on GitHub · 2026-10-09 19:34 UTC · original · reviewed
🧹 Nitpick comments (1)
ℹ️ Review info
⚙️ Run configuration
96ea5396-2f80-447b-8270-fb6c2b2af216📥 Commits
Reviewing files that changed from the base of the PR and between 0b14de25de3789d2de2d1c220abd8090bfa2091c and a39d5c690de48353696c0ce7c0e269e68b92ab32.
📒 Files selected for processing (2)
src/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cpptests/ShaderRecompilerComputeTests.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
@NeySlim on GitHub · 2026-10-14 07:09 UTC · original
Rebased on main. The stores and sample_lz landed in
c11254a9and56738aa4; what is left is the UNORM to float conversion for image_load and gathers, with a test for each.@NeySlim on GitHub · 2026-10-16 17:46 UTC · original
Closing:
1905b28b3decodes 11_11_10 UNORM image loads through the shared conversion, which covers what God of War needed here. Gathers are the only part left, and main rejects them on purpose for now. I'll send that separately if a game actually hits it.Pull request closed