fix(macos): run games on MoltenVK 1.4.x #1083

Closed
github-bot wants to merge 2 commits from gh-pr/1083/head into gh-pr/1083/base
Owner

@⁠juanfariasdev on GitHub · 2026-10-05 22:11 UTC · original
juanfariasdev:fix/macos → main · +74 −13 · 6 files · 2 commits · closed without merging

Summary

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

  • Device setup (vulkanWindow.cpp): MoltenVK does not expose shaderBufferInt64Atomics, shaderCullDistance or VK_EXT_image_view_min_lod, so device selection rejected the only GPU (#1068). On macOS these are no longer required or enabled.
  • Image views (imageView.cpp): on macOS, drop the min-LOD clamp instead of chaining VkImageViewMinLodCreateInfoEXT without the extension.
  • Descriptors (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.
  • Shader recompiler (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 the LaneId use that made Dead Cells pipeline creation fail with Subgroup builtins are not available in this type of function. A macOS-only check in shaderCfgTests.cpp covers it.
  • README: documents MoltenVK 1.4.2 as the validated release.

Known limitations on macOS

  • 64-bit buffer atomics and cull distances are still unavailable, so shaders that use them will fail pipeline creation on MoltenVK.
  • Hades boots but sometimes hits a guest fault on 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_tests pass.
  • Dead Cells (PPSA15552): menu and gameplay.
  • Hades (PPSA03355): boots.

I did not build on Linux or Windows locally. Outside macOS, the only source difference is the position of VK_EXT_image_view_min_lod in the device extension list.

🤖 Generated with Claude Code

**@⁠juanfariasdev** on GitHub · 2026-10-05 22:11 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083) `juanfariasdev:fix/macos` → `main` · +74 −13 · 6 files · 2 commits · closed without merging ## Summary 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 - **Device setup** (`vulkanWindow.cpp`): MoltenVK does not expose `shaderBufferInt64Atomics`, `shaderCullDistance` or `VK_EXT_image_view_min_lod`, so device selection rejected the only GPU (#1068). On macOS these are no longer required or enabled. - **Image views** (`imageView.cpp`): on macOS, drop the min-LOD clamp instead of chaining `VkImageViewMinLodCreateInfoEXT` without the extension. - **Descriptors** (`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. - **Shader recompiler** (`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 the `LaneId` use that made Dead Cells pipeline creation fail with `Subgroup builtins are not available in this type of function`. A macOS-only check in `shaderCfgTests.cpp` covers it. - **README**: documents MoltenVK 1.4.2 as the validated release. ## Known limitations on macOS - 64-bit buffer atomics and cull distances are still unavailable, so shaders that use them will fail pipeline creation on MoltenVK. - Hades boots but sometimes hits a guest fault on `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_tests` pass. - Dead Cells (PPSA15552): menu and gameplay. - Hades (PPSA03355): boots. I did not build on Linux or Windows locally. Outside macOS, the only source difference is the position of `VK_EXT_image_view_min_lod` in the device extension list. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MoltenVK 1.4.2 on Apple M4 Pro lacks shaderBufferInt64Atomics,
shaderCullDistance and VK_EXT_image_view_min_lod, so device selection
rejected the only GPU. Stop requiring and enabling them on macOS, and
drop the image-view min-LOD clamp there instead of chaining an
unenabled struct.

MoltenVK 1.4.1+ leaves buffer-size metadata stale when pushing
descriptors, which corrupts Dead Cells rendering, so use pooled
descriptor sets on those versions.

Metal has no subgroup builtins in vertex shaders. On macOS, also fold
lane-mask projections of all-zero and all-ones masks in wave64
shaders, which removes the LaneId use that failed Dead Cells pipeline
creation.

Every change is behind __APPLE__; other platforms are unchanged.

Validation: shader_cfg_tests, launcher build and install, Dead Cells
gameplay and Hades boot on Apple M4 Pro with MoltenVK 1.4.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Warn at device creation when min LOD, shaderBufferInt64Atomics or
shaderCullDistance are unavailable. Min-LOD clamps are ignored, and
the shader recompiler has no fallback for the other two, so pipelines
that need them may fail.

The idea comes from #1082. Its whole-mip trimming for min LOD is left
out: shrinking the view changes OpImageQuerySizeLod, OpImageQueryLevels
and OpImageFetch results, which the real clamp does not.

Every change is behind __APPLE__.

Co-authored-by: overlordxrz-source <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:42:24 +00:00
github-bot closed this pull request 2026-11-26 09:42:24 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-05 22:22 UTC · original · edited 2026-10-05 23:37 UTC

Review in Change Stack →

📝 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: nmzik

Priority: ⬆️ High

Change: Bug fix · Severity of issue fixed: High

Merge Risk: 🔵 Low · up to 0f86c

Some 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 0f86c

The 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

  • inferred — The supported exposure is guest rendering and shader workloads using the selected Vulkan device in the macOS emulator process. Relaxed admission makes those workloads reachable on previously rejected devices, but the inspected change does not grant new credentials, service authority, or tenant access. Broader host-driver containment was not established.

Trust Boundaries and Controls

  • inferred — The removed requirements are GPU compatibility gates, not demonstrated authorization controls. Device selection retains other required-feature and queue checks, and unsupported Apple capabilities are omitted rather than newly enabled. No security-control bypass was established by the inspected initialization path.

Resilience and Maintainability Implications

  • observed — The descriptor fallback consumes distinct sets from layout-keyed batches. Exhausted pools are tagged with the current semaphore tick and reset only after IsFree reports completion; otherwise a new pool is created. Unexpected allocation failures terminate through assertions. These are source-level reuse controls, not a complete verification of submission ordering, shutdown, concurrent access, or resource-exhaustion containment.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the macOS compatibility changes for MoltenVK 1.4.x.
Description check ✅ Passed The description explains the macOS compatibility changes, their purpose, testing, and known limitations. It is directly related to the changeset.
Linked Issues check ✅ 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 …
Out of Scope Changes check ✅ Passed The MoltenVK 1.4.1+ pooled-descriptor fallback addresses reported rendering corruption during macOS game startup. The lane-mask change and its test address the reported subgroup pipeline failure. The …
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 help to get the list of available commands.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-05 22:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6004354758) · edited 2026-10-05 23:37 UTC <!-- This is an auto-generated comment: summarize by coderabbit.ai --> <!-- review_stack_entry_start --> <a href="https://app.coderabbit.ai/change-stack/KytyPS5/KytyPS5/pull/1083?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=2" alt="Review in Change Stack →" width="220" height="32"></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary>📝 Walkthrough</summary> ## 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:** `nmzik` </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬆️ High <!-- change_assessment_commit:"0f86cae9a2c6882cd81e87a32f4b71dddacf03f5" --> **Change:** Bug fix · **Severity of issue fixed:** High <!-- change_assessment_end --> <!-- final_review_risk_start --> **Merge Risk:** _🔵 Low_ · up to `0f86c` <!-- final_review_risk_coverage:{"sourceCommitId":"0f86cae9a2c6882cd81e87a32f4b71dddacf03f5","coveredCommitId":"0f86cae9a2c6882cd81e87a32f4b71dddacf03f5","kind":"reviewed"} --> Some 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. <!-- final_review_risk_end --> <!-- architecture_review_start --> ### Security Architecture Review **Security architecture risk:** _🔵 Low_ · up to `0f86c` The 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. <details> <summary>Security review details</summary> **Security Blast Radius** - _inferred_ — The supported exposure is guest rendering and shader workloads using the selected Vulkan device in the macOS emulator process. Relaxed admission makes those workloads reachable on previously rejected devices, but the inspected change does not grant new credentials, service authority, or tenant access. Broader host-driver containment was not established. **Trust Boundaries and Controls** - _inferred_ — The removed requirements are GPU compatibility gates, not demonstrated authorization controls. Device selection retains other required-feature and queue checks, and unsupported Apple capabilities are omitted rather than newly enabled. No security-control bypass was established by the inspected initialization path. **Resilience and Maintainability Implications** - _observed_ — The descriptor fallback consumes distinct sets from layout-keyed batches. Exhausted pools are tagged with the current semaphore tick and reset only after IsFree reports completion; otherwise a new pool is created. Unexpected allocation failures terminate through assertions. These are source-level reuse controls, not a complete verification of submission ordering, shutdown, concurrent access, or resource-exhaustion containment. </details> <!-- architecture_review_end --> <!-- pre_merge_checks_walkthrough_start --> <details> <summary>🚥 Pre-merge checks | ✅ 4 | ❌ 1</summary> ### ❌ Failed checks (1 warning) | Check name | Status | Explanation | Resolution | | :----------------: | :--------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------- | | Docstring Coverage | ⚠️ Warning | Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary>✅ Passed checks (4 passed)</summary> | Check name | Status | Explanation | | :------------------------: | :------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ✅ Passed | The title clearly summarizes the macOS compatibility changes for MoltenVK 1.4.x. | | Description check | ✅ Passed | The description explains the macOS compatibility changes, their purpose, testing, and known limitations. It is directly related to the changeset. | | Linked Issues check | ✅ 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 … | | Out of Scope Changes check | ✅ Passed | The MoltenVK 1.4.1+ pooled-descriptor fallback addresses reported rendering corruption during macOS game startup. The lane-mask change and its test address the reported subgroup pipeline failure. The … | </details> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- autopilot:start --> - [ ] <!-- {"checkboxId":"2708ad07-9f24-4260-9c11-7dc76a49f2e3"} --> <strong title="Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts">Autopilot</strong> · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts <!-- autopilot:end --> <!-- tips_start --> --- Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=1083)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary>❤️ Share</summary> - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code) </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
Author
Owner

@⁠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

**@⁠overlordxrz-source** on GitHub · 2026-10-05 22:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6004420448) yo bruh i litrerally pushed the 20 mins before you... check whats going on before you do stuff like this
Author
Owner

@⁠juanfariasdev on GitHub · 2026-10-05 22:32 UTC · original

yo bruh i litrerally pushed the 20 mins before you... check whats going on before you do stuff like this

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:

  1. Push descriptors on MoltenVK 1.4.1+: buffer-size metadata goes stale when pushing descriptors, which corrupts Dead Cells rendering. I fall back to pooled descriptor sets on those versions.
  2. Wave64 lane-mask fold: Metal has no subgroup builtins in vertex shaders. Without folding all-zero/all-ones lane-mask projections, pipeline creation fails with 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.

**@⁠juanfariasdev** on GitHub · 2026-10-05 22:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6004522819) > yo bruh i litrerally pushed the 20 mins before you... check whats going on before you do stuff like this 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: 1. **Push descriptors on MoltenVK 1.4.1+**: buffer-size metadata goes stale when pushing descriptors, which corrupts Dead Cells rendering. I fall back to pooled descriptor sets on those versions. 2. **Wave64 lane-mask fold**: Metal has no subgroup builtins in vertex shaders. Without folding all-zero/all-ones lane-mask projections, pipeline creation fails with `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.
Author
Owner

@⁠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

**@⁠overlordxrz-source** on GitHub · 2026-10-05 22:35 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6004560795) 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
Author
Owner

@⁠juanfariasdev on GitHub · 2026-10-05 22:45 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

@⁠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:

  • Enabling VK_EXT_image_view_min_lod on Apple when MoltenVK advertises it, so a future MoltenVK gets the real clamp.
  • Approximating min-LOD by trimming whole mip levels instead of dropping the clamp. Good idea, but in #1082 the trim happens after the view-cache lookup, so the stored key (trimmed, min_lod = 0) never matches the next lookup (untrimmed). Every FindView with a non-zero min_lod would then create a new VkImageView. I'd do the trim before the lookup, where this PR already normalizes min_lod.
  • The clearer log when 64-bit buffer atomics or cull distances are missing (macOS only).

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 22:45 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6004716698) > 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 @⁠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: - **Enabling `VK_EXT_image_view_min_lod` on Apple when MoltenVK advertises it**, so a future MoltenVK gets the real clamp. - **Approximating min-LOD by trimming whole mip levels** instead of dropping the clamp. Good idea, but in #1082 the trim happens after the view-cache lookup, so the stored key (trimmed, `min_lod = 0`) never matches the next lookup (untrimmed). Every `FindView` with a non-zero `min_lod` would then create a new `VkImageView`. I'd do the trim before the lookup, where this PR already normalizes `min_lod`. - **The clearer log** when 64-bit buffer atomics or cull distances are missing (macOS only). If you're OK with it, I'll port these here and credit you with `Co-authored-by`. Let me know what you think.
Author
Owner

@⁠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:

  • No current MoltenVK exposes VK_EXT_image_view_min_lod, so enabling it "when advertised" would be code that never runs.
  • Whole-mip trimming changes OpImageQuerySizeLod, OpImageQueryLevels and OpImageFetch results 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:

  • Current 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.
  • This branch merged with current main: the device is created, and Dead Cells and Hades both run for 75 s with no MoltenVK errors. Dead Cells also gets past the Subgroup builtins are not available in this type of function blocker 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.
**@⁠juanfariasdev** on GitHub · 2026-10-05 23:10 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6005118440) 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: - No current MoltenVK exposes `VK_EXT_image_view_min_lod`, so enabling it "when advertised" would be code that never runs. - Whole-mip trimming changes `OpImageQuerySizeLod`, `OpImageQueryLevels` and `OpImageFetch` results 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: - Current `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`. - This branch merged with current `main`: the device is created, and Dead Cells and Hades both run for 75 s with no MoltenVK errors. Dead Cells also gets past the `Subgroup builtins are not available in this type of function` blocker 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;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-05 23:33 UTC · original

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

git diff cdb64bfd4fb4d5312b2542a41a0070f25663166a 0f86cae9a2c6882cd81e87a32f4b71dddacf03f5 -- src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp tests/shaderCfgTests.cpp
sed -n '680,725p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
sed -n '12030,12110p' tests/shaderCfgTests.cpp
rg -n 'LaneMaskProjection|UINT32_MAX|WaveSize|wave_size' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp tests/shaderCfgTests.cpp

Repository: KytyPS5/KytyPS5

Length of output: 17829


🏁 Script executed:

sed -n '693,765p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
sed -n '210,300p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
sed -n '12030,12145p' tests/shaderCfgTests.cpp
rg -n -i 'exec(_| )?(lo|hi)|exec_lo|exec_hi|ballot|active.mask|lane.mask|full.mask' src/graphics/shader/recompiler --glob '!**/generated/**'

Repository: KytyPS5/KytyPS5

Length of output: 41218


🏁 Script executed:

nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '118,138p;1078,1105p'
nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '693,765p'
nl -ba tests/shaderCfgTests.cpp | sed -n '12075,12094p'

Repository: KytyPS5/KytyPS5

Length of output: 8091


🏁 Script executed:

rg -n 'FoldInstruction|ValueOpcode::Ballot|CompositeExtractU32x4|ConstantPropagationPass' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp
nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '1,120p;760,830p'
nl -ba src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc | sed -n '208,220p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp | sed -n '475,501p'

Repository: KytyPS5/KytyPS5

Length of output: 10324


🏁 Script executed:

rg -n 'BallotMask\\(|ValueOpcode::LaneId|EmitLaneId|GroupNonUniform.*Invocation|SubgroupLocalInvocation' src/graphics/shader/recompiler
nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '1038,1100p'
nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '198,390p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h | sed -n '1,80p;350,390p'

Repository: KytyPS5/KytyPS5

Length of output: 21186


🏁 Script executed:

rg -n -F 'LaneId' src/graphics/shader/recompiler/backend/spirv
rg -n -F 'EmitLaneId' src/graphics/shader/recompiler/backend/spirv
nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '390,520p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.cpp | sed -n '1,100p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '1,80p'

Repository: KytyPS5/KytyPS5

Length of output: 10967


🏁 Script executed:

rg -n -F 'ConstantPropagationPass(' src/graphics/shader/recompiler
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '620,642p'
nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '332,345p;690,745p;793,810p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '126,131p;1092,1100p'

Repository: KytyPS5/KytyPS5

Length of output: 7374


🏁 Script executed:

rg -n -F 'ValueOpcode::LaneId' src/graphics/shader/recompiler
rg -n -F 'Emit(ValueOpcode::LaneId' src/graphics/shader/recompiler
rg -n -F 'LaneId' src/graphics/shader/recompiler/frontend
nl -ba src/graphics/shader/recompiler/ShaderRecompiler.cpp | sed -n '585,612p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '40,58p'

Repository: KytyPS5/KytyPS5

Length of output: 4075


🏁 Script executed:

nl -ba src/graphics/shader/recompiler/frontend/translate/Control.cpp | sed -n '345,370p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Integer.cpp | sed -n '320,342p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '852,882p'
nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '592,622p'

Repository: KytyPS5/KytyPS5

Length of output: 5802


Recognize the producer form of a full wave64 mask.

When Translator::ThreadBit reads a full wave64 BallotMask, both U32 words represent UINT32_MAX. The function selects one ballot extract before shifting by LaneId & 31, so the guard sees a SelectU32, not an immediate, and returns. CanProject would also reject the high ballot component. The LaneId therefore remains, and EmitLaneId lowers it to EmitSubgroupLocalInvocationId, 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](https://github.com/KytyPS5/KytyPS5/pull/1083#discussion_r4189953040) **🎯 Functional Correctness** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash git diff cdb64bfd4fb4d5312b2542a41a0070f25663166a 0f86cae9a2c6882cd81e87a32f4b71dddacf03f5 -- src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp tests/shaderCfgTests.cpp sed -n '680,725p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp sed -n '12030,12110p' tests/shaderCfgTests.cpp rg -n 'LaneMaskProjection|UINT32_MAX|WaveSize|wave_size' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp tests/shaderCfgTests.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 17829 --- 🏁 Script executed: ```bash sed -n '693,765p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp sed -n '210,300p' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp sed -n '12030,12145p' tests/shaderCfgTests.cpp rg -n -i 'exec(_| )?(lo|hi)|exec_lo|exec_hi|ballot|active.mask|lane.mask|full.mask' src/graphics/shader/recompiler --glob '!**/generated/**' ``` Repository: KytyPS5/KytyPS5 Length of output: 41218 --- 🏁 Script executed: ```bash nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '118,138p;1078,1105p' nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '693,765p' nl -ba tests/shaderCfgTests.cpp | sed -n '12075,12094p' ``` Repository: KytyPS5/KytyPS5 Length of output: 8091 --- 🏁 Script executed: ```bash rg -n 'FoldInstruction|ValueOpcode::Ballot|CompositeExtractU32x4|ConstantPropagationPass' src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '1,120p;760,830p' nl -ba src/graphics/shader/recompiler/ir/opcodes/ValueOpcodes.inc | sed -n '208,220p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterProgram.cpp | sed -n '475,501p' ``` Repository: KytyPS5/KytyPS5 Length of output: 10324 --- 🏁 Script executed: ```bash rg -n 'BallotMask\\(|ValueOpcode::LaneId|EmitLaneId|GroupNonUniform.*Invocation|SubgroupLocalInvocation' src/graphics/shader/recompiler nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '1038,1100p' nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '198,390p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.h | sed -n '1,80p;350,390p' ``` Repository: KytyPS5/KytyPS5 Length of output: 21186 --- 🏁 Script executed: ```bash rg -n -F 'LaneId' src/graphics/shader/recompiler/backend/spirv rg -n -F 'EmitLaneId' src/graphics/shader/recompiler/backend/spirv nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '390,520p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterInstructions.cpp | sed -n '1,100p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '1,80p' ``` Repository: KytyPS5/KytyPS5 Length of output: 10967 --- 🏁 Script executed: ```bash rg -n -F 'ConstantPropagationPass(' src/graphics/shader/recompiler nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterFlow.cpp | sed -n '620,642p' nl -ba src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp | sed -n '332,345p;690,745p;793,810p' nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '126,131p;1092,1100p' ``` Repository: KytyPS5/KytyPS5 Length of output: 7374 --- 🏁 Script executed: ```bash rg -n -F 'ValueOpcode::LaneId' src/graphics/shader/recompiler rg -n -F 'Emit(ValueOpcode::LaneId' src/graphics/shader/recompiler rg -n -F 'LaneId' src/graphics/shader/recompiler/frontend nl -ba src/graphics/shader/recompiler/ShaderRecompiler.cpp | sed -n '585,612p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterTessellation.cpp | sed -n '40,58p' ``` Repository: KytyPS5/KytyPS5 Length of output: 4075 --- 🏁 Script executed: ```bash nl -ba src/graphics/shader/recompiler/frontend/translate/Control.cpp | sed -n '345,370p' nl -ba src/graphics/shader/recompiler/frontend/translate/Integer.cpp | sed -n '320,342p' nl -ba src/graphics/shader/recompiler/frontend/translate/Memory.cpp | sed -n '852,882p' nl -ba src/graphics/shader/recompiler/frontend/translate/Translate.cpp | sed -n '592,622p' ``` Repository: KytyPS5/KytyPS5 Length of output: 5802 --- </details> **Recognize the producer form of a full wave64 mask.** When `Translator::ThreadBit` reads a full wave64 `BallotMask`, both `U32` words represent `UINT32_MAX`. The function selects one ballot extract before shifting by `LaneId & 31`, so the guard sees a `SelectU32`, not an immediate, and returns. `CanProject` would also reject the high ballot component. The `LaneId` therefore remains, and `EmitLaneId` lowers it to `EmitSubgroupLocalInvocationId`, defeating the Apple vertex workaround. Recognize the full ballot pair in both the guard and projection logic while continuing to reject nonuniform words. <!-- fingerprinting:phantom:medusa:serval --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:b39255eaf17885d4bb7d97e1 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-05 23:33 UTC · original · reviewed

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 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.cpp
  • src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-05 23:33 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#pullrequestreview-5421953649) · **reviewed** **Actionable comments posted: 1** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `709d1ac6-c098-4c3c-9650-355afbfffd14` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 769b4cf2d058c9f97a3d5ae13fdf87aa56c620e9 and 0f86cae9a2c6882cd81e87a32f4b71dddacf03f5. </details> <details> <summary>📒 Files selected for processing (2)</summary> * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/graphics/shader/recompiler/ir/passes/ConstantPropagation.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=0776bc5b-49c4-4baf-9c90-001a7619c95c attempt=0ff24456-e667-4125-b8ee-b806b608b5ac batch=1/1 -->
Author
Owner

@⁠overlordxrz-source on GitHub · 2026-10-06 00:32 UTC · original

Independent validation (built + tested, x86_64 macOS no-Qt Release): kyty_emulator links clean, shader_cfg passes. 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.

**@⁠overlordxrz-source** on GitHub · 2026-10-06 00:32 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6006562803) Independent validation (built + tested, x86_64 macOS no-Qt Release): `kyty_emulator` links clean, `shader_cfg` passes. 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.
Author
Owner

@⁠Nmzik on GitHub · 2026-10-21 19:42 UTC · original

Duplicate of #1547.

**@⁠Nmzik** on GitHub · 2026-10-21 19:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1083#issuecomment-6324944688) Duplicate of #1547.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.