Friday, September 10, 2021

Introduction to OpenXR Explorer

Screenshot of the OpenXR Explorer application.Screenshot of the OpenXR Explorer application.

If you're a Unity or Unreal developer that's building an experience atop OpenXR, or a lower level developer that might be interacting with OpenXR directly, then OpenXR Explorer is a tool that may be of interest to you! There are numerous OpenXR runtimes out there, and OpenXR Explorer can help you find your way around each of these separately maintained implementations.

 

OpenXR Runtimes

 

OpenXR is unfortunately not a singular library that simply handles all XR headsets, instead it's a common API that many different companies agree upon and implement. There are currently 5 conformant OpenXR runtimes available on Windows alone! These runtimes do have to pass a conformance test that assures a base level of consistent behavior, and this means that a well designed OpenXR application should run on any OpenXR runtime it encounters on its target platforms!

 

In reality, this is easier said than done, especially once you consider extensions. Right now, much of the really interesting XR behavior is present in the form of optional OpenXR extensions. For example, XR_MSFT_spatial_anchor is a MSFT extension that's currently only implemented in Microsoft OpenXR runtimes like Windows Mixed Reality! In time, extensions like these may graduate to KHR extensions, officially recognized by Khronos as a common, yet still optional extension. You can read about how extensions are adopted into the standard over in the spec.

 

For the thorough developer, this means a lot of testing. And for the developer working directly with OpenXR, understanding what differences to expect can help with designing your code. OpenXR Explorer helps you peek at information provided by each runtime, see the extensions it implements, as well as inspect some common properties and enumerations that can be queried. In addition to this, OpenXR Explorer provides some functionality for easily changing active runtimes, by a visual user interface, or via command line.

 

Runtime Switching

 

Each OpenXR runtime has its own way of setting itself as active! This is generally fine for normal users, but as a developer, it can be nice to have some options. On Windows, the active runtime is indicated using a registry key, and while you could modify this directly yourself, OpenXR Explorer provides a simple way to do this with just a click!

 

User changing runtime using the OpenXR Explorer GUIUser changing runtime using the OpenXR Explorer GUI

Alternatively, you can use xrsetruntime.exe via the Command Prompt directly. Runtime switching is performed with a separate executable to prevent the main OpenXR Explorer application from requiring admin access to the computer when modifying the OpenXR registry key.

 

# To list all available OpenXR runtimes
xrsetruntime.exe --list

# From a Command Prompt with Admin permissions
xrsetruntime.exe -WMR

 

 

Extensions and Properties

 

A quick glance at a runtime's extension support can tell you a lot about what to expect! For example, the Windows Mixed Reality runtime on Windows currently supports the XR_KHR_D3D11_enable and XR_KHR_D3D12_enable extensions, but not XR_KHR_opengl_enable, XR_KHR_vulkan_enable, or XR_KHR_vulkan_enable2. This would be an important thing to know about for a certain subset of developers!

 

OpenXR Explorer's extension view, with links to the specOpenXR Explorer's extension view, with links to the spec

OpenXR Explorer can also attempt to spin up an instance of the runtime and query OpenXR for any easily accessible properties it provides. Knowing what the recommended display resolution is, or what type of positioning/reference spaces the runtime supports can also be quite handy! In addition, OpenXR runtimes often list enumerations in order of preference, so it can be quite insightful to see, for example, what swapchain formats are listed towards the top of the enumeration list.

 

And for those interested in the gritty details about the information they're seeing, the GUI provides quick links to the relevant portions of the OpenXR specification! The spec is an invaluable resource for the native developer, or those curious about the exact behavior indicated by a particular enumeration.

 

OpenXR explorer also provides a Command Line Interface that will allow you to gather all the same information via the Command Prompt! When provided command line arguments, OpenXR Explorer will skip the GUI, and just print out information.

 

# To list what arguments are available
openxr-explorer.exe -help

# To show the runtime's extension list, you can pass in either the name of the
# function, or the structure that contains the data.
openxr-explorer.exe -xrEnumerateInstanceExtensionProperties
# Or
openxr-explorer.exe -XrExtensionProperties

 

 

Try it out!

 

You can download the latest Windows or Linux builds of OpenXR Explorer here. It's also open source under the MIT license, and you can find the code as well as additional instructions here! We hope you'll find this tool useful along your OpenXR journey, and welcome any feedback or contributions :)

Posted at https://sl.advdat.com/3z1PBIw