graphics: accept Metal-backed Vulkan devices on macOS #2269

Open
github-bot wants to merge 1 commit from github-bot/gh-2269 into main AGit
Owner

@⁠bengidev on GitHub · 2026-11-14 07:08 UTC · original
bengidev:macos-metal-device → main · +86 −17 · 5 files · 1 commits · open

Why

On Apple Silicon, device selection rejects every device with

Could not find suitable device:
  Apple M1 Max: image view minLod is not supported; shaderBufferInt64Atomics is not
  supported; nullDescriptor is not supported; shaderCullDistance is not supported

(issue #1068). All four are optional Vulkan features that Metal-backed drivers do not
implement, and the renderer only relies on them for shaders that ask for the matching
SPIR-V capability. Two more platform gaps sit right behind that one: agc requires its
driver memory to land on the fixed 0x0fe0000000 base, which Rosetta reserves, and a
KosmicKrisp device does not advertise VK_KHR_portability_subset, which Kyty requested
unconditionally.

What

Device selection (vulkanWindow.cpp) — the five features above become optional on
macOS (selection warns, other platforms still reject), and vkCreateDevice never asks a
device for a feature it reports as unsupported:

  • VK_EXT_image_view_min_lod moves from the required extension list to the optional set.
    The device is queried anyway, so the capability is known even where the extension is
    absent, and Image::FindView only attaches minLod when the device has it (views then
    start at their base level, as before).
  • shaderBufferInt64Atomics, shaderCullDistance and fillModeNonSolid are taken from
    the device instead of being forced on, and their pNext entries are unlinked when
    unavailable.
  • Pipelines fall back to VK_POLYGON_MODE_FILL when fillModeNonSolid is missing —
    Metal cannot rasterize point or line fill, so a wireframe request renders filled rather
    than failing.
  • VK_KHR_portability_subset is requested in VulkanCreateDevice (where the extension
    list is built from what the driver reports) instead of being pushed unconditionally.
  • GraphicContext records the resulting capabilities
    (image_view_min_lod_enabled, fill_mode_non_solid_enabled,
    shader_buffer_int64_atomics_enabled, graphics_subgroups_enabled) so the renderer and
    the shader emitter can pick a fallback instead of assuming the feature.

AGC (agc.cpp) — the direct-memory mapping keeps asking for the fixed base first, and
if the kernel refuses it retries without the fixed address and derives every address from
the base that comes back (Graphics5Driver: driver DMEM mapped at 0x0000007000000000 instead of 0x0000000fe0000000). The previous EXIT_IF(address != DriverDmemBase) is
what aborted every macOS run, and the same fixed-address assumption is already documented
in #1454.

Testing

Apple M1 Max, macOS 26.7, x86_64 build running under Rosetta, MoltenVK 1.4.2 bundled
with the KytyPS5 app. Before: exit 65 at device selection. After: device selected,
swapchain created (1280x720), graphics and compute pipelines created, and Madden NFL 26
(PPSA26127) reaches its main menu — see the follow-up PR for the shader changes this
depends on.

Not verified: any other title, and the KosmicKrisp path beyond device creation (it needs
the shader changes too). Nothing here changes behaviour on Windows/Linux: the relaxed
checks and the pNext unlinks only trigger for features a device actually lacks.

Follow-up

shader: ... PR stacked on this branch covers the three translation problems Metal
exposes next: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit
atomics.

**@⁠bengidev** on GitHub · 2026-11-14 07:08 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269) `bengidev:macos-metal-device` → `main` · +86 −17 · 5 files · 1 commits · open ## Why On Apple Silicon, device selection rejects every device with ``` Could not find suitable device: Apple M1 Max: image view minLod is not supported; shaderBufferInt64Atomics is not supported; nullDescriptor is not supported; shaderCullDistance is not supported ``` (issue #1068). All four are optional Vulkan features that Metal-backed drivers do not implement, and the renderer only relies on them for shaders that ask for the matching SPIR-V capability. Two more platform gaps sit right behind that one: `agc` requires its driver memory to land on the fixed `0x0fe0000000` base, which Rosetta reserves, and a KosmicKrisp device does not advertise `VK_KHR_portability_subset`, which Kyty requested unconditionally. ## What **Device selection** (`vulkanWindow.cpp`) — the five features above become optional on macOS (selection warns, other platforms still reject), and `vkCreateDevice` never asks a device for a feature it reports as unsupported: - `VK_EXT_image_view_min_lod` moves from the required extension list to the optional set. The device is queried anyway, so the capability is known even where the extension is absent, and `Image::FindView` only attaches `minLod` when the device has it (views then start at their base level, as before). - `shaderBufferInt64Atomics`, `shaderCullDistance` and `fillModeNonSolid` are taken from the device instead of being forced on, and their `pNext` entries are unlinked when unavailable. - Pipelines fall back to `VK_POLYGON_MODE_FILL` when `fillModeNonSolid` is missing — Metal cannot rasterize point or line fill, so a wireframe request renders filled rather than failing. - `VK_KHR_portability_subset` is requested in `VulkanCreateDevice` (where the extension list is built from what the driver reports) instead of being pushed unconditionally. - `GraphicContext` records the resulting capabilities (`image_view_min_lod_enabled`, `fill_mode_non_solid_enabled`, `shader_buffer_int64_atomics_enabled`, `graphics_subgroups_enabled`) so the renderer and the shader emitter can pick a fallback instead of assuming the feature. **AGC** (`agc.cpp`) — the direct-memory mapping keeps asking for the fixed base first, and if the kernel refuses it retries without the fixed address and derives every address from the base that comes back (`Graphics5Driver: driver DMEM mapped at 0x0000007000000000 instead of 0x0000000fe0000000`). The previous `EXIT_IF(address != DriverDmemBase)` is what aborted every macOS run, and the same fixed-address assumption is already documented in #1454. ## Testing Apple M1 Max, macOS 26.7, x86_64 build running under Rosetta, MoltenVK 1.4.2 bundled with the KytyPS5 app. Before: `exit 65` at device selection. After: device selected, swapchain created (1280x720), graphics and compute pipelines created, and Madden NFL 26 (PPSA26127) reaches its main menu — see the follow-up PR for the shader changes this depends on. Not verified: any other title, and the KosmicKrisp path beyond device creation (it needs the shader changes too). Nothing here changes behaviour on Windows/Linux: the relaxed checks and the `pNext` unlinks only trigger for features a device actually lacks. ## Follow-up `shader: ...` PR stacked on this branch covers the three translation problems Metal exposes next: descriptor aliasing, subgroup builtins in graphics stages, and 64-bit atomics.
Metal drivers (MoltenVK, KosmicKrisp) implement none of VK_EXT_image_view_min_lod,
64-bit buffer atomics, null descriptors, cull distance or non-solid fill, so device
selection rejected every Apple Silicon device with "Could not find suitable device"
(issue #1068). Those five are optional again on macOS: selection warns about them and
the renderer falls back where it relies on them.

- VK_EXT_image_view_min_lod moved from the required extension list to the optional
  set; image views only carry minLod when the device advertises it, otherwise the
  view starts at its base level.
- vkCreateDevice takes shaderBufferInt64Atomics, shaderCullDistance and
  fillModeNonSolid from the device instead of forcing VK_TRUE, and drops the
  corresponding features from the pNext chain when they are unavailable.
  GraphicContext now records the three capabilities for the shader emitter.
- Pipelines fall back to filled triangles when fillModeNonSolid is missing; Metal
  cannot rasterize point or line fill.
- VK_KHR_portability_subset is only requested from drivers that advertise it
  (KosmicKrisp does not), and Metal rejects subgroup builtins in vertex and pixel
  functions, so GraphicContext records that too.

The AGC driver memory no longer has to land on its fixed base: the x86_64 build runs
under Rosetta, which reserves 0x0fe0000000, so the mapping is retried without the
fixed address and everything derived from it follows the returned base.

Together with the shader changes in the follow-up PR this brings Madden NFL 26
(PPSA26127) to its main menu on an M1 Max.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:17:42 +00:00
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original

Explain Change →

Walkthrough

Vulkan device creation now treats selected features as optional on Apple and enables them only when supported. Image-view and pipeline creation use recorded capability flags. Gen5Driver::Initialize retries DMEM mapping without fixed placement after a fixed-address mapping failure and derives the binding-table base from the returned address.

Suggested reviewers: nmzik

Change: Bug fix

Merge Risk: Moderate · up to 50123

This makes Metal-backed Vulkan devices selectable on macOS, but some devices could be accepted and then fail at pipeline or shader creation, or when binding missing textures. The fallback memory mapping can also fail again at the same address. Address these before merging, or explicitly accept them pending the follow-up shader PR.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: making Metal-backed Vulkan devices on macOS pass device selection. The changeset makes optional device features optional on macOS, adds fallbacks, and changes AGC memo…
Description check Passed The description explains the problem (device selection rejects Apple M1 Max devices), the changes to device selection, pipeline fallback, portability subset handling, GraphicContext capability fields,…
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.
Full details: Title check

Explanation

The title names the main change: making Metal-backed Vulkan devices on macOS pass device selection. The changeset makes optional device features optional on macOS, adds fallbacks, and changes AGC memory mapping. The title does not mention the AGC change, but it is a secondary part of the change.

Full details: Description check

Explanation

The description explains the problem (device selection rejects Apple M1 Max devices), the changes to device selection, pipeline fallback, portability subset handling, GraphicContext capability fields, and the AGC memory mapping retry. It also gives testing details and a follow-up note, all of which match the changeset.

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#issuecomment-6873653739) <!-- coderabbit-ai-generated:v1 --> <!-- 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/2269?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-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a> <!-- review_stack_entry_end --> <!-- walkthrough_start --> <details> <summary><strong>Walkthrough</strong></summary> <dl> <dd> <br> Vulkan device creation now treats selected features as optional on Apple and enables them only when supported. Image-view and pipeline creation use recorded capability flags. `Gen5Driver::Initialize` retries DMEM mapping without fixed placement after a fixed-address mapping failure and derives the binding-table base from the returned address. **Suggested reviewers:** `nmzik` </dd> </dl> </details> <!-- walkthrough_end --> <!-- change_assessment_start --> <!-- change_assessment_commit:"501231ece1ade05db11e56ec23943ee572c4dc31" --> <!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} --> **Change:** Bug fix <!-- change_assessment_end --> <details> <summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-normal-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Moderate</strong> · up to <code>50123</code></summary> <dl> <dd> <br> <!-- final_review_risk_start --> <!-- final_review_risk_label **Merge Risk:** **🟡 Moderate** · up to `50123` --> <!-- final_review_risk_coverage:{"sourceCommitId":"501231ece1ade05db11e56ec23943ee572c4dc31","coveredCommitId":"501231ece1ade05db11e56ec23943ee572c4dc31","kind":"reviewed"} --> This makes Metal-backed Vulkan devices selectable on macOS, but some devices could be accepted and then fail at pipeline or shader creation, or when binding missing textures. The fallback memory mapping can also fail again at the same address. Address these before merging, or explicitly accept them pending the follow-up shader PR. <!-- 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</strong></summary> <dl> <dd> <br> | Check name | Status | Explanation | | :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Title check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The title names the main change: making Metal-backed Vulkan devices on macOS pass device selection. The changeset makes optional device features optional on macOS, adds fallbacks, and changes AGC memo… | | Description check | ![Passed](https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-passed.svg) | The description explains the problem (device selection rejects Apple M1 Max devices), the changes to device selection, pipeline fallback, portability subset handling, GraphicContext capability fields,… | | 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. | <details> <summary><strong>Full details: Title check</strong></summary> <dl> <dd> <br> **Explanation** The title names the main change: making Metal-backed Vulkan devices on macOS pass device selection. The changeset makes optional device features optional on macOS, adds fallbacks, and changes AGC memory mapping. The title does not mention the AGC change, but it is a secondary part of the change. </dd> </dl> </details> <details> <summary><strong>Full details: Description check</strong></summary> <dl> <dd> <br> **Explanation** The description explains the problem (device selection rejects Apple M1 Max devices), the changes to device selection, pipeline fallback, portability subset handling, GraphicContext capability fields, and the AGC memory mapping retry. It also gives testing details and a follow-up note, all of which match the changeset. </dd> </dl> </details> </dd> </dl> </details> <!-- pre_merge_checks_walkthrough_end --> <!-- tips_start --> Thanks for using [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=KytyPS5/KytyPS5&utm_content=2269)! 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> <br> - [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> <!-- tips_end -->
@ -251,3 +265,3 @@
"descriptorBindingPartiallyBound");
check_feature(features13.robustImageAccess, "robustImageAccess");
check_feature(robustness2.nullDescriptor, "nullDescriptor");
check_optional_feature(robustness2.nullDescriptor, "nullDescriptor");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original

Major · Stability & Availability · Quick win

Keep nullDescriptor required, or substitute a valid view for missing textures.

On Apple, nullDescriptor is no longer required for device selection (vulkanWindow.cpp:221-229, :267). Device creation then leaves the feature disabled. When a texture has no image, MakeImageInfo returns a null imageView (descriptors.cpp:70-74). Its image entries are built at descriptors.cpp:1079 and submitted with the descriptor writes at descriptors.cpp:1095-1107. Without nullDescriptor, descriptor writes cannot contain null resource handles. With validation enabled, the debug callback exits on that error (vulkanWindow.cpp:858-861). Without validation, the write is undefined.

The PR objectives list four optional features and do not include nullDescriptor. Restoring the required check keeps the existing requirement for this feature.

Suggested fix

--- "a/src/graphics/presentation/window/vulkanWindow.cpp"
+++ "b/src/graphics/presentation/window/vulkanWindow.cpp"
@@ -264,7 +264,7 @@
 		check_feature(features12.descriptorBindingPartiallyBound,
 		              "descriptorBindingPartiallyBound");
 		check_feature(features13.robustImageAccess, "robustImageAccess");
-		check_optional_feature(robustness2.nullDescriptor, "nullDescriptor");
+		check_feature(robustness2.nullDescriptor, "nullDescriptor");
 		check_feature(features13.dynamicRendering, "dynamicRendering");
 		check_feature(features13.synchronization2, "synchronization2");
 		check_feature(device_features2.features.sampleRateShading, "sampleRateShading");

If the target device lacks nullDescriptor, this change keeps the device unselected. To keep the device selectable, MakeImageInfo must return a valid placeholder view instead of a null handle. That change is outside the inspected code. Update the comment at vulkanWindow.cpp:670 to match the final decision.

Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

		check_feature(robustness2.nullDescriptor, "nullDescriptor");
**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#discussion_r4572154126) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Quick win** **Keep `nullDescriptor` required, or substitute a valid view for missing textures.** On Apple, `nullDescriptor` is no longer required for device selection (`vulkanWindow.cpp:221-229`, `:267`). Device creation then leaves the feature disabled. When a texture has no image, `MakeImageInfo` returns a null `imageView` (`descriptors.cpp:70-74`). Its image entries are built at `descriptors.cpp:1079` and submitted with the descriptor writes at `descriptors.cpp:1095-1107`. Without `nullDescriptor`, descriptor writes cannot contain null resource handles. With validation enabled, the debug callback exits on that error (`vulkanWindow.cpp:858-861`). Without validation, the write is undefined. The PR objectives list four optional features and do not include `nullDescriptor`. Restoring the required check keeps the existing requirement for this feature. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff --- "a/src/graphics/presentation/window/vulkanWindow.cpp" +++ "b/src/graphics/presentation/window/vulkanWindow.cpp" @@ -264,7 +264,7 @@ check_feature(features12.descriptorBindingPartiallyBound, "descriptorBindingPartiallyBound"); check_feature(features13.robustImageAccess, "robustImageAccess"); - check_optional_feature(robustness2.nullDescriptor, "nullDescriptor"); + check_feature(robustness2.nullDescriptor, "nullDescriptor"); check_feature(features13.dynamicRendering, "dynamicRendering"); check_feature(features13.synchronization2, "synchronization2"); check_feature(device_features2.features.sampleRateShading, "sampleRateShading"); ``` </dd> </dl> </details> If the target device lacks `nullDescriptor`, this change keeps the device unselected. To keep the device selectable, `MakeImageInfo` must return a valid placeholder view instead of a null handle. That change is outside the inspected code. Update the comment at `vulkanWindow.cpp:670` to match the final decision. <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> <br> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Review the replacement and indentation, then test before committing. ```suggestion check_feature(robustness2.nullDescriptor, "nullDescriptor"); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:71f4fe09bc8beea3642fe910 --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -484,0 +512,4 @@
// request the feature from a device that does not report it (MoltenVK reports false).
features12.shaderBufferInt64Atomics = supported12.shaderBufferInt64Atomics;
graphics.shader_buffer_int64_atomics_enabled =
supported12.shaderBufferInt64Atomics == VK_TRUE;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original

Major · Stability & Availability · Heavy lift

Reject or lower 64-bit buffer atomics when shaderBufferInt64Atomics is unavailable.

With shaderBufferInt64Atomics false, the device is accepted and shader_buffer_int64_atomics_enabled is set to false (vulkanWindow.cpp:513-515). No code reads that flag. spirvEmitterModule.cpp:773-776 still requires CapabilityInt64Atomics for any shader where info.buffer_int64_atomics is set. ShaderInfoCollection.cpp:289-290 sets that flag for every 64-bit buffer atomic.

The Vulkan environment appendix permits a SPIR-V capability only when a corresponding feature is enabled. On a device where no other feature backing Int64Atomics is enabled, such a shader requests an unsupported capability. Shader module creation can then fail or lead to undefined behavior.

The header comment in graphicContext.h:33-34 describes a lowering for Metal. The inspected code does not show it. Its scope covers only atomic 64-bit loads, so it would not cover read-modify-write operations such as BufferAtomicIAdd64.

When the flag is false, either lower these operations in the emitter or reject the shader before module creation. Use the same approach as ResolveTexture, which exits on 64-bit image atomics when shader_image_int64_atomics_enabled is false (descriptors.cpp:485-486).

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#discussion_r4572154132) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Heavy lift** **Reject or lower 64-bit buffer atomics when `shaderBufferInt64Atomics` is unavailable.** With `shaderBufferInt64Atomics` false, the device is accepted and `shader_buffer_int64_atomics_enabled` is set to false (`vulkanWindow.cpp:513-515`). No code reads that flag. `spirvEmitterModule.cpp:773-776` still requires `CapabilityInt64Atomics` for any shader where `info.buffer_int64_atomics` is set. `ShaderInfoCollection.cpp:289-290` sets that flag for every 64-bit buffer atomic. The Vulkan environment appendix permits a SPIR-V capability only when a corresponding feature is enabled. On a device where no other feature backing `Int64Atomics` is enabled, such a shader requests an unsupported capability. Shader module creation can then fail or lead to undefined behavior. The header comment in `graphicContext.h:33-34` describes a lowering for Metal. The inspected code does not show it. Its scope covers only atomic 64-bit loads, so it would not cover read-modify-write operations such as `BufferAtomicIAdd64`. When the flag is false, either lower these operations in the emitter or reject the shader before module creation. Use the same approach as `ResolveTexture`, which exits on 64-bit image atomics when `shader_image_int64_atomics_enabled` is false (`descriptors.cpp:485-486`). <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:316f2551cf245ab1701d966f --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -577,3 +613,3 @@
device_features.depthBiasClamp = VK_TRUE;
device_features.shaderClipDistance = VK_TRUE;
device_features.shaderCullDistance = VK_TRUE;
device_features.shaderCullDistance = supported2.features.shaderCullDistance;
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original

Major · Stability & Availability · Heavy lift

Gate CullDistance shader output on shaderCullDistance.

vulkanWindow.cpp now accepts devices without shaderCullDistance and passes VK_FALSE for it at line 615. The shader recompiler still declares CullDistance when a shader exports cull-distance data. The Vulkan specification states that shader modules must not use CullDistance when this feature is not enabled. A module that does so can fail pipeline creation on these devices.

No shader-side check gates this declaration. The export and declaration path runs as follows:

  • ShaderIR.h:316 sets cull_distance from the export control bits.
  • ShaderInfoCollection.cpp:233-235 adds a CullDistance output.
  • spirvEmitterModule.cpp:786-788 requires CapabilityCullDistance when cull_distance_variable is set.

Handle the unsupported case explicitly before it reaches the emitter. Either skip the CullDistance output and capability, or reject shaders that need them on devices without the feature. Skipping the output changes culling results, so define that behavior before choosing this option.

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#discussion_r4572154137) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Heavy lift** **Gate `CullDistance` shader output on `shaderCullDistance`.** `vulkanWindow.cpp` now accepts devices without `shaderCullDistance` and passes `VK_FALSE` for it at line 615. The shader recompiler still declares `CullDistance` when a shader exports cull-distance data. The Vulkan specification states that shader modules must not use `CullDistance` when this feature is not enabled. A module that does so can fail pipeline creation on these devices. No shader-side check gates this declaration. The export and declaration path runs as follows: - `ShaderIR.h:316` sets `cull_distance` from the export control bits. - `ShaderInfoCollection.cpp:233-235` adds a `CullDistance` output. - `spirvEmitterModule.cpp:786-788` requires `CapabilityCullDistance` when `cull_distance_variable` is set. Handle the unsupported case explicitly before it reaches the emitter. Either skip the `CullDistance` output and capability, or reject shaders that need them on devices without the feature. Skipping the output changes culling results, so define that behavior before choosing this option. <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:9a013966eaeefce7c0dd80ef --> <!-- This is an auto-generated comment by CodeRabbit -->
@ -4079,0 +4083,4 @@
if (result != OK) {
address = reinterpret_cast<void*>(DriverDmemBase);
result = LibKernel::Memory::KernelMapNamedDirectMemory(
&address, DriverDmemSize, 0x33, 0, physical_offset, DriverDmemSize, "SceAgcDriver");
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original

Major · Stability & Availability · Quick win

The retry can request the address that the fixed attempt just failed to map.

When the fixed attempt reserves the target span and then MapBacking fails, the span stays Reserved. MapDirectMemory then returns ENOMEM. The retry at DriverDmemBase with flags 0 sees IsReservedSpan succeed. It keeps the same target and skips FindGuestFreeRange. If the backing failure repeats at that address, Gen5Driver::Initialize fails. The fallback does not reach a different address on this path.

The retry should request placement without a hint. The code already derives the binding-table base from the returned address, so this does not change the consumer.

Suggested fix

 	if (result != OK) {
-		address = reinterpret_cast<void*>(DriverDmemBase);
+		address = nullptr;
 		result  = LibKernel::Memory::KernelMapNamedDirectMemory(
 		    &address, DriverDmemSize, 0x33, 0, physical_offset, DriverDmemSize, "SceAgcDriver");
 	}
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

		address = nullptr;
		result  = LibKernel::Memory::KernelMapNamedDirectMemory(
		    &address, DriverDmemSize, 0x33, 0, physical_offset, DriverDmemSize, "SceAgcDriver");
**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#discussion_r4572154138) <!-- coderabbit-ai-generated:v1 --> **<picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/major-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Major** · **Stability & Availability** · **Quick win** **The retry can request the address that the fixed attempt just failed to map.** When the fixed attempt reserves the target span and then `MapBacking` fails, the span stays `Reserved`. `MapDirectMemory` then returns `ENOMEM`. The retry at `DriverDmemBase` with flags `0` sees `IsReservedSpan` succeed. It keeps the same target and skips `FindGuestFreeRange`. If the backing failure repeats at that address, `Gen5Driver::Initialize` fails. The fallback does not reach a different address on this path. The retry should request placement without a hint. The code already derives the binding-table base from the returned address, so this does not change the consumer. <details> <summary>Suggested fix</summary> <dl> <dd> <br> ```diff if (result != OK) { - address = reinterpret_cast<void*>(DriverDmemBase); + address = nullptr; result = LibKernel::Memory::KernelMapNamedDirectMemory( &address, DriverDmemSize, 0x33, 0, physical_offset, DriverDmemSize, "SceAgcDriver"); } ``` </dd> </dl> </details> <!-- suggestion_start --> <details> <summary>Committable suggestion</summary> <dl> <dd> <br> > <picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-warning.svg" width="20" height="20" align="absmiddle" alt=""></picture> **IMPORTANT** > Review the replacement and indentation, then test before committing. ```suggestion address = nullptr; result = LibKernel::Memory::KernelMapNamedDirectMemory( &address, DriverDmemSize, 0x33, 0, physical_offset, DriverDmemSize, "SceAgcDriver"); ``` </dd> </dl> </details> <!-- suggestion_end --> <!-- fingerprinting:phantom:poseidon:wombat61 --> <!-- cr-indicator-types:potential_issue --> <!-- cr-comment:v1:426a54a37db5f0cb7deac531 --> <!-- This is an auto-generated comment by CodeRabbit -->
Author
Owner

@⁠coderabbitai[bot] on GitHub · 2026-11-14 07:14 UTC · original · reviewed

Actionable comments posted: 4

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 11d834dd82 and 501231ece1.

Files selected for processing: 5

  • src/graphics/host_gpu/graphicContext.h
  • src/graphics/host_gpu/renderer/image/imageView.cpp
  • src/graphics/host_gpu/renderer/pipeline/shaders.cpp
  • src/graphics/presentation/window/vulkanWindow.cpp
  • src/libs/agc.cpp

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

**@⁠coderabbitai[bot]** on GitHub · 2026-11-14 07:14 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#pullrequestreview-5902557330) · **reviewed** <!-- coderabbit-ai-generated:v1 --> **Actionable comments posted: 4** <h6> <details> <summary><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/info.svg" width="12" height="12" align="absmiddle" alt=""></picture> Review info</summary> <dl> <dd> <br> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/cog.svg" width="16" height="16" align="absmiddle" alt=""></picture> Run configuration</summary> <dl> <dd> <br> - **Source mode**: Auto - **Repository**: [KytyPS5/KytyPS5](<https://github.com/KytyPS5/KytyPS5>) - **Branch**: [main](<https://github.com/KytyPS5/KytyPS5/tree/main>) - **File**: [.coderabbit.yaml](<https://github.com/KytyPS5/KytyPS5/blob/11d834dd820c093118d37177c6162f8092134cf2/.coderabbit.yaml>) - **Commit**: [11d834d](<https://github.com/KytyPS5/KytyPS5/commit/11d834dd820c093118d37177c6162f8092134cf2>) - **Layers**: Repository YAML - **Review profile**: CHILL - **Plan**: Advanced - **Run ID**: `a2eb2050-7ae5-4468-8084-8d5de967adf5` </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/git-commit-horizontal.svg" width="16" height="16" align="absmiddle" alt=""></picture> Commits</summary> <dl> <dd> <br> Reviewing files that changed from the base of the PR and between 11d834dd820c093118d37177c6162f8092134cf2 and 501231ece1ade05db11e56ec23943ee572c4dc31. </dd> </dl> </details> <details> <summary><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner-dark.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/file-plus-corner.svg" width="16" height="16" align="absmiddle" alt=""></picture> Files selected for processing: 5</summary> <dl> <dd> <br> * `src/graphics/host_gpu/graphicContext.h` * `src/graphics/host_gpu/renderer/image/imageView.cpp` * `src/graphics/host_gpu/renderer/pipeline/shaders.cpp` * `src/graphics/presentation/window/vulkanWindow.cpp` * `src/libs/agc.cpp` </dd> </dl> </details> **Included review availability:** This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. </dd> </dl> </details> </h6> <!-- This is an auto-generated comment by CodeRabbit for review status --> <!-- coderabbit-review-publication v1 publication=7c7ee2b9-ca1f-498b-a6e0-8c30a871465e attempt=f449f39b-5b2a-492a-b7c2-5bdc4c4977e4 batch=1/1 -->
Author
Owner

@⁠Fr0gzilla on GitHub · 2026-11-21 13:26 UTC · original

Tested on Apple M5, macOS 26.6 (25G72), MoltenVK 1.4.2, x86_64 build under Rosetta 2.

On current main (39936ff), device selection still fails, and nullDescriptor is now missing too (required since 892e70c8):

Apple M5: image view minLod is not supported; shaderBufferInt64Atomics is not supported; nullDescriptor is not supported; shaderCullDistance is not supported

#2402 and #1547 don't handle nullDescriptor. This PR does. It cherry-picks cleanly onto 39936ff, and shader_recompiler_compute_tests --device-creation-only passes:

[host]    DeviceCreation                   ok

I don't have PS5 games, so this only covers device selection, not in-game rendering.

AI disclosure: I used an AI assistant to build, run the tests and read the logs; I checked the results myself on my Mac.

**@⁠Fr0gzilla** on GitHub · 2026-11-21 13:26 UTC · [original](https://github.com/KytyPS5/KytyPS5/pull/2269#issuecomment-7063280812) Tested on Apple M5, macOS 26.6 (25G72), MoltenVK 1.4.2, x86_64 build under Rosetta 2. On current main (39936ff), device selection still fails, and nullDescriptor is now missing too (required since 892e70c8): ``` Apple M5: image view minLod is not supported; shaderBufferInt64Atomics is not supported; nullDescriptor is not supported; shaderCullDistance is not supported ``` #2402 and #1547 don't handle nullDescriptor. This PR does. It cherry-picks cleanly onto 39936ff, and `shader_recompiler_compute_tests --device-creation-only` passes: ``` [host] DeviceCreation ok ``` I don't have PS5 games, so this only covers device selection, not in-game rendering. AI disclosure: I used an AI assistant to build, run the tests and read the logs; I checked the results myself on my Mac.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

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

Merge

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