macos: start on MoltenVK without minLod, 64-bit buffer atomics, or cull distance #1547

Open
github-bot wants to merge 3 commits from github-bot/gh-1547 into main AGit
Owner

@⁠theantipopau on GitHub · 2026-10-16 02:59 UTC · original
theantipopau:m5-moltenvk-fallback → main · +186 −17 · 6 files · 3 commits · open

Follow-up to #1448 (and #1083). On Apple silicon the three hard requirements reject the only device, so this demotes them to warnings on APPLE:

  • device selection: minLod, shaderBufferInt64Atomics, and shaderCullDistance log instead of rejecting (same pattern as the existing colorWriteEnable/depthClipEnable Apple branches); VK_EXT_image_view_min_lod becomes optional in the extension check.
  • device creation: the minLod extension is dropped when the driver lacks it, support is queried up front, and only supported feature values are requested so vkCreateDevice succeeds. New GraphicContext flags (supports_image_view_min_lod, shader_buffer_int64_atomics_enabled, shader_cull_distance_enabled) with warnings when unavailable.
  • Image::FindView: whole mip levels from min_lod are remapped into base_level before the view-cache lookup when the extension is missing; the pNext struct is only chained when supported.

Shaders that genuinely need 64-bit buffer atomics or cull distance still fail per-pipeline with a warning instead of blocking boot. I can't test on Apple hardware here — @⁠rpmdiffusion offered an M5 MacBook on #1448, would appreciate a test run.

**@⁠theantipopau** on GitHub · 2026-10-16 02:59 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547) `theantipopau:m5-moltenvk-fallback` → `main` · +186 −17 · 6 files · 3 commits · open Follow-up to #1448 (and #1083). On Apple silicon the three hard requirements reject the only device, so this demotes them to warnings on __APPLE__: - device selection: minLod, shaderBufferInt64Atomics, and shaderCullDistance log instead of rejecting (same pattern as the existing colorWriteEnable/depthClipEnable Apple branches); VK_EXT_image_view_min_lod becomes optional in the extension check. - device creation: the minLod extension is dropped when the driver lacks it, support is queried up front, and only supported feature values are requested so vkCreateDevice succeeds. New GraphicContext flags (supports_image_view_min_lod, shader_buffer_int64_atomics_enabled, shader_cull_distance_enabled) with warnings when unavailable. - Image::FindView: whole mip levels from min_lod are remapped into base_level before the view-cache lookup when the extension is missing; the pNext struct is only chained when supported. Shaders that genuinely need 64-bit buffer atomics or cull distance still fail per-pipeline with a warning instead of blocking boot. I can't test on Apple hardware here — @⁠rpmdiffusion offered an M5 MacBook on #1448, would appreciate a test run.
On Apple silicon (M5) these three requirements hard-reject the only
device. Demote them to warnings on __APPLE__, request only supported
feature values so vkCreateDevice succeeds, make the minLod device
extension optional, and remap whole mip levels into the base level in
Image::FindView when VK_EXT_image_view_min_lod is missing. Shaders
that actually need 64-bit buffer atomics or cull distance still fail
per-pipeline with a warning instead of blocking boot.
Chaining VkPhysicalDeviceImageViewMinLodFeaturesEXT with minLod=FALSE
is still invalid Vulkan usage when VK_EXT_image_view_min_lod is not
enabled - pNext entries must come from enabled extensions. Route
depth_clip_control.pNext around the struct on that path (MoltenVK),
preserving the depth_clip_enable link on other platforms.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:59:22 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 03:01 UTC · original · edited 2026-10-18 23:06 UTC

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

On macOS, Vulkan device selection and creation now treat image-view min LOD, buffer int64 atomics, and shader cull distance as optional capabilities. GraphicContext records their availability. When image-view min LOD is unavailable, Image::FindView adjusts the view range and omits the unsupported min-LOD create info. When cull-distance support is unavailable, the pipeline cache rejects affected programs and records their keys. Draw preparation skips draws when required shader programs are missing. Other platform feature requirements remain unchanged.

Suggested reviewers: nmzik

Priority: ⬇️ Low

Change: Bug fix

Merge Risk: 🔴 Critical · up to 9a757

The change is not ready to merge: it blocks compilation, and the rendering fallbacks can select the wrong mip, keep skipping a changed program, or reach shader-module creation with unsupported atomics.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main macOS MoltenVK compatibility change.
Description check Passed The description directly explains the device-selection, device-creation, image-view, and shader fallback changes.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Autofix · 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-16 03:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6207058336) · edited 2026-10-18 23:06 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/1547?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&amp;cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui-dark.svg?v=3"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg?v=3" alt="Review in Change Stack →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- This is an auto-generated comment: review paused by coderabbit.ai --> > [!NOTE] > ## Reviews paused > > It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the `reviews.auto_review.auto_pause_after_reviewed_commits` setting. > > - Last reviewed commit: 9a757bef21c5e945573672f3755a323364cb0b17 > > Use the following commands to manage reviews: > - `@coderabbitai resume` to resume automatic reviews. > - `@coderabbitai review` to trigger a single review. > > Use the checkboxes below for quick actions: > - [ ] <!-- {"checkboxId":"7f6cc2e2-2e4e-497a-8c31-c9e4573e93d1"} --> ▶️ Resume reviews > - [ ] <!-- {"checkboxId":"e9bb8d72-00e8-4f67-9cb2-caf3b22574fe"} --> 🔍 Trigger review <!-- end of auto-generated comment: review paused by coderabbit.ai --> <!-- walkthrough_start --> <details> <summary><strong>📝 Walkthrough</strong></summary> <dl> <dd> On macOS, Vulkan device selection and creation now treat image-view min LOD, buffer int64 atomics, and shader cull distance as optional capabilities. `GraphicContext` records their availability. When image-view min LOD is unavailable, `Image::FindView` adjusts the view range and omits the unsupported min-LOD create info. When cull-distance support is unavailable, the pipeline cache rejects affected programs and records their keys. Draw preparation skips draws when required shader programs are missing. Other platform feature requirements remain unchanged. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> **Priority:** ⬇️ Low <!-- change_assessment_commit:"9a757bef21c5e945573672f3755a323364cb0b17" --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong>🔴 Critical</strong> · up to <code>9a757</code></summary> <dl> <dd> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🔴 Critical** · up to `9a757` --> <!-- final_review_risk_coverage:{"sourceCommitId":"9a757bef21c5e945573672f3755a323364cb0b17","coveredCommitId":"9a757bef21c5e945573672f3755a323364cb0b17","kind":"reviewed"} --> The change is not ready to merge: it blocks compilation, and the rendering fallbacks can select the wrong mip, keep skipping a changed program, or reach shader-module creation with unsupported atomics. <!-- final_review_risk_end --> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_start --> <details> <summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4 · <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> 1</strong></summary> <dl> <dd> <strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-failed-14-v2.svg" width="14" height="14" align="middle" alt="Failed" title="Failed"></picture></sup> Failed checks: 1 warning</strong> | Check name | Status | Explanation | Resolution | | :---------------- | :----------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :--------------------------------------------------------------------------------- | | Docstring Coverage | ![Warning](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg) | Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 6 files. | Write docstrings for the functions missing them to satisfy the coverage threshold. | <details> <summary><strong><sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> Passed checks: 4 passed</strong></summary> <dl> <dd> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :---------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title clearly and concisely describes the main macOS MoltenVK compatibility change. | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description directly explains the device-selection, device-creation, image-view, and shader fallback changes. | | Linked Issues check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | | Out of Scope Changes check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | Check skipped because no linked issues were found for this pull request. | </dd> </dl> </details> </dd> </dl> </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">Autofix</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=1547)! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. <details> <summary><strong>❤️ Share</strong></summary> <dl> <dd> - [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) </dd> </dl> </details> <sub>Comment `@coderabbitai help` to get the list of available commands.</sub> <!-- tips_end -->
@ -312,0 +318,4 @@
// the remapped key is what gets cached and reused.
const uint32_t skip =
std::min(normalized.min_lod / 256u, normalized.level_count - 1u);
normalized.base_level += skip;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 03:01 UTC · original

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Preserve explicit LOD addressing in the fallback.

If a shader samples with an explicit LOD, moving base_level also moves the mip that the shader addresses. For example, with base level 0, minimum LOD 1, and explicit LOD 2, this fallback changes the selected mip from 2 to 3. Vulkan interprets the shader LOD relative to the view’s base mip level. Account for the base shift in affected shader operations, or reject those operations when the extension is unavailable; changing the view alone does not preserve their result. (docs.vulkan.org)

**@⁠coderabbitai[bot]** on GitHub · 2026-10-16 03:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4290430900) **🎯 Functional Correctness** | **🟠 Major** | **🏗️ Heavy lift** **Preserve explicit LOD addressing in the fallback.** If a shader samples with an explicit LOD, moving `base_level` also moves the mip that the shader addresses. For example, with base level 0, minimum LOD 1, and explicit LOD 2, this fallback changes the selected mip from 2 to 3. Vulkan interprets the shader LOD relative to the view’s base mip level. Account for the base shift in affected shader operations, or reject those operations when the extension is unavailable; changing the view alone does not preserve their result. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/textures.html?utm_source=openai)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:61c8c2a71a4b143790d70207 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -425,0 +462,4 @@
for (const char* ext: device_extensions_in) {
#if defined(__APPLE__)
if (strcmp(ext, VK_EXT_IMAGE_VIEW_MIN_LOD_EXTENSION_NAME) == 0 &&
!HasExtension(available_create_extensions, ext)) {
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 03:01 UTC · original · edited 2026-10-18 08:42 UTC

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Remove the min-LOD feature structure when the extension is absent.

If this branch removes VK_EXT_image_view_min_lod, depth_clip_control.pNext still chains image_view_min_lod into vkCreateDevice. Setting minLod to VK_FALSE does not make that structure valid: a device-creation pNext structure must be defined by an enabled extension. This leaves the intended MoltenVK fallback with invalid Vulkan usage and can prevent startup. Chain the feature structure only when the extension is enabled. (docs.vulkan.org)

✅ Addressed in commit 3c2cc47

**@⁠coderabbitai[bot]** on GitHub · 2026-10-16 03:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4290430905) · edited 2026-10-18 08:42 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** **Remove the min-LOD feature structure when the extension is absent.** If this branch removes `VK_EXT_image_view_min_lod`, `depth_clip_control.pNext` still chains `image_view_min_lod` into `vkCreateDevice`. Setting `minLod` to `VK_FALSE` does not make that structure valid: a device-creation `pNext` structure must be defined by an enabled extension. This leaves the intended MoltenVK fallback with invalid Vulkan usage and can prevent startup. Chain the feature structure only when the extension is enabled. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/fundamentals.html)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:f062525af4654cb9d8f36f81 --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commit 3c2cc47
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-16 03:01 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2db48bed-5f0e-4ca9-8628-603e00aa51af
📥 Commits

Reviewing files that changed from the base of the PR and between 3ff6606fcb and 3bfbbba8a3809a3fbd9c66f25236715f2ac1abf4.

📒 Files selected for processing: 3
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/presentation/window/vulkanWindow.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-16 03:01 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#pullrequestreview-5542509155) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `2db48bed-5f0e-4ca9-8628-603e00aa51af` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 3ff6606fcb6c1cae3aa46ef619f14b28efd3705d and 3bfbbba8a3809a3fbd9c66f25236715f2ac1abf4. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/image/imageView.cpp` * `src/graphics/presentation/window/vulkanWindow.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=d4e4d223-08d9-4867-a229-1123bd87d1cc attempt=a0429538-cbac-42d6-bb5e-d01d91f69e4a batch=1/1 -->
Author
Owner

@⁠wuboo on GitHub · 2026-10-16 17:00 UTC · original

The min_lod part overlaps with #1314, which does the same base-level remap when VK_EXT_image_view_min_lod is missing, with a few differences:

  • it rounds the skipped levels up (ceil(MinLod / 256)), so a partially resident mip is never sampled;
  • it corrects image_get_resinfo: the shader gets the T# extent and level count, not those of the shifted view;
  • it leaves storage and Dynamic-mip images alone.

It is tested on an M3 Max in Astro Bot (the streamed terrain textures), plus CPU tests and mutants.

Maybe this PR could keep the device-selection part (int64 atomics and cull distance as warnings) and rely on #1314 for min_lod? Happy to test this branch on an M3 Max if that helps.

**@⁠wuboo** on GitHub · 2026-10-16 17:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6220563140) The min_lod part overlaps with #1314, which does the same base-level remap when `VK_EXT_image_view_min_lod` is missing, with a few differences: - it rounds the skipped levels up (`ceil(MinLod / 256)`), so a partially resident mip is never sampled; - it corrects `image_get_resinfo`: the shader gets the T# extent and level count, not those of the shifted view; - it leaves storage and Dynamic-mip images alone. It is tested on an M3 Max in Astro Bot (the streamed terrain textures), plus CPU tests and mutants. Maybe this PR could keep the device-selection part (int64 atomics and cull distance as warnings) and rely on #1314 for min_lod? Happy to test this branch on an M3 Max if that helps.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-17 22:53 UTC · original

@⁠wuboo thanks for the comparison. Agreed: #1314's approach (ceil shift, RESINFO correction, storage/dynamic-mip guards, mutant tests) is strictly better than the floor-remap in this PR's imageView.cpp hunk. Plan: once #1314 merges I'll rebase this branch to drop the imageView.cpp remap and keep only the device-selection fallback (int64 atomics + cull distance as warnings, minLod extension optional). Until then I'll leave the remap in place so MoltenVK has some clamping. And yes, please do test this branch on the M3 Max if you get a chance.

**@⁠theantipopau** on GitHub · 2026-10-17 22:53 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6242625193) @⁠wuboo thanks for the comparison. Agreed: #1314's approach (ceil shift, RESINFO correction, storage/dynamic-mip guards, mutant tests) is strictly better than the floor-remap in this PR's imageView.cpp hunk. Plan: once #1314 merges I'll rebase this branch to drop the imageView.cpp remap and keep only the device-selection fallback (int64 atomics + cull distance as warnings, minLod extension optional). Until then I'll leave the remap in place so MoltenVK has some clamping. And yes, please do test this branch on the M3 Max if you get a chance.
Author
Owner

@⁠theantipopau on GitHub · 2026-10-18 08:42 UTC · original

Fixed the device-creation pNext issue in 3c2cc47: the minLod feature struct is now skipped entirely when the extension is absent (previously chained with minLod=FALSE, which is still invalid Vulkan usage and could fail vkCreateDevice on MoltenVK). Non-Apple chain still links depth_clip_enable. The explicit-LOD concern above is real but is exactly what #1314 solves (RESINFO correction + guards); per my plan above this PR's remap goes away once #1314 merges.

**@⁠theantipopau** on GitHub · 2026-10-18 08:42 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6247757299) Fixed the device-creation pNext issue in 3c2cc47: the minLod feature struct is now skipped entirely when the extension is absent (previously chained with minLod=FALSE, which is still invalid Vulkan usage and could fail vkCreateDevice on MoltenVK). Non-Apple chain still links depth_clip_enable. The explicit-LOD concern above is real but is exactly what #1314 solves (RESINFO correction + guards); per my plan above this PR's remap goes away once #1314 merges.
Author
Owner

@⁠wuboo on GitHub · 2026-10-18 09:26 UTC · original

Thanks! Happy to test this branch on the M3 Max, but on current main it won't get far on its own: once device selection accepts the GPU with your fallback, the next hard requirement is VK_EXT_robustness2 nullDescriptor, which MoltenVK doesn't report, so startup still stops with "Could not find suitable device". I've opened #1635 for that (a 1x1 stand-in image per format when nullDescriptor is unsupported; the native null path stays unchanged elsewhere).

For reference, on our macOS stack Astro Bot also needed the driver direct-memory base fix (same issue as #1454) and #1528 to get past boot. With those plus this PR, #1314 and #1635, it runs on the M3 Max. I'll post the results once I've run your branch on top of #1635.

**@⁠wuboo** on GitHub · 2026-10-18 09:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6248228337) Thanks! Happy to test this branch on the M3 Max, but on current main it won't get far on its own: once device selection accepts the GPU with your fallback, the next hard requirement is `VK_EXT_robustness2` `nullDescriptor`, which MoltenVK doesn't report, so startup still stops with "Could not find suitable device". I've opened #1635 for that (a 1x1 stand-in image per format when `nullDescriptor` is unsupported; the native null path stays unchanged elsewhere). For reference, on our macOS stack Astro Bot also needed the driver direct-memory base fix (same issue as #1454) and #1528 to get past boot. With those plus this PR, #1314 and #1635, it runs on the M3 Max. I'll post the results once I've run your branch on top of #1635.
Author
Owner

@⁠wuboo on GitHub · 2026-10-18 18:43 UTC · original

Tested your branch on an M3 Max (macOS 26, x86_64 build under Rosetta): origin/main (099de8de) + this PR + #1669, no other local patches or env.

  • MoltenVK: still rejected at selection with "nullDescriptor is not supported" (vulkanWindow.cpp:1107), so it never reaches the minLod / int64-atomics paths changed here.
  • KosmicKrisp (Mesa, loaded via SDL_VULKAN_LIBRARY / VK_DRIVER_FILES): with your fallback plus #1669 (portability_subset only when the device has it, fillModeNonSolid optional), device selection and vkCreateDevice succeed. The minLod and shaderBufferInt64Atomics warnings show up as expected. A few seconds later it stops on an unrelated issue: agc.cpp:4150 address != DriverDmemBase (the fixed direct-memory base can't be mapped). 2/2 starts were identical.

So no frames yet on either driver, but the device-creation part of this PR works on KosmicKrisp. Next step on our side is the DriverDmemBase mapping.

**@⁠wuboo** on GitHub · 2026-10-18 18:43 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6253686413) Tested your branch on an M3 Max (macOS 26, x86_64 build under Rosetta): origin/main (099de8de) + this PR + #1669, no other local patches or env. - MoltenVK: still rejected at selection with "nullDescriptor is not supported" (vulkanWindow.cpp:1107), so it never reaches the minLod / int64-atomics paths changed here. - KosmicKrisp (Mesa, loaded via SDL_VULKAN_LIBRARY / VK_DRIVER_FILES): with your fallback plus #1669 (portability_subset only when the device has it, fillModeNonSolid optional), device selection and vkCreateDevice succeed. The minLod and shaderBufferInt64Atomics warnings show up as expected. A few seconds later it stops on an unrelated issue: `agc.cpp:4150 address != DriverDmemBase` (the fixed direct-memory base can't be mapped). 2/2 starts were identical. So no frames yet on either driver, but the device-creation part of this PR works on KosmicKrisp. Next step on our side is the DriverDmemBase mapping.
@ -519,0 +604,4 @@
features12.shaderBufferInt64Atomics == VK_TRUE;
if (!graphics.shader_buffer_int64_atomics_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderBufferInt64Atomics is unavailable; shaders using 64-bit buffer atomics will fail.\n");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-18 22:22 UTC · original · edited 2026-10-18 22:30 UTC

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '592,613p' src/graphics/presentation/window/vulkanWindow.cpp
sed -n '258,287p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
sed -n '740,757p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
sed -n '290,322p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 5770


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- CompileSPV and pipeline compilation ---'
rg -n -F -- 'CompileSPV(' src/graphics/host_gpu src/graphics/shader || test "$?" -eq 1
rg -n -F -- 'EXIT_IF(module == nullptr)' src/graphics/host_gpu src/graphics/shader || test "$?" -eq 1
sed -n '860,910p' src/graphics/shader/recompiler/ShaderRecompiler.cpp
sed -n '270,315p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
printf '%s\n' '--- buffer atomic producer and IR fields ---'
rg -n -F -e 'buffer_int64_atomics' -e 'BufferInt64' -e 'Atomic' src/graphics/shader src/graphics/host_gpu/renderer | head -160
sed -n '500,540p' src/graphics/shader/recompiler/ir/ShaderIR.h
printf '%s\n' '--- cull-distance emission and feature flag reads ---'
rg -n -F -e 'cull_distance' -e 'shader_cull_distance_enabled' src/graphics/shader src/graphics/host_gpu src/graphics/presentation/window/vulkanWindow.cpp | head -160
sed -n '570,615p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
sed -n '735,775p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp

Repository: KytyPS5/KytyPS5

Length of output: 37671


🏁 Script executed:

set -o pipefail
sed -n '115,150p' src/graphics/host_gpu/vulkanCommon.cpp
sed -n '300,326p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
rg -n -F -- 'shader_buffer_int64_atomics_enabled' src
rg -n -F -- 'shader_cull_distance_enabled' src

Repository: KytyPS5/KytyPS5

Length of output: 3354


🏁 Script executed:

set -o pipefail
rg -n -F -e 'struct Permutation' -e 'class Permutation' -e 'CompilePermutation(' -e 'permutations.push_back' -e 'permutations.emplace_back' -e 'module' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
sed -n '1,180p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
sed -n '280,350p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
rg -n -F -e 'shader_int64' -e 'unsupported' -e 'nullptr' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 13838


Reject unsupported buffer-atomic permutations before shader-module creation.

When shaderBufferInt64Atomics is unavailable, a buffer-atomic shader can still emit spv::CapabilityInt64Atomics. CompileSPV then passes the module to vkCreateShaderModule; RequireVulkanSuccess calls EXIT when creation fails. Route this permutation through a contained unsupported-pipeline result before CompileSPV.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 22:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309015829) · edited 2026-10-18 22:30 UTC **🩺 Stability & Availability** | **🟡 Minor** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '592,613p' src/graphics/presentation/window/vulkanWindow.cpp sed -n '258,287p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp sed -n '740,757p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp sed -n '290,322p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 5770 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- CompileSPV and pipeline compilation ---' rg -n -F -- 'CompileSPV(' src/graphics/host_gpu src/graphics/shader || test "$?" -eq 1 rg -n -F -- 'EXIT_IF(module == nullptr)' src/graphics/host_gpu src/graphics/shader || test "$?" -eq 1 sed -n '860,910p' src/graphics/shader/recompiler/ShaderRecompiler.cpp sed -n '270,315p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp printf '%s\n' '--- buffer atomic producer and IR fields ---' rg -n -F -e 'buffer_int64_atomics' -e 'BufferInt64' -e 'Atomic' src/graphics/shader src/graphics/host_gpu/renderer | head -160 sed -n '500,540p' src/graphics/shader/recompiler/ir/ShaderIR.h printf '%s\n' '--- cull-distance emission and feature flag reads ---' rg -n -F -e 'cull_distance' -e 'shader_cull_distance_enabled' src/graphics/shader src/graphics/host_gpu src/graphics/presentation/window/vulkanWindow.cpp | head -160 sed -n '570,615p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp sed -n '735,775p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 37671 --- 🏁 Script executed: ```bash set -o pipefail sed -n '115,150p' src/graphics/host_gpu/vulkanCommon.cpp sed -n '300,326p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp rg -n -F -- 'shader_buffer_int64_atomics_enabled' src rg -n -F -- 'shader_cull_distance_enabled' src ``` Repository: KytyPS5/KytyPS5 Length of output: 3354 --- 🏁 Script executed: ```bash set -o pipefail rg -n -F -e 'struct Permutation' -e 'class Permutation' -e 'CompilePermutation(' -e 'permutations.push_back' -e 'permutations.emplace_back' -e 'module' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp sed -n '1,180p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp sed -n '280,350p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp rg -n -F -e 'shader_int64' -e 'unsupported' -e 'nullptr' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 13838 --- </details> **Reject unsupported buffer-atomic permutations before shader-module creation.** When `shaderBufferInt64Atomics` is unavailable, a buffer-atomic shader can still emit `spv::CapabilityInt64Atomics`. `CompileSPV` then passes the module to `vkCreateShaderModule`; `RequireVulkanSuccess` calls `EXIT` when creation fails. Route this permutation through a contained unsupported-pipeline result before `CompileSPV`. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:6bbe6c2d654fba7d1801c590 --> <!-- This is an auto-generated reply by CodeRabbit -->
@ -606,0 +701,4 @@
graphics.shader_cull_distance_enabled = device_features.shaderCullDistance == VK_TRUE;
if (!graphics.shader_cull_distance_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderCullDistance is unavailable; cull-distance exports will be dropped.\n");
Author
Owner

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

sed -n '688,712p' src/graphics/presentation/window/vulkanWindow.cpp
sed -n '580,612p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
sed -n '634,656p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp
sed -n '750,770p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp

Repository: KytyPS5/KytyPS5

Length of output: 5122


🏁 Script executed:

set -u
printf '%s\n' '--- pipeline compile bindings ---'
rg -n -F --glob '*.{cpp,h,hpp}' -e 'CompilePermutation' -e 'CompileProgram' -e 'EmitProgram' -e 'shader_cull_distance_enabled' src/ || test "$?" -eq 1
printf '%s\n' '--- pipeline compile source ---'
sed -n '180,280p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
sed -n '850,915p' src/graphics/shader/recompiler/ShaderRecompiler.cpp
printf '%s\n' '--- local Vulkan feature references ---'
rg -n -F --glob '*.{cpp,h,hpp,md,txt}' -e 'shaderCullDistance' -e 'CullDistance' . || test "$?" -eq 1

Repository: KytyPS5/KytyPS5

Length of output: 11324


🏁 Script executed:

set -u
printf '%s\n' '--- CompilePermutation ---'
sed -n '285,335p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
printf '%s\n' '--- pipeline creation consumers ---'
rg -n -F --glob 'src/graphics/host_gpu/renderer/pipeline/*.{cpp,h,hpp}' -e 'vkCreateGraphicsPipelines' -e 'vkCreateComputePipelines' -e 'ShaderProgram' -e 'permutation.handle' -e 'entry->second' src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1
printf '%s\n' '--- relevant pipeline creation block ---'
sed -n '335,475p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 13482


🌐 Web query:

official Vulkan specification shaderCullDistance CullDistance capability feature pipeline shader module

💡 Result:

In the current Vulkan 1.4.365 specification:

- **`shaderCullDistance` is a device feature.** Query support and enable it when creating the logical device if shaders will use cull distances. If it is not enabled, shader modules must not read or write `CullDistance`-decorated members, and must not declare the SPIR-V `CullDistance` capability. ([docs.vulkan.org](https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceFeatures.html))
- **The SPIR-V `CullDistance` capability corresponds to that feature.** The Vulkan SPIR-V environment maps `CullDistance` to `VkPhysicalDeviceFeatures::shaderCullDistance`; the feature must be enabled for the module to use the capability. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/appendices/spirvenv.html))
- **This is a shader-module validity requirement, not a separate pipeline feature switch.** Pipeline stages select entry points from shader modules; those modules must satisfy the Vulkan SPIR-V and feature requirements when supplied to shader-module creation (or through the applicable pipeline shader-module path). ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai))
- **At drawing time**, the output `CullDistance` array on the final pre-rasterization shader stage determines the enabled cull half-spaces. A primitive is discarded when its cull distance is negative for all its vertices for any enabled half-space. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html))

So, enable `shaderCullDistance` on the device before using SPIR-V that declares `CullDistance` or accesses `CullDistance` built-ins. The cited current specification is Vulkan 1.4.365. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/index.html?utm_source=openai))

Citations:

- 1: https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceFeatures.html
- 2: https://docs.vulkan.org/spec/latest/appendices/spirvenv.html
- 3: https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai
- 4: https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html
- 5: https://docs.vulkan.org/spec/latest/index.html?utm_source=openai

🏁 Script executed:

set -u
printf '%s\n' '--- CompileSPV definition and callers ---'
rg -n -F --glob 'src/**/*.{cpp,h,hpp}' -e 'CompileSPV' -e '#define EXIT_IF' -e 'void Exit' -e 'EXIT_IF(' src/ || test "$?" -eq 1
printf '%s\n' '--- CompileSPV owning block ---'
sed -n '1,150p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
printf '%s\n' '--- EXIT_IF declaration/definition context ---'
rg -n -F --glob 'src/**/*.{cpp,h,hpp}' -e 'EXIT_IF' src/common src/graphics | head -40 || true

Repository: KytyPS5/KytyPS5

Length of output: 41199


🏁 Script executed:

set -u
printf '%s\n' '--- CompileSPV implementation ---'
sed -n '105,155p' src/graphics/vulkan/vulkanCommon.cpp
printf '%s\n' '--- EXIT_IF macro ---'
sed -n '25,48p' src/common/assert.h

Repository: KytyPS5/KytyPS5

Length of output: 1561


🏁 Script executed:

set -u
file=$(rg --files | while IFS= read -r f; do rg -l -F -- 'CompileSPV' "$f" 2>/dev/null && break; done)
printf 'candidate=%s\n' "$file"
rg -n -F -- 'CompileSPV' "$file"
sed -n '115,155p' "$file"

Repository: KytyPS5/KytyPS5

Length of output: 1147


Prevent unsupported cull-distance SPIR-V from reaching Vulkan

When shaderCullDistance is unavailable, the emitter still produces gl_CullDistance and CapabilityCullDistance. Vulkan does not permit this without the feature. CompileSPV converts shader-module creation errors into EXIT, so a reachable shader can terminate the emulator. The code does not drop the export or limit the failure to one pipeline.

Handle cull-distance outputs before SPIR-V emission, or reject the device when the feature is unavailable.

✅ Addressed in commit cd70694

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 22:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309015836) · edited 2026-10-18 23:07 UTC **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash sed -n '688,712p' src/graphics/presentation/window/vulkanWindow.cpp sed -n '580,612p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp sed -n '634,656p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp sed -n '750,770p' src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 5122 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- pipeline compile bindings ---' rg -n -F --glob '*.{cpp,h,hpp}' -e 'CompilePermutation' -e 'CompileProgram' -e 'EmitProgram' -e 'shader_cull_distance_enabled' src/ || test "$?" -eq 1 printf '%s\n' '--- pipeline compile source ---' sed -n '180,280p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp sed -n '850,915p' src/graphics/shader/recompiler/ShaderRecompiler.cpp printf '%s\n' '--- local Vulkan feature references ---' rg -n -F --glob '*.{cpp,h,hpp,md,txt}' -e 'shaderCullDistance' -e 'CullDistance' . || test "$?" -eq 1 ``` Repository: KytyPS5/KytyPS5 Length of output: 11324 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- CompilePermutation ---' sed -n '285,335p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp printf '%s\n' '--- pipeline creation consumers ---' rg -n -F --glob 'src/graphics/host_gpu/renderer/pipeline/*.{cpp,h,hpp}' -e 'vkCreateGraphicsPipelines' -e 'vkCreateComputePipelines' -e 'ShaderProgram' -e 'permutation.handle' -e 'entry->second' src/graphics/host_gpu/renderer/pipeline || test "$?" -eq 1 printf '%s\n' '--- relevant pipeline creation block ---' sed -n '335,475p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 13482 --- 🌐 Web query: `official Vulkan specification shaderCullDistance CullDistance capability feature pipeline shader module` 💡 Result: ``` In the current Vulkan 1.4.365 specification: - **`shaderCullDistance` is a device feature.** Query support and enable it when creating the logical device if shaders will use cull distances. If it is not enabled, shader modules must not read or write `CullDistance`-decorated members, and must not declare the SPIR-V `CullDistance` capability. ([docs.vulkan.org](https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceFeatures.html)) - **The SPIR-V `CullDistance` capability corresponds to that feature.** The Vulkan SPIR-V environment maps `CullDistance` to `VkPhysicalDeviceFeatures::shaderCullDistance`; the feature must be enabled for the module to use the capability. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/appendices/spirvenv.html)) - **This is a shader-module validity requirement, not a separate pipeline feature switch.** Pipeline stages select entry points from shader modules; those modules must satisfy the Vulkan SPIR-V and feature requirements when supplied to shader-module creation (or through the applicable pipeline shader-module path). ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai)) - **At drawing time**, the output `CullDistance` array on the final pre-rasterization shader stage determines the enabled cull half-spaces. A primitive is discarded when its cull distance is negative for all its vertices for any enabled half-space. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html)) So, enable `shaderCullDistance` on the device before using SPIR-V that declares `CullDistance` or accesses `CullDistance` built-ins. The cited current specification is Vulkan 1.4.365. ([docs.vulkan.org](https://docs.vulkan.org/spec/latest/index.html?utm_source=openai)) Citations: - 1: https://docs.vulkan.org/refpages/latest/refpages/source/VkPhysicalDeviceFeatures.html - 2: https://docs.vulkan.org/spec/latest/appendices/spirvenv.html - 3: https://docs.vulkan.org/spec/latest/chapters/shaders.html?utm_source=openai - 4: https://docs.vulkan.org/spec/latest/chapters/vertexpostproc.html - 5: https://docs.vulkan.org/spec/latest/index.html?utm_source=openai ``` --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- CompileSPV definition and callers ---' rg -n -F --glob 'src/**/*.{cpp,h,hpp}' -e 'CompileSPV' -e '#define EXIT_IF' -e 'void Exit' -e 'EXIT_IF(' src/ || test "$?" -eq 1 printf '%s\n' '--- CompileSPV owning block ---' sed -n '1,150p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp printf '%s\n' '--- EXIT_IF declaration/definition context ---' rg -n -F --glob 'src/**/*.{cpp,h,hpp}' -e 'EXIT_IF' src/common src/graphics | head -40 || true ``` Repository: KytyPS5/KytyPS5 Length of output: 41199 --- 🏁 Script executed: ```bash set -u printf '%s\n' '--- CompileSPV implementation ---' sed -n '105,155p' src/graphics/vulkan/vulkanCommon.cpp printf '%s\n' '--- EXIT_IF macro ---' sed -n '25,48p' src/common/assert.h ``` Repository: KytyPS5/KytyPS5 Length of output: 1561 --- 🏁 Script executed: ```bash set -u file=$(rg --files | while IFS= read -r f; do rg -l -F -- 'CompileSPV' "$f" 2>/dev/null && break; done) printf 'candidate=%s\n' "$file" rg -n -F -- 'CompileSPV' "$file" sed -n '115,155p' "$file" ``` Repository: KytyPS5/KytyPS5 Length of output: 1147 --- </details> **Prevent unsupported cull-distance SPIR-V from reaching Vulkan** When `shaderCullDistance` is unavailable, the emitter still produces `gl_CullDistance` and `CapabilityCullDistance`. Vulkan does not permit this without the feature. `CompileSPV` converts shader-module creation errors into `EXIT`, so a reachable shader can terminate the emulator. The code does not drop the export or limit the failure to one pipeline. Handle cull-distance outputs before SPIR-V emission, or reject the device when the feature is unavailable. <!-- fingerprinting:phantom:medusa:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:c2fd72699ff9d8e9d67cf3a7 --> <!-- This is an auto-generated reply by CodeRabbit --> ✅ Addressed in commit cd70694
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-18 22:22 UTC · original · reviewed

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: baf5af3f-8b3b-4e5e-b477-380e116dea17
📥 Commits

Reviewing files that changed from the base of the PR and between 3c2cc47338c72b1b216d491218aecd3197440cfa and 4316445967.

📒 Files selected for processing: 2
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/presentation/window/vulkanWindow.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 22:22 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#pullrequestreview-5565322762) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `baf5af3f-8b3b-4e5e-b477-380e116dea17` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 3c2cc47338c72b1b216d491218aecd3197440cfa and 43164459673b5ce55436056b0fa7bc9fa9c3e2bf. </details> <details> <summary>📒 Files selected for processing: 2</summary> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/presentation/window/vulkanWindow.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d73e06c5-2599-4dbf-bf81-b8930a0c8fe3 attempt=537c99d0-762f-4506-b704-df9f58a04941 batch=1/1 -->
Author
Owner

@⁠theantipopau on GitHub · 2026-10-18 22:26 UTC · original

@⁠wuboo Thanks for the M3 Max results — very useful. Two notes from my side:

  1. Rebasing this branch onto latest main was clean (no conflicts), so it now sits on top of everything up to and past 099de8de. The KosmicKrisp device-creation success you observed should carry over; if you re-run, the minLod/int64-atomics warnings are the expected steady state until #1314 lands.
  2. Noted Nmzik's call on #1635 (KosmicKrisp over MoltenVK workarounds). That leaves this PR's role as the KosmicKrisp device-selection enabler alongside #1669, with the imageView.cpp remap still slated for removal once #1314 (ceil shift + RESINFO correction + guards) merges. The DriverDmemBase mapping stop you hit is outside this PR's scope — let me know if there's anything on the device-creation side I can adjust to help.
**@⁠theantipopau** on GitHub · 2026-10-18 22:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#issuecomment-6255922063) @⁠wuboo Thanks for the M3 Max results — very useful. Two notes from my side: 1. Rebasing this branch onto latest main was clean (no conflicts), so it now sits on top of everything up to and past 099de8de. The KosmicKrisp device-creation success you observed should carry over; if you re-run, the minLod/int64-atomics warnings are the expected steady state until #1314 lands. 2. Noted Nmzik's call on #1635 (KosmicKrisp over MoltenVK workarounds). That leaves this PR's role as the KosmicKrisp device-selection enabler alongside #1669, with the imageView.cpp remap still slated for removal once #1314 (ceil shift + RESINFO correction + guards) merges. The DriverDmemBase mapping stop you hit is outside this PR's scope — let me know if there's anything on the device-creation side I can adjust to help.
@ -519,0 +604,4 @@
features12.shaderBufferInt64Atomics == VK_TRUE;
if (!graphics.shader_buffer_int64_atomics_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderBufferInt64Atomics is unavailable; shaders using 64-bit buffer atomics will fail.\n");
Author
Owner

@⁠theantipopau on GitHub · 2026-10-18 22:30 UTC · original

Confirmed real: the emitter unconditionally requires CapabilityCullDistance whenever IR has cull-distance outputs, nothing gates it on device support (no such flag exists in src), and CompileSPV EXITs on module failure — so a cull-distance shader on a fallback device would terminate rather than skip. Also note the branch's own log line claiming exports 'will be ignored' is currently untrue. Plan as follow-up: plumb a shader_cull_distance_enabled flag into GraphicContext (mirroring the shader_image_int64_atomics_enabled -> descriptors.cpp pattern) and skip affected programs before SPIR-V emission. Not yet observed in field tests (Astro Bot run stopped earlier at DriverDmemBase).

**@⁠theantipopau** on GitHub · 2026-10-18 22:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309042126) Confirmed real: the emitter unconditionally requires CapabilityCullDistance whenever IR has cull-distance outputs, nothing gates it on device support (no such flag exists in src), and CompileSPV EXITs on module failure — so a cull-distance shader on a fallback device would terminate rather than skip. Also note the branch's own log line claiming exports 'will be ignored' is currently untrue. Plan as follow-up: plumb a shader_cull_distance_enabled flag into GraphicContext (mirroring the shader_image_int64_atomics_enabled -> descriptors.cpp pattern) and skip affected programs before SPIR-V emission. Not yet observed in field tests (Astro Bot run stopped earlier at DriverDmemBase).
@ -519,0 +604,4 @@
features12.shaderBufferInt64Atomics == VK_TRUE;
if (!graphics.shader_buffer_int64_atomics_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderBufferInt64Atomics is unavailable; shaders using 64-bit buffer atomics will fail.\n");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-18 22:30 UTC · original

@⁠theantipopau Thanks for confirming. Rejecting unsupported programs before SPIR-V emission is the right approach. The rejection must reach a contained unsupported-pipeline result, not another fatal assertion.

One detail: the supplied snapshot already declares GraphicContext::shader_cull_distance_enabled and sets it in VulkanCreateDevice. The follow-up can use that flag rather than add it. The warning should describe rejection, not claim that exports are ignored or dropped.

This thread’s original buffer-atomic finding also remains open. That path needs the equivalent guard using shader_buffer_int64_atomics_enabled.

Would you like me to open a follow-up issue for both guards and the warning correction?

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 22:30 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309043084) @⁠theantipopau Thanks for confirming. Rejecting unsupported programs before SPIR-V emission is the right approach. The rejection must reach a contained unsupported-pipeline result, not another fatal assertion. One detail: the supplied snapshot already declares `GraphicContext::shader_cull_distance_enabled` and sets it in `VulkanCreateDevice`. The follow-up can use that flag rather than add it. The warning should describe rejection, not claim that exports are ignored or dropped. This thread’s original buffer-atomic finding also remains open. That path needs the equivalent guard using `shader_buffer_int64_atomics_enabled`. Would you like me to open a follow-up issue for both guards and the warning correction? _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
@ -519,0 +604,4 @@
features12.shaderBufferInt64Atomics == VK_TRUE;
if (!graphics.shader_buffer_int64_atomics_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderBufferInt64Atomics is unavailable; shaders using 64-bit buffer atomics will fail.\n");
Author
Owner

@⁠theantipopau on GitHub · 2026-10-18 22:55 UTC · original

Fixed in cd70694b: programs whose compiled outputs use cull distance are now dropped before SPIR-V emission when shader_cull_distance_enabled is off (key remembered in a negative program set so later draws fail fast), and PrepareDrawRenderState skips draws with missing vertex/tess/pixel programs. This also makes the branch's 'cull-distance exports will be dropped' warning accurate. CI running.

**@⁠theantipopau** on GitHub · 2026-10-18 22:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309124510) Fixed in cd70694b: programs whose compiled outputs use cull distance are now dropped before SPIR-V emission when shader_cull_distance_enabled is off (key remembered in a negative program set so later draws fail fast), and PrepareDrawRenderState skips draws with missing vertex/tess/pixel programs. This also makes the branch's 'cull-distance exports will be dropped' warning accurate. CI running.
@ -606,0 +701,4 @@
graphics.shader_cull_distance_enabled = device_features.shaderCullDistance == VK_TRUE;
if (!graphics.shader_cull_distance_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderCullDistance is unavailable; cull-distance exports will be dropped.\n");
Author
Owner

@⁠theantipopau on GitHub · 2026-10-18 22:55 UTC · original

Same fix as above (cd70694b) — replying here too since the finding was posted twice. Programs needing cull distance on unsupported hosts are dropped pre-emission and their draws skipped instead of aborting in CompileSPV.

**@⁠theantipopau** on GitHub · 2026-10-18 22:55 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309124604) Same fix as above (cd70694b) — replying here too since the finding was posted twice. Programs needing cull distance on unsupported hosts are dropped pre-emission and their draws skipped instead of aborting in CompileSPV.
@ -304,0 +302,4 @@
});
}
std::optional<Permutation>
Author
Owner

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Construct a Permutation before returning the optional.

The success return at Line 345 still uses {.function_code = ..., ...}. After this return-type change, that list initializes std::optional<Permutation>, which is not an aggregate. C++ requires an aggregate for designated initialization, so this file does not compile. Return Permutation{.function_code = ..., ...} instead. (eel.is)

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309139966) **🎯 Functional Correctness** | **🔴 Critical** | **⚡ Quick win** **Construct a `Permutation` before returning the optional.** The success return at Line 345 still uses `{.function_code = ..., ...}`. After this return-type change, that list initializes `std::optional<Permutation>`, which is not an aggregate. C++ requires an aggregate for designated initialization, so this file does not compile. Return `Permutation{.function_code = ..., ...}` instead. ([eel.is](https://eel.is/c%2B%2Bdraft/dcl.init.list?utm_source=openai)) <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:aac2173ab10e00720c019539 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -350,0 +373,4 @@
if (unsupported_programs.contains(lookup_key)) {
// A previous compile needed device features the host lacks; fail fast.
return ShaderProgram{};
}
Author
Owner

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Inspect how a call-source revision and stage outputs are produced.
rg -n -C 6 'RefreshShaderSource\s*\(|revision|StageOutputKind::CullDistance|info\.outputs' src/graphics/shader src/graphics/host_gpu/renderer/pipeline

Repository: KytyPS5/KytyPS5

Length of output: 28092


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- pipeline cache relevant declarations and methods ---'
sed -n '200,490p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
printf '%s\n' '--- shader source refresh implementation ---'
sed -n '520,700p' src/graphics/shader/recompiler/ShaderRecompiler.cpp
printf '%s\n' '--- ProgramKey and cache declarations/usages ---'
rg -n -C 8 -F -e 'struct ProgramKey' -e 'class ProgramCache' -e 'unsupported_programs' -e 'Get(const' -e 'RefreshCallSource' src/graphics/host_gpu/renderer/pipeline src/graphics/shader

Repository: KytyPS5/KytyPS5

Length of output: 36781


🏁 Script executed:

set -o pipefail
printf '%s\n' '--- translation and output collection ---'
rg -n -C 18 -F -e 'CollectShaderInfo' -e 'TranslateProgram(const Decoder::Program' -e 'ProgramNeedsCullDistance' src/graphics/shader/recompiler src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

Repository: KytyPS5/KytyPS5

Length of output: 29407


Invalidate unsupported entries when a call-source revision changes.

unsupported_programs is keyed only by ProgramKey, but Get checks it before RefreshCallSource. A refreshed SWAPPC source can produce new output metadata without changing that key. If the previous revision used cull distance and the new revision does not, this lookup still returns an empty program and skips the draw.

Move the rejection check after source refresh and erase the entry when source_changed is true, or key the rejection by the source revision/permutation.

Suggested fix
-		if (unsupported_programs.contains(lookup_key)) {
-			// A previous compile needed device features the host lacks; fail fast.
-			return ShaderProgram{};
-		}
 		auto                                         entry = programs.find(lookup_key);
@@
 			if (cached.call_source) {
 				source_changed = cached.RefreshCallSource(runtime);
+				if (source_changed) unsupported_programs.erase(lookup_key);
 				if (!source_changed) permutation = cached.FindPermutation<true>(runtime, push_data_cursor);
 			} else {
 				permutation = cached.FindPermutation<false>(runtime, push_data_cursor);
 			}
+			if (!source_changed && unsupported_programs.contains(lookup_key)) {
+				return ShaderProgram{};
+			}
 			if (permutation != nullptr) {
@@
 				return permutation->handle;
 			}
+		} else if (unsupported_programs.contains(lookup_key)) {
+			return ShaderProgram{};
 		}
**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309139970) **🎯 Functional Correctness** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Inspect how a call-source revision and stage outputs are produced. rg -n -C 6 'RefreshShaderSource\s*\(|revision|StageOutputKind::CullDistance|info\.outputs' src/graphics/shader src/graphics/host_gpu/renderer/pipeline ``` Repository: KytyPS5/KytyPS5 Length of output: 28092 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- pipeline cache relevant declarations and methods ---' sed -n '200,490p' src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp printf '%s\n' '--- shader source refresh implementation ---' sed -n '520,700p' src/graphics/shader/recompiler/ShaderRecompiler.cpp printf '%s\n' '--- ProgramKey and cache declarations/usages ---' rg -n -C 8 -F -e 'struct ProgramKey' -e 'class ProgramCache' -e 'unsupported_programs' -e 'Get(const' -e 'RefreshCallSource' src/graphics/host_gpu/renderer/pipeline src/graphics/shader ``` Repository: KytyPS5/KytyPS5 Length of output: 36781 --- 🏁 Script executed: ```bash set -o pipefail printf '%s\n' '--- translation and output collection ---' rg -n -C 18 -F -e 'CollectShaderInfo' -e 'TranslateProgram(const Decoder::Program' -e 'ProgramNeedsCullDistance' src/graphics/shader/recompiler src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp ``` Repository: KytyPS5/KytyPS5 Length of output: 29407 --- </details> **Invalidate unsupported entries when a call-source revision changes.** `unsupported_programs` is keyed only by `ProgramKey`, but `Get` checks it before `RefreshCallSource`. A refreshed `SWAPPC` source can produce new output metadata without changing that key. If the previous revision used cull distance and the new revision does not, this lookup still returns an empty program and skips the draw. Move the rejection check after source refresh and erase the entry when `source_changed` is true, or key the rejection by the source revision/permutation. <details> <summary>Suggested fix</summary> ```diff - if (unsupported_programs.contains(lookup_key)) { - // A previous compile needed device features the host lacks; fail fast. - return ShaderProgram{}; - } auto entry = programs.find(lookup_key); @@ if (cached.call_source) { source_changed = cached.RefreshCallSource(runtime); + if (source_changed) unsupported_programs.erase(lookup_key); if (!source_changed) permutation = cached.FindPermutation<true>(runtime, push_data_cursor); } else { permutation = cached.FindPermutation<false>(runtime, push_data_cursor); } + if (!source_changed && unsupported_programs.contains(lookup_key)) { + return ShaderProgram{}; + } if (permutation != nullptr) { @@ return permutation->handle; } + } else if (unsupported_programs.contains(lookup_key)) { + return ShaderProgram{}; } ``` </details> <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:acd53831c93657206dfad653 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository: KytyPS5/KytyPS5/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9b889ea4-9f7c-4c68-b73d-fe0c07b163bf
📥 Commits

Reviewing files that changed from the base of the PR and between 4316445967 and cd70694b58086ab430af42e8eff962c01fa68333.

📒 Files selected for processing: 3
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/renderDraw.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:00 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#pullrequestreview-5565453955) · **reviewed** **Actionable comments posted: 2** --- <details> <summary>ℹ️ Review info</summary> <details> <summary>⚙️ Run configuration</summary> - **Configuration used**: Repository: KytyPS5/KytyPS5/.coderabbit.yaml - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `9b889ea4-9f7c-4c68-b73d-fe0c07b163bf` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between 43164459673b5ce55436056b0fa7bc9fa9c3e2bf and cd70694b58086ab430af42e8eff962c01fa68333. </details> <details> <summary>📒 Files selected for processing: 3</summary> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.h` * `src/graphics/host_gpu/renderer/renderDraw.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=d233c4b5-295f-4032-a934-cf54e3ce2d17 attempt=3a59d3da-6874-4f60-af63-a0e5795f98d0 batch=1/1 -->
@ -314,18 +321,34 @@ struct PipelineCache::ProgramCache {
}
DumpShaderSpirv(stage_name, options.shader_hash, result.spirv);
if (!graphics.shader_cull_distance_enabled && ProgramNeedsCullDistance(result.program)) {
Author
Owner

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

🔎 Supported by static analysis

🏁 Script executed:

#!/bin/bash
# Trace the feature flag, atomic emission, and shader-module creation paths.
rg -ni -C 3 \
  'shaderBufferInt64Atomics|int64.*atomic|atomic.*int64|CompileSPV\s*\(|CompileProgram\s*\(' \
  src/graphics

Repository: KytyPS5/KytyPS5

Length of output: 35530


🏁 Script executed:

set -eu
printf '%s\n' '--- pipelineCache.cpp relevant block ---'
nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp | sed -n '260,355p'
printf '%s\n' '--- CompileResult and CompileProgram declarations/definition ---'
rg -n -C 5 -F -- 'struct CompileResult' src/graphics/shader/recompiler
rg -n -C 8 -F -- 'CompileResult CompileProgram' src/graphics/shader/recompiler/ShaderRecompiler.cpp src/graphics/shader/recompiler/ShaderRecompiler.h
printf '%s\n' '--- buffer atomic metadata and emitter flow ---'
nl -ba src/graphics/shader/recompiler/ir/ShaderIR.h | sed -n '500,540p'
nl -ba src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp | sed -n '270,385p'
nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp | sed -n '730,765p'
printf '%s\n' '--- ProgramNeeds helpers and relevant call sites ---'
rg -n -C 8 -F -- 'ProgramNeedsCullDistance' src/graphics
rg -n -C 8 -F -- 'buffer_int64_atomics' src/graphics

Repository: KytyPS5/KytyPS5

Length of output: 41057


🏁 Script executed:

set -eu
printf '%s\n' '--- CompileProgram implementation ---'
nl -ba src/graphics/shader/recompiler/ShaderRecompiler.cpp | sed -n '830,950p'
printf '%s\n' '--- SPIR-V emission entry points used by CompileProgram ---'
rg -n -C 6 -e 'Emit.*SPIR|Emit.*Spirv|EmitProgram|Generate.*SPV|Spirv' src/graphics/shader/recompiler/ShaderRecompiler.cpp src/graphics/shader/recompiler/backend/spirv

Repository: KytyPS5/KytyPS5

Length of output: 41314


Reject unsupported 64-bit buffer-atomic shaders before CompileSPV.

When shader_buffer_int64_atomics_enabled is false, CompileProgram still emits SPIR-V for programs that use 64-bit buffer atomics. The current gate checks only cull distance, so this SPIR-V can reach CompileSPV instead of using the per-program failure path.

Suggested fix
--- "a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp"
+++ "b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp"
@@ -321,22 +321,34 @@
 		}
 		DumpShaderSpirv(stage_name, options.shader_hash, result.spirv);
 
 		if (!graphics.shader_cull_distance_enabled && ProgramNeedsCullDistance(result.program)) {
 			// The host cannot consume gl_CullDistance: skip draws using this program
 			// instead of emitting SPIR-V the driver must reject (module creation
 			// aborts the emulator). The key is remembered below so later draws fail
 			// fast instead of recompiling every frame.
 			static std::atomic_uint log_count {0};
 			if (log_count.fetch_add(1, std::memory_order_relaxed) < 8) {
 				LOGF("%s hash=0x%016" PRIx64
 				     ": shader uses cull distance but the host does not support it; draws "
 				     "using this program will be skipped\n",
 				     options.dump_label, options.shader_hash);
 			}
 			return std::nullopt;
 		}
+
+		if (!graphics.shader_buffer_int64_atomics_enabled &&
+		    result.program.info.buffer_int64_atomics) {
+			static std::atomic_uint log_count {0};
+			if (log_count.fetch_add(1, std::memory_order_relaxed) < 8) {
+				LOGF("%s hash=0x%016" PRIx64
+				     ": shader uses 64-bit buffer atomics but the host does not support them; "
+				     "draws using this program will be skipped\n",
+				     options.dump_label, options.shader_hash);
+			}
+			return std::nullopt;
+		}
 
 		const auto module = CompileSPV(result.spirv, graphics.device);
 		EXIT_IF(module == nullptr);
 		if (options.dump_ir) {
 			LOGF("%s SPIR-V words=%" PRIu64 " wave_size=%u\n", options.dump_label,
**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309157235) **🩺 Stability & Availability** | **🟠 Major** | **⚡ Quick win** <details> <summary>🔎 Supported by static analysis</summary> 🏁 Script executed: ```bash #!/bin/bash # Trace the feature flag, atomic emission, and shader-module creation paths. rg -ni -C 3 \ 'shaderBufferInt64Atomics|int64.*atomic|atomic.*int64|CompileSPV\s*\(|CompileProgram\s*\(' \ src/graphics ``` Repository: KytyPS5/KytyPS5 Length of output: 35530 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- pipelineCache.cpp relevant block ---' nl -ba src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp | sed -n '260,355p' printf '%s\n' '--- CompileResult and CompileProgram declarations/definition ---' rg -n -C 5 -F -- 'struct CompileResult' src/graphics/shader/recompiler rg -n -C 8 -F -- 'CompileResult CompileProgram' src/graphics/shader/recompiler/ShaderRecompiler.cpp src/graphics/shader/recompiler/ShaderRecompiler.h printf '%s\n' '--- buffer atomic metadata and emitter flow ---' nl -ba src/graphics/shader/recompiler/ir/ShaderIR.h | sed -n '500,540p' nl -ba src/graphics/shader/recompiler/ir/passes/ShaderInfoCollection.cpp | sed -n '270,385p' nl -ba src/graphics/shader/recompiler/backend/spirv/spirvEmitterModule.cpp | sed -n '730,765p' printf '%s\n' '--- ProgramNeeds helpers and relevant call sites ---' rg -n -C 8 -F -- 'ProgramNeedsCullDistance' src/graphics rg -n -C 8 -F -- 'buffer_int64_atomics' src/graphics ``` Repository: KytyPS5/KytyPS5 Length of output: 41057 --- 🏁 Script executed: ```bash set -eu printf '%s\n' '--- CompileProgram implementation ---' nl -ba src/graphics/shader/recompiler/ShaderRecompiler.cpp | sed -n '830,950p' printf '%s\n' '--- SPIR-V emission entry points used by CompileProgram ---' rg -n -C 6 -e 'Emit.*SPIR|Emit.*Spirv|EmitProgram|Generate.*SPV|Spirv' src/graphics/shader/recompiler/ShaderRecompiler.cpp src/graphics/shader/recompiler/backend/spirv ``` Repository: KytyPS5/KytyPS5 Length of output: 41314 --- </details> **Reject unsupported 64-bit buffer-atomic shaders before `CompileSPV`.** When `shader_buffer_int64_atomics_enabled` is false, `CompileProgram` still emits SPIR-V for programs that use 64-bit buffer atomics. The current gate checks only cull distance, so this SPIR-V can reach `CompileSPV` instead of using the per-program failure path. <details> <summary>Suggested fix</summary> ```diff --- "a/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp" +++ "b/src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp" @@ -321,22 +321,34 @@ } DumpShaderSpirv(stage_name, options.shader_hash, result.spirv); if (!graphics.shader_cull_distance_enabled && ProgramNeedsCullDistance(result.program)) { // The host cannot consume gl_CullDistance: skip draws using this program // instead of emitting SPIR-V the driver must reject (module creation // aborts the emulator). The key is remembered below so later draws fail // fast instead of recompiling every frame. static std::atomic_uint log_count {0}; if (log_count.fetch_add(1, std::memory_order_relaxed) < 8) { LOGF("%s hash=0x%016" PRIx64 ": shader uses cull distance but the host does not support it; draws " "using this program will be skipped\n", options.dump_label, options.shader_hash); } return std::nullopt; } + + if (!graphics.shader_buffer_int64_atomics_enabled && + result.program.info.buffer_int64_atomics) { + static std::atomic_uint log_count {0}; + if (log_count.fetch_add(1, std::memory_order_relaxed) < 8) { + LOGF("%s hash=0x%016" PRIx64 + ": shader uses 64-bit buffer atomics but the host does not support them; " + "draws using this program will be skipped\n", + options.dump_label, options.shader_hash); + } + return std::nullopt; + } const auto module = CompileSPV(result.spirv, graphics.device); EXIT_IF(module == nullptr); if (options.dump_ir) { LOGF("%s SPIR-V words=%" PRIu64 " wave_size=%u\n", options.dump_label, ``` </details> <!-- fingerprinting:phantom:poseidon:wombat --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:945666063da26235269f68d1 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-10-18 23:06 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: 7af92a0f-c581-4f3d-90ae-8516c7da20e5
📥 Commits

Reviewing files that changed from the base of the PR and between cd70694b58086ab430af42e8eff962c01fa68333 and 9a757bef21.

📒 Files selected for processing: 1
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:06 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#pullrequestreview-5565472892) · **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**: `7af92a0f-c581-4f3d-90ae-8516c7da20e5` </details> <details> <summary>📥 Commits</summary> Reviewing files that changed from the base of the PR and between cd70694b58086ab430af42e8eff962c01fa68333 and 9a757bef21c5e945573672f3755a323364cb0b17. </details> <details> <summary>📒 Files selected for processing: 1</summary> * `src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp` </details> **Included review availability:** This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review. </details> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=8b6217f9-f0f0-4bd7-9c96-5cbe691624f6 attempt=1cd7a6eb-51fb-4b78-9923-7ae0c3961c5d batch=1/1 -->
@ -606,0 +701,4 @@
graphics.shader_cull_distance_enabled = device_features.shaderCullDistance == VK_TRUE;
if (!graphics.shader_cull_distance_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderCullDistance is unavailable; cull-distance exports will be dropped.\n");
Author
Owner

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

@⁠theantipopau Thanks for fixing this in cd70694b. Rejecting affected programs before SPIR-V emission and skipping their draws addresses the CompileSPV abort path. Sorry for the duplicate finding.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

✅ Review thread resolved.

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:07 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309161785) @⁠theantipopau Thanks for fixing this in `cd70694b`. Rejecting affected programs before SPIR-V emission and skipping their draws addresses the `CompileSPV` abort path. Sorry for the duplicate finding. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=Unsupported%20cull-distance%20shaders%20could%20crash%20the%20emulator.%20Drop%20them%20before%20SPIR-V%20emission%20and%20skip%20their%20draws%20instead.%20Try%20%40coderabbitai%20for%20actionable%20code%20reviews%20%F0%9F%9B%A0%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1547%23discussion_r4309015836)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> ✅ Review thread resolved. _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
@ -519,0 +604,4 @@
features12.shaderBufferInt64Atomics == VK_TRUE;
if (!graphics.shader_buffer_int64_atomics_enabled) {
Log::WriteToConsoleAndLog(
"WARNING: shaderBufferInt64Atomics is unavailable; shaders using 64-bit buffer atomics will fail.\n");
Author
Owner

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

@⁠theantipopau Thanks for fixing the cull-distance path in cd70694b. Rejecting those programs before SPIR-V emission and skipping draws with missing programs contains that failure.

This thread’s original buffer-atomic finding remains open. The reported fix does not cover rejecting programs that require 64-bit buffer atomics when shader_buffer_int64_atomics_enabled is false.


If you found this review helpful, would you consider giving us a shout-out on X?

Thank you for using CodeRabbit!

You are interacting with an AI system.

**@⁠coderabbitai[bot]** on GitHub · 2026-10-18 23:09 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/1547#discussion_r4309165855) @⁠theantipopau Thanks for fixing the cull-distance path in `cd70694b`. Rejecting those programs before SPIR-V emission and skipping draws with missing programs contains that failure. This thread’s original buffer-atomic finding remains open. The reported fix does not cover rejecting programs that require 64-bit buffer atomics when `shader_buffer_int64_atomics_enabled` is false. --- <!-- This is an auto-generated comment: tweet message by coderabbit.ai --> If you found this review helpful, would you consider giving us a shout-out on [X](https://twitter.com/intent/tweet?related=CodeRabbitAI&text=%40coderabbitai%20caught%20a%20cull-distance%20fallback%20crash%3A%20reject%20unsupported%20shaders%20before%20SPIR-V%20emission%20and%20skip%20affected%20draws.%20It%20also%20flagged%20the%20still-needed%20buffer-atomic%20guard.%20Try%20CodeRabbit%20for%20actionable%20reviews%20%F0%9F%9B%A0%EF%B8%8F&url=https%3A%2F%2Fgithub.com%2FKytyPS5%2FKytyPS5%2Fpull%2F1547%23discussion_r4309015829)? Thank you for using CodeRabbit! <!-- end of auto-generated comment: tweet message by coderabbit.ai --> _You are interacting with an AI system._ <!-- This is an auto-generated reply by CodeRabbit -->
This pull request has changes conflicting with the target branch.
  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.cpp
  • src/graphics/host_gpu/renderer/pipeline/pipelineCache.h
  • src/graphics/host_gpu/renderer/renderDraw.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1547/head:github-bot/gh-1547'
git switch 'github-bot/gh-1547'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1547'
git switch 'github-bot/gh-1547'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1547'
git switch 'github-bot/gh-1547'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1547'
git switch 'main'
git merge --squash 'github-bot/gh-1547'
git switch 'main'
git merge --ff-only 'github-bot/gh-1547'
git switch 'main'
git merge 'github-bot/gh-1547'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.