shader: support MIMG float image atomics (FMIN/FMAX) #837
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!837
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/837/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?
@theantipopau on GitHub · 2026-09-25 20:47 UTC · original
theantipopau:mimg-float-atomics→main· +109 −6 · 11 files · 1 commits · closed without mergingProblem
MIMG_ATOMIC_OPCODE_LISTstops at0x1a(IMAGE_ATOMIC_XOR). Opcodes0x1eand0x1fare floatimage atomics, so a shader that uses them cannot be decoded and fails before it ever reaches
translation, the same way a missing-opcode shader fails the CFG stage in #426 and #799.
Changes
The two opcodes are wired through the whole path:
frontend/decode/ImageOps.cpp—0x1e->IMAGE_ATOMIC_FMIN,0x1f->IMAGE_ATOMIC_FMAXfrontend/decode/ShaderDecoder.h/.cpp— theOpcodeenum entries and theirInstructionToStringcasesfrontend/translate/Memory.cpp— theEmitMemorydispatch, and the atomic range end inMemorySourceAtso the operand layout is picked up as an atomicir/opcodes/ValueOpcodes.inc/.cpp—ImageAtomicFMin32/ImageAtomicFMax32, classified as{ImageAccess::Atomic, ImageResourceClass::Storage, false}like the integer image atomicsSPIR-V has no float image atomic, so
backend/spirv/spirvEmitterImage.cppbuilds anOpImageTexelPointerinto the image and reuses the existingAtomicUpdatecompare-exchangemachinery, with
EmitFloatAtomicReplacementdoing an ordered bit-level min or max. That keeps NaNand signed-zero behaviour explicit instead of inheriting whatever the host integer atomic does
with the raw bits. The whole thing stays inside
EmitValueOrZeroIfCondition, so a predicated imageatomic skips the read-modify-write the same way the integer path does.
Atomic images keep the
R32uiABI regardless of the guest numeric type, which means the image typestays a
u32storage image and the descriptor still has to resolve to anR32Uintview. Twovalidation sites had to learn about that:
ir/passes/ResourceMaterialization.cpp— an atomic image descriptor that was notk32UIntwasrejected outright. It now also accepts
k32Float, and the numeric class is forced back toUintfor atomic images so a
k32Floatdescriptor does not trip theSintrejection on the way in.host_gpu/renderer/pipeline/descriptors.cpp—ValidateStorageTexturegains the samefloat_atomiccase, andResolveTextureforceseR32Uintfor an atomick32Floatview the wayit already did for
k32SInt.Testing
Windows, clang-cl + Ninja, Release, on
upstream/main49716600:shader_cfg_tests: passes, including the newTestNewShaderRecompilerImageFloatAtomicTranslation. It drives both opcodes through ak32Floatdescriptor and asserts the decode names, the IR opcodes, that the image stays atomic and
Uint-typed,OpImageTexelPointer/OpAtomicCompareExchange/OpAtomicLoad/OpMemoryBarrierin the binary,R32uiin the disassembly, and that none of the direct integeratomics leak in. The generated SPIR-V is validated.
resource_materialization_tests: all cases passed.ngs2_sampler_tests: all cases passed.kyty_emulator: clean build and link.shader_recompiler_compute_testsdoes not run here: its Vulkan harness aborts at startup withproduction rasterization features are not supportedbecause this driver does not exposeVK_EXT_attachment_feedback_loop_dynamic_state. That happens before any dispatch, so it saysnothing about this change either way. No game was run.
Risk
Additive, and only reached by shaders that use these two opcodes, which could not be decoded before.
No existing opcode, image ABI, or descriptor format changes; the
R32uipath the existing integeratomics rely on is untouched.
Caveat worth stating plainly: I do not have a captured shader or a reported game that uses
0x1e/0x1f. This is a completeness fix for the opcode table, not a fix for a specificcompatibility report. If someone has a game that stops failing because of it, that would be worth a
note on the PR.
@coderabbitai[bot] on GitHub · 2026-09-25 20:56 UTC · original
Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
a64abb13-2fad-4894-88f4-9a5619508059📥 Commits
Reviewing files that changed from the base of the PR and between
497166009cand3b59f7a9b8.📒 Files selected for processing (11)
src/graphics/host_gpu/renderer/pipeline/descriptors.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterImage.cppsrc/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.hsrc/graphics/shader/recompiler/frontend/decode/ImageOps.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.cppsrc/graphics/shader/recompiler/frontend/decode/ShaderDecoder.hsrc/graphics/shader/recompiler/frontend/translate/Memory.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.cppsrc/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.incsrc/graphics/shader/recompiler/ir/passes/ResourceMaterialization.cpptests/shaderCfgTests.cppIncluded review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
Walkthrough
The change adds decoding and IR translation for floating-point image atomic minimum and maximum operations. Atomic 32-bit float storage images use the uint storage class and an R32Uint view. The SPIR-V emitter generates atomic updates for the new operations. A regression test checks translation and validates the generated SPIR-V.
Suggested reviewers:
nmzikPriority: ⬇️ Low
Change: Feature
Merge Risk: ⚪ Minimal · up to
3b59fNo actionable merge-blocking defect was established. The float-image atomic path is ready for normal checks, though runtime behavior has not been tested in a game.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
3b59fThe new operations use the existing storage-image binding rules and atomic update mechanism. No new security bypass was identified, but runtime behavior and some floating-point edge cases remain unverified.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
Full details: Docstring Coverage
Explanation
Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 9 files. (2 skipped: 1 unsupported, 1 too large.)
Comment
@coderabbitai helpto get the list of available commands.@Nmzik on GitHub · 2026-09-26 11:19 UTC · original
Credited
Pull request closed