Add __APPLE__ arm to dawnxr.h (enables Vulkan via MoltenVK on macOS) - #1
Draft
scasekar wants to merge 1 commit into
Draft
Add __APPLE__ arm to dawnxr.h (enables Vulkan via MoltenVK on macOS)#1scasekar wants to merge 1 commit into
scasekar wants to merge 1 commit into
Conversation
Upstream dawnxr.h has platform arms for _WIN32 and __linux__ that define XR_USE_GRAPHICS_API_VULKAN + include <vulkan/vulkan.h>, but no __APPLE__ arm. Without it, dawnxr_vulkan.cpp compiles as an empty translation unit on macOS (its outer #ifdef XR_USE_GRAPHICS_API_VULKAN is never satisfied), and downstream code cannot call any of the Vulkan-binding dawnxr APIs. On Apple, Vulkan is provided by MoltenVK (Khronos's Vulkan-on-Metal portability layer). Both <vulkan/vulkan.h> and a working libvulkan loader are available via the LunarG Vulkan SDK or via Homebrew (vulkan-headers + vulkan-loader + molten-vk packages). Tested on Apple Silicon (M1, macOS 14) against the Meta XR Simulator v71.0.0: a stereo XR triangle renders through dawnxr + Dawn's Vulkan backend end-to-end (276 frames in 5 seconds at 1680x1760 per eye, full OpenXR session-state lifecycle, clean shutdown). This makes macOS-host inner-loop development viable for any dawnxr user targeting Quest 3 / Snapdragon XR2, since the same Dawn-Vulkan code path runs on both. No effect on Windows or Linux behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
#elif defined(__APPLE__)platform arm todawnxr.hthat parallels the existing__linux__arm: defineXR_USE_GRAPHICS_API_VULKANand include<vulkan/vulkan.h>. Without this arm, on macOS no graphics-API macro is defined before<openxr/openxr_platform.h>is included, so the Vulkan-binding typedefs needed bydawnxr_vulkan.cppare absent — the Vulkan path compiles as an empty translation unit.Why
The dawnxr Vulkan path uses identical code on Linux and macOS at the source level — both rely on
vulkan/vulkan.hand the Khronos Vulkan loader. The only difference is that on Apple, libvulkan dispatches through MoltenVK (Khronos's Vulkan-on-Metal portability layer) instead of native drivers.This is a real use case: macOS-host inner-loop development for native-OpenXR XR engines targeting Quest 3 / Snapdragon XR2. The Quest 3 device target uses Dawn-on-Vulkan; validating the same Dawn-Vulkan code path on macOS before cross-compiling to Android NDK collapses iteration time from minutes-with-headset-don/doff to seconds.
Test plan
dawnxr_vulkan.cppnow compiles to non-empty object code (previously empty).dawnxr::createSession/createSwapchain/enumerateSwapchainImagesrenders into Meta XR Simulator (Apple Silicon native build, 71.0.0): 276 frames in 5s at 1680×1760 per eye, full OpenXR session-state lifecycle (IDLE → READY → SYNCHRONIZED → VISIBLE → FOCUSED → STOPPING → EXITING), clean shutdown.#endiffall-through on Apple is affected.Context
This patch was discovered during a pre-proposal feasibility spike for an upcoming Navy SBIR phase-I VR application (DON26BZ01-NV015 — VR Model Walkthrough), where we are evaluating Dawn-native + OpenXR as the primary delivery surface for Quest 3 with the same WebGPU codebase that targets desktop browsers. wgpuEngine + dawnxr are the published prior-art reference implementations of this architecture (Web3D 2025); making them work on macOS host hardware removes the largest inner-loop friction.
Happy to add the same on
__APPLE__to any other place in the dawnxr tree that needs it — let me know if you'd like the scope extended.