Skip to content

Add __APPLE__ arm to dawnxr.h (enables Vulkan via MoltenVK on macOS) - #1

Draft
scasekar wants to merge 1 commit into
upf-gti:mainfrom
scasekar:spike006/macos-apple-arm
Draft

Add __APPLE__ arm to dawnxr.h (enables Vulkan via MoltenVK on macOS)#1
scasekar wants to merge 1 commit into
upf-gti:mainfrom
scasekar:spike006/macos-apple-arm

Conversation

@scasekar

Copy link
Copy Markdown

Summary

Adds an #elif defined(__APPLE__) platform arm to dawnxr.h that parallels the existing __linux__ arm: define XR_USE_GRAPHICS_API_VULKAN and 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 by dawnxr_vulkan.cpp are 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.h and 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

  • Builds on Apple Silicon (M1, macOS 14, AppleClang 17, Vulkan SDK 1.4.341).
  • dawnxr_vulkan.cpp now compiles to non-empty object code (previously empty).
  • End-to-end stereo XR triangle through dawnxr::createSession / createSwapchain / enumerateSwapchainImages renders 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.
  • No changes to Windows or Linux behavior — only the previously-empty #endif fall-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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant