fix(macos): run games on MoltenVK 1.4.x #1083
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!1083
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/1083/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?
@juanfariasdev on GitHub · 2026-10-05 22:11 UTC · original
juanfariasdev:fix/macos→main· +74 −13 · 6 files · 2 commits · closed without mergingSummary
Fixes #1068.
Makes KytyPS5 run on macOS with MoltenVK 1.4.x. Every code change is behind
__APPLE__, so Linux and Windows behave exactly as before.#1068 covers device selection, which rejects every Apple GPU. This PR fixes that and also the two issues that come next when booting a game: push-descriptor corruption on MoltenVK 1.4.1+, and vertex shaders that use subgroup builtins, which Metal rejects.
Changes
vulkanWindow.cpp): MoltenVK does not exposeshaderBufferInt64Atomics,shaderCullDistanceorVK_EXT_image_view_min_lod, so device selection rejected the only GPU (#1068). On macOS these are no longer required or enabled.imageView.cpp): on macOS, drop the min-LOD clamp instead of chainingVkImageViewMinLodCreateInfoEXTwithout the extension.shaders.cpp): MoltenVK 1.4.1+ leaves buffer-size metadata stale with push descriptors, which corrupts Dead Cells rendering. Those versions now use pooled descriptor sets.ConstantPropagation.cpp): Metal has no subgroup builtins in vertex shaders. On macOS, lane-mask projections of all-zero and all-ones masks are also folded in wave64 shaders. This removes theLaneIduse that made Dead Cells pipeline creation fail withSubgroup builtins are not available in this type of function. A macOS-only check inshaderCfgTests.cppcovers it.Known limitations on macOS
RenderThread(a write to a null destination). This crash predates these changes and is not addressed here.Testing
Apple M4 Pro, MoltenVK 1.4.2, x86_64 build, also checked after rebasing onto current
main:shader_cfg_testspass.I did not build on Linux or Windows locally. Outside macOS, the only source difference is the position of
VK_EXT_image_view_min_lodin the device extension list.🤖 Generated with Claude Code
@coderabbitai[bot] on GitHub · 2026-10-05 22:22 UTC · original · edited 2026-10-05 23:37 UTC
📝 Walkthrough
Walkthrough
The changes update macOS Vulkan feature and extension requirements, adjust Apple renderer behavior, and add Apple-specific constant propagation for uniform shader masks. The README identifies MoltenVK 1.4.2 as the validated baseline and 1.4.0 and 1.4.1 as supported versions.
Suggested reviewers:
nmzikPriority: ⬆️ High
Change: Bug fix · Severity of issue fixed: High
Merge Risk: 🔵 Low · up to
0f86cSome macOS vertex shaders that derive a lane bit from a fully active wave64 ballot may still fail pipeline creation. The fallback works for immediate masks, but this narrower input remains unsupported.
Security Architecture Review
Security architecture risk: 🔵 Low · up to
0f86cThe macOS compatibility changes admit devices that were previously rejected, but unavailable capabilities remain disabled and shader folding remains narrowly constrained. No introduced security vulnerability was established. Runtime failure handling and resource teardown were not fully verified.
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 warning)
✅ Passed checks (4 passed)
#1068] The Apple path no longer requires min-LOD, buffer-int64-atomic, or cull-distance support for device selection. It omits the min-LOD extension and feature setup, and sets image-view min-LOD to …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.@overlordxrz-source on GitHub · 2026-10-05 22:26 UTC · original
yo bruh i litrerally pushed the 20 mins before you... check whats going on before you do stuff like this
@juanfariasdev on GitHub · 2026-10-05 22:32 UTC · original
Hey, fair point. I should have checked open PRs before pushing, sorry about that. This wasn't a copy, though: I'd been debugging Dead Cells on my M4 Pro since this afternoon (local commits from before yours), and we landed on the same device-selection fix independently.
Your PR covers that part well, but on my machine it isn't enough to boot Dead Cells. Two more fixes were needed:
Subgroup builtins are not available in this type of function.Happy to rebase onto #1082 and keep only those two (plus the MoltenVK 1.4.2 note in the README), so we don't step on each other. Does that work for you?
One small thing: the log lines say 64-bit buffer atomics "will use a fallback" and cull distances "will be dropped", but the recompiler still emits both. Maybe reword them, or I can add the actual handling in a follow-up.
@overlordxrz-source on GitHub · 2026-10-05 22:35 UTC · original
Sorry I didn't mean to come off kinda aggressive I was half joking, great contribution, I'm currently working on improving performance overall, my goal is to make Kyty as prepared as possible for GTA VI lol
@juanfariasdev on GitHub · 2026-10-05 22:45 UTC · original
@overlordxrz-source No worries at all, and good luck with the performance work. GTA VI on Kyty would be something 😄
Since my last comment I went through all of #1082, including your new commit, and I changed my mind about rebasing onto it. The bug only exists on macOS, but #1082 also changes code that runs on Windows and Linux: the feature queries at device creation, the image-view path and the new runtime flags. It should behave the same there, but I'd rather keep a macOS-only fix out of the shared paths, so I'd prefer to keep this PR's approach, where every change is behind
__APPLE__.That said, your follow-up commit has a few things worth bringing over here:
VK_EXT_image_view_min_lodon Apple when MoltenVK advertises it, so a future MoltenVK gets the real clamp.min_lod = 0) never matches the next lookup (untrimmed). EveryFindViewwith a non-zeromin_lodwould then create a newVkImageView. I'd do the trim before the lookup, where this PR already normalizesmin_lod.If you're OK with it, I'll port these here and credit you with
Co-authored-by. Let me know what you think.@juanfariasdev on GitHub · 2026-10-05 23:10 UTC · original
Quick update: I pushed 7901478, which ports the warnings for the features MoltenVK lacks (credited @overlordxrz-source as co-author).
I left out the min-LOD changes from #1082 after all:
VK_EXT_image_view_min_lod, so enabling it "when advertised" would be code that never runs.OpImageQuerySizeLod,OpImageQueryLevelsandOpImageFetchresults in the recompiled shaders, while the real clamp only affects sampling LOD selection. So on MoltenVK the clamp is still dropped rather than approximated.Verified against #1068 on Apple M4 Pro, MoltenVK 1.4.2, x86_64 build:
main(cdb64bf) reproduces the exact error from the issue:Could not find suitable device: Apple M4 Pro: image view minLod is not supported; shaderBufferInt64Atomics is not supported; shaderCullDistance is not supported.main: the device is created, and Dead Cells and Hades both run for 75 s with no MoltenVK errors. Dead Cells also gets past theSubgroup builtins are not available in this type of functionblocker that #1068 reports for GRIS. I don't have GRIS, so I couldn't confirm that its vertex shaders use the same lane-mask pattern this PR folds.@ -710,0 +710,4 @@// Uniform mask words have the same bit in both halves of wave64. Ballot// projections still require wave32 because their low word omits lanes 32-63.const auto mask = Arg(*shift, 0);if (uniform_masks_only && !Immediate(mask, 0u) && !Immediate(mask, UINT32_MAX)) return;@coderabbitai[bot] on GitHub · 2026-10-05 23:33 UTC · original
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 17829
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41218
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 8091
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10324
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 21186
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 10967
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 7374
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 4075
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 5802
Recognize the producer form of a full wave64 mask.
When
Translator::ThreadBitreads a full wave64BallotMask, bothU32words representUINT32_MAX. The function selects one ballot extract before shifting byLaneId & 31, so the guard sees aSelectU32, not an immediate, and returns.CanProjectwould also reject the high ballot component. TheLaneIdtherefore remains, andEmitLaneIdlowers it toEmitSubgroupLocalInvocationId, defeating the Apple vertex workaround. Recognize the full ballot pair in both the guard and projection logic while continuing to reject nonuniform words.@coderabbitai[bot] on GitHub · 2026-10-05 23:33 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
709d1ac6-c098-4c3c-9650-355afbfffd14📥 Commits
Reviewing files that changed from the base of the PR and between 769b4cf2d058c9f97a3d5ae13fdf87aa56c620e9 and
0f86cae9a2.📒 Files selected for processing (2)
src/graphics/presentation/window/vulkanWindow.cppsrc/graphics/shader/recompiler/ir/passes/ConstantPropagation.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@overlordxrz-source on GitHub · 2026-10-06 00:32 UTC · original
Independent validation (built + tested, x86_64 macOS no-Qt Release):
kyty_emulatorlinks clean,shader_cfgpasses. Also verified the design calls against the alternatives: dropping the min-LOD clamp (rather than trimming whole mips, which breaks view-cache coherence and query semantics) is the right fallback, and keeping everything behind__APPLE__with honest known-limitations matches the repo's conventions. The Dead Cells/Hades results are the strongest signal here — device selection was only the first of the three blockers and this covers all of them. Looks good to me.@Nmzik on GitHub · 2026-10-21 19:42 UTC · original
Duplicate of #1547.
Pull request closed