macos: start on MoltenVK without minLod, 64-bit buffer atomics, or cull distance #1547
No reviewers
Labels
No labels
bug
documentation
duplicate
enhancement
GPU
GUI
help wanted
question
Shaders
Video
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/KytyPS5--KytyPS5!1547
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1547"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@theantipopau on GitHub · 2026-10-16 02:59 UTC · original
theantipopau:m5-moltenvk-fallback→main· +186 −17 · 6 files · 3 commits · openFollow-up to #1448 (and #1083). On Apple silicon the three hard requirements reject the only device, so this demotes them to warnings on APPLE:
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.
@coderabbitai[bot] on GitHub · 2026-10-16 03:01 UTC · original · edited 2026-10-18 23:06 UTC
📝 Walkthrough
On macOS, Vulkan device selection and creation now treat image-view min LOD, buffer int64 atomics, and shader cull distance as optional capabilities.
GraphicContextrecords their availability. When image-view min LOD is unavailable,Image::FindViewadjusts 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:
nmzikPriority: ⬇️ Low
Change: Bug fix
Merge Risk: 🔴 Critical · up to
9a757The 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:
4 ·
1
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands.@ -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;@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_levelalso 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)@ -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)) {@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.pNextstill chainsimage_view_min_lodintovkCreateDevice. SettingminLodtoVK_FALSEdoes not make that structure valid: a device-creationpNextstructure 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 · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
2db48bed-5f0e-4ca9-8628-603e00aa51af📥 Commits
Reviewing files that changed from the base of the PR and between
3ff6606fcband 3bfbbba8a3809a3fbd9c66f25236715f2ac1abf4.📒 Files selected for processing: 3
src/graphics/host_gpu/graphicContext.hsrc/graphics/host_gpu/renderer/image/imageView.cppsrc/graphics/presentation/window/vulkanWindow.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
@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_lodis missing, with a few differences:ceil(MinLod / 256)), so a partially resident mip is never sampled;image_get_resinfo: the shader gets the T# extent and level count, not those of the shifted view;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.
@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-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.
@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_robustness2nullDescriptor, 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 whennullDescriptoris 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 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.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");@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:
Repository: KytyPS5/KytyPS5
Length of output: 5770
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 37671
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 3354
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13838
Reject unsupported buffer-atomic permutations before shader-module creation.
When
shaderBufferInt64Atomicsis unavailable, a buffer-atomic shader can still emitspv::CapabilityInt64Atomics.CompileSPVthen passes the module tovkCreateShaderModule;RequireVulkanSuccesscallsEXITwhen creation fails. Route this permutation through a contained unsupported-pipeline result beforeCompileSPV.@ -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");@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:
Repository: KytyPS5/KytyPS5
Length of output: 5122
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 11324
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 13482
🌐 Web query:
official Vulkan specification shaderCullDistance CullDistance capability feature pipeline shader module💡 Result:
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41199
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1561
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 1147
Prevent unsupported cull-distance SPIR-V from reaching Vulkan
When
shaderCullDistanceis unavailable, the emitter still producesgl_CullDistanceandCapabilityCullDistance. Vulkan does not permit this without the feature.CompileSPVconverts shader-module creation errors intoEXIT, 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 · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
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.hsrc/graphics/presentation/window/vulkanWindow.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
@theantipopau on GitHub · 2026-10-18 22:26 UTC · original
@wuboo Thanks for the M3 Max results — very useful. Two notes from my side:
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.@ -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");@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).
@ -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");@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_enabledand sets it inVulkanCreateDevice. 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.
@ -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");@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.
@ -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");@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.
@ -304,0 +302,4 @@});}std::optional<Permutation>@coderabbitai[bot] on GitHub · 2026-10-18 23:00 UTC · original
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
Construct a
Permutationbefore returning the optional.The success return at Line 345 still uses
{.function_code = ..., ...}. After this return-type change, that list initializesstd::optional<Permutation>, which is not an aggregate. C++ requires an aggregate for designated initialization, so this file does not compile. ReturnPermutation{.function_code = ..., ...}instead. (eel.is)@ -350,0 +373,4 @@if (unsupported_programs.contains(lookup_key)) {// A previous compile needed device features the host lacks; fail fast.return ShaderProgram{};}@coderabbitai[bot] on GitHub · 2026-10-18 23:00 UTC · original
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 28092
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 36781
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 29407
Invalidate unsupported entries when a call-source revision changes.
unsupported_programsis keyed only byProgramKey, butGetchecks it beforeRefreshCallSource. A refreshedSWAPPCsource 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_changedis true, or key the rejection by the source revision/permutation.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-18 23:00 UTC · original · reviewed
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
9b889ea4-9f7c-4c68-b73d-fe0c07b163bf📥 Commits
Reviewing files that changed from the base of the PR and between
4316445967and cd70694b58086ab430af42e8eff962c01fa68333.📒 Files selected for processing: 3
src/graphics/host_gpu/renderer/pipeline/pipelineCache.cppsrc/graphics/host_gpu/renderer/pipeline/pipelineCache.hsrc/graphics/host_gpu/renderer/renderDraw.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
@ -314,18 +321,34 @@ struct PipelineCache::ProgramCache {}DumpShaderSpirv(stage_name, options.shader_hash, result.spirv);if (!graphics.shader_cull_distance_enabled && ProgramNeedsCullDistance(result.program)) {@coderabbitai[bot] on GitHub · 2026-10-18 23:06 UTC · original
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 35530
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41057
🏁 Script executed:
Repository: KytyPS5/KytyPS5
Length of output: 41314
Reject unsupported 64-bit buffer-atomic shaders before
CompileSPV.When
shader_buffer_int64_atomics_enabledis false,CompileProgramstill emits SPIR-V for programs that use 64-bit buffer atomics. The current gate checks only cull distance, so this SPIR-V can reachCompileSPVinstead of using the per-program failure path.Suggested fix
@coderabbitai[bot] on GitHub · 2026-10-18 23:06 UTC · original · reviewed
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
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.cppIncluded review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 0 remain after this review.
@ -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");@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 theCompileSPVabort 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.
@ -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");@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_enabledis 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.
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.Merge
Merge the changes and update on Forgejo.