Support for Metal graphics bindings

Hi everyone, I’m currently working a very basic OpenXR runtime. I’d like the runtime to support Windows, Linux and macOS, so I’m implementing the OpenXR extensions for the various graphics APIs that the platforms provide.

While reading through the specification, I noticed that there doesn’t seem to be an extension for Apple’s Metal API (e.g. XR_KHR_metal_enable). Is there actually no support for Metal or am I overlooking something? Does this mean that OpenXR applications have to render using the deprecated OpenGL API on macOS?

There is some code in the loader for Mac to work the same way as on Linux. It should work with Vulkan and MoltenVK if you have a runtime that works on Mac, though iirc you can’t do cross-process texture/sync sharing so your runtime has to have an in-process compositor unlike most other platforms. I’m not aware of any headsets that work on Mac however. We’re certainly open to having mac support if a vendor familiar with it proposes the appropriate spec updates.

(Re: implementing your own runtime - I assume you’re aware of Monado right?)

Thanks for the clarification!

I’ve experimented a bit with the Godot engine on macOS and got it to load my runtime, which means the loader indeed works on this platform. The engine even enabled XR_KHR_vulkan_enable2, so it seems to support OpenXR using MoltenVK. Cross-process texture sharing shouldn’t be a problem as swapchain images are only used in the same process.

I wanted to try the same thing with the Unity engine, but since it currently only supports Metal on macOS, this is probably technically impossible. I guess I’ll have to wait until the VR industry gets interested in macOS :slight_smile:.

As for Monado, I’ve looked into this project before, but thought it was mainly for Linux. Although I’m seeing a lot of references to Windows and D3D now that I’m taking a closer look at it, so I was probably wrong…

AFAIK the Unity OpenXR plugin currently only supports Windows, it doesn’t even run on Linux. It likely wouldn’t work on MacOS even if it supported Vulkan.

Monado is primarily developed on Linux, but it also works on Android and Windows (with varying capabilities), and I know some folks have done some hacks to run it on Mac too (nothing complete or mergeable yet I guess? I don’t have a mac so I can’t test it.) It’s intended to work on a wide range of platforms. In terms of physical hardware support and capability it does best on Linux, but you can use it for development if nothing else elsewhere too. As far as I know, Mac is missing some API surface that would be required to make a meaningfully performant VR headset and runtime, at least exposed to normal userspace.

The OpenXR plugin is available on macOS and I’m able to select an OpenXR runtime and enter play mode. However, the logs show that Unity loads its mock OpenXR runtime instead of the one selected and also disables rendering (tested with both Metal and the deprecated OpenGL API):

[Subsystems] OpenXR XR Plugin successfully registered Provider for OpenXR Display
[Subsystems] OpenXR XR Plugin successfully registered Provider for OpenXR Input
[Subsystems] OpenXR XR Plugin successfully registered Provider for OpenXR Display
[Subsystems] Loading plugin UnityOpenXR for subsystem OpenXR Display...
[XR] Unsupported graphics API - falling back to NullGraphicsPlugin

...

==== Start Unity OpenXR Diagnostic Report ====

...

[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] ==== OpenXR Runtime Info ====
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Features requested to be enabled: (1)
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   Oculus Touch Controller Profile: Version=0.0.1, Company="Unity"
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Requested feature extensions not supported by runtime: (0)
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Available Runtime Extensions: (16)
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_UNITY_mock_test: Version=123
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_UNITY_null_gfx: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_UNITY_android_present: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_KHR_visibility_mask: Version=2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_EXT_conformance_automation: Version=3
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_KHR_composition_layer_depth: Version=6
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_VARJO_quad_views: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_MSFT_secondary_view_configuration: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_EXT_eye_gaze_interaction: Version=2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_MSFT_hand_interaction: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_EXT_hand_interaction: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_FB_touch_controller_pro: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_MSFT_first_person_observer: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_MSFT_third_person_observer_private: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_META_performance_metrics: Version=2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_EXT_hp_mixed_reality_controller: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Available Layers: (0)
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Runtime Name: Unity Mock Runtime
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Runtime Version: 0.0.2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Form factor: XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] 
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ] Runtime extensions enabled: (4)
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_KHR_composition_layer_depth: Version=6
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_KHR_visibility_mask: Version=2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_UNITY_null_gfx: Version=1
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]   XR_META_performance_metrics: Version=2
[XR] [0x7ff857f1f640] [13:22:03.466][Info   ]

...

==== End Unity OpenXR Diagnostic Report ====

On Linux it indeed doesn’t work at all:

It looks like they’re adding the framework for eventual cross-platform OpenXR support, but they’re not quite there yet.

This is awesome! I’ll have to decide now whether to switch to Monado because I’m already quite far with this project (working headset and controller input, D3D11 and Vulkan support) and I don’t need 100% conformance, but using Monado would make everything much simpler.

I see, so that could be one of the reasons why Valve dropped SteamVR support for macOS a few years ago. Maybe Apple’s Vision Pro will give us some new user-space APIs for VR runtime development?

Oh that’s surprising. Not sure if any of the headset vendors are looking to support MacOS though, it might just be there to help with development for the Apple Vision Pro.

I think a fair number of developers for standalone headsets also use macOS.