The open source OpenXR runtime.
Find a file
Linus Lüssing fca4ac41e5 d/wmr: avoid using non-self-explanatory numbers for input allocations
By using an extra, final entry in the according inputs enum instead
of using a hard coded number it should be slightly safer and easier
to verify that the to be allocated inputs array is of correct size.

No functional change.

Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
2023-06-13 20:28:05 +00:00
.gitlab-ci ci: Fix archlinux container 2023-05-22 16:53:15 +02:00
.reuse external: Add NanoPB 2022-11-24 00:34:50 +00:00
cmake cmake: Add name for OpenXR manifest file 2023-06-02 15:53:44 +00:00
doc doc: Document !1836 2023-06-13 19:23:56 +01:00
gradle/wrapper gradle: Bump Gradle to 7.4.2 2022-06-27 10:00:01 -05:00
LICENSES licenses: Add Zlib license 2022-11-24 00:34:50 +00:00
scripts a/vk: Add vkCmdPushConstants 2023-05-19 23:18:29 +01:00
src d/wmr: avoid using non-self-explanatory numbers for input allocations 2023-06-13 20:28:05 +00:00
tests cmake: Fix build failure on msys2/mingw64 2023-05-15 16:41:34 +00:00
.clang-tidy clang-tidy: Enable -misc-unused-using-decls check 2023-04-10 11:06:23 +00:00
.cmake-format.py cmake: Switch to a new way of setting options more in line with expectations. 2022-05-04 11:24:02 -05:00
.editorconfig editorconfig: Update 2021-04-13 11:46:53 -05:00
.gitignore .gitignore: Ignore .hprof files 2023-04-11 11:43:57 +00:00
.gitlab-ci.yml ci: Fix archlinux container 2023-05-22 16:53:15 +02:00
build.gradle gradle: Enable spotless for Gradle, Markdown and gitignore files 2023-04-17 10:58:38 -05:00
CMakeLists.txt build,a/{os,util},xrt,ipc: Fix compilation with Mingw64 on MSYS2 2023-06-05 12:03:47 -05:00
CMakePresets.json build: Remove condition from CMakePresets 2023-02-27 15:02:33 -06:00
CMakePresets.json.license cmake: Add CMakePresets.json 2022-06-07 17:49:50 +00:00
CompilerFlags.cmake cmake: Fix build flags on MSVC 2023-05-16 22:04:53 +00:00
CONTRIBUTING.md contributing: Mention how to run spotless. 2023-04-17 10:58:38 -05:00
gradle.properties aux/android: Add Java code 2020-10-28 09:33:26 -05:00
gradlew t/oxr_android: add licenses for gradlew 2022-03-16 20:29:50 +00:00
gradlew.bat t/oxr_android: add licenses for gradlew 2022-03-16 20:29:50 +00:00
LICENSE Add LICENSE file 2019-09-18 09:30:16 +01:00
README.md Fixed a small typo. 2023-04-04 13:05:47 +00:00
settings.gradle gradle: Update some deps slightly to cope with gradle 7 2022-06-25 09:59:37 +08:00
vcpkg.json vcpkg: Add an option for OpenCV tracking support 2023-05-16 22:04:53 +00:00
vcpkg.json.license build: Add vcpkg manifest for easier Windows builds 2021-06-08 12:05:23 -05:00

Monado - XR Runtime (XRT)

Monado is an open source XR runtime delivering immersive experiences such as VR and AR on mobile, PC/desktop, and any other device (because gosh darn people come up with a lot of weird hardware). Monado aims to be a complete and conforming implementation of the OpenXR API made by Khronos. The project is primarily developed on GNU/Linux, but also runs on Android and Windows. "Monado" has no specific meaning and is just a name.

Monado source tree

  • src/xrt/include - headers that define the internal interfaces of Monado.
  • src/xrt/compositor - code for doing distortion and driving the display hardware of a device.
  • src/xrt/auxiliary - utilities and other larger components.
  • src/xrt/drivers - hardware drivers.
  • src/xrt/state_trackers/oxr - OpenXR API implementation.
  • src/xrt/targets - glue code and build logic to produce final binaries.
  • src/external - a small collection of external code and headers.

Getting Started

Dependencies include:

  • CMake 3.13 or newer (Note Ubuntu 18.04 only has 3.10)
  • Python 3.6 or newer
  • Vulkan headers and loader - Fedora package vulkan-loader-devel
  • OpenGL headers
  • Eigen3 - Debian/Ubuntu package 'libeigen3-dev'
  • glslangValidator - Debian/Ubuntu package glslang-tools, Fedora package glslang.
  • libusb
  • libudev - Fedora package systemd-devel
  • Video 4 Linux - Debian/Ubuntu package libv4l-dev.

Optional (but recommended) dependencies:

  • libxcb and xcb-xrandr development packages
  • OpenHMD 0.3.0 or newer (found using pkg-config)

Truly optional dependencies, useful for some drivers, app support, etc.:

  • Doxygen
  • Wayland development packages
  • Xlib development packages
  • libhidapi
  • OpenCV
  • libuvc
  • ffmpeg
  • libjpeg
  • libbluetooth

Experimental Windows support requires the Vulkan SDK and also needs or works best with the following vcpkg packages installed:

  • pthreads eigen3 libusb hidapi zlib doxygen

If you have a recent vcpkg installed and use the appropriate CMake toolchain file, the vcpkg manifest in the Monado repository will instruct vcpkg to locally install the dependencies automatically.

Monado has been tested on these distributions, but is expected to work on almost any modern distribution.

  • Ubuntu 22.04, 20.04, (18.04 may not be fully supported)
  • Debian 11 bookworm, 10 buster
    • Up-to-date package lists can be found in our CI config file, .gitlab-ci.yml
  • Archlinux

These distributions include recent-enough versions of all the software to use direct mode, without using any external, third-party, or backported package sources.

See also Status of DRM Leases for more details on specific packages, versions, and commits.

Due to the lack of a OpenGL extension: GL_EXT_memory_object_fd on Intel's OpenGL driver, only the AMD radeonsi driver and the proprietary NVIDIA driver will work for OpenGL OpenXR clients. This is due to a requirement of the Compositor. Support status of the extension can be found on the mesamatrix website.

CMake

Build process is similar to other CMake builds, so something like the following will build it.

Go into the source directory, create a build directory, and change into it.

mkdir build
cd build

Then, invoke CMake to generate a project. Feel free to change the build type or generator ("Ninja" is fast and parallel) as you see fit.

cmake .. -DCMAKE_BUILD_TYPE=Debug -G "Unix Makefiles"

If you plan to install the runtime, append something like -DCMAKE_INSTALL_PREFIX=~/.local to specify the root of the install directory. (The default install prefix is /usr/local.)

To build, the generic CMake build commands below will work on all systems, though you can manually invoke your build tool (make, ninja, etc.) if you prefer. The first command builds the runtime and docs, and the second, which is optional, installs the runtime under ${CMAKE_INSTALL_PREFIX}.

cmake --build .
cmake --build . --target install

Alternately, if using Make, the following will build the runtime and docs, then install. Replace make with ninja if you used the Ninja generator.

make
make install

Documentation can be browsed by opening doc/html/index.html in the build directory in a web browser.

Getting started using OpenXR with Monado

This implements the OpenXR API, so to do anything with it, you'll need an application that uses OpenXR, along with the OpenXR loader. The OpenXR loader is a glue library that connects OpenXR applications to OpenXR runtimes such as Monado It determines which runtime to use by looking for the config file active_runtime.json (either a symlink to or a copy of a runtime manifest) in the usual XDG config paths and processes environment variables such as XR_RUNTIME_JSON=/usr/share/openxr/0/openxr_monado.json. It can also insert OpenXR API Layers without the application or the runtime having to do it.

You can use the hello_xr sample provided with the OpenXR SDK.

The OpenXR loader can be pointed to a runtime json file in a nonstandard location with the environment variable XR_RUNTIME_JSON. Example:

XR_RUNTIME_JSON=~/monado/build/openxr_monado-dev.json ./openxr-example

For ease of development Monado creates a runtime manifest file in its build directory using an absolute path to the Monado runtime in the build directory called openxr_monado-dev.json. Pointing XR_RUNTIME_JSON to this file allows using Monado after building, without installing.

Note that the loader can always find and load the runtime if the path to the runtime library given in the json manifest is an absolute path, but if a relative path like libopenxr_monado.so.0 is given, then LD_LIBRARY_PATH must include the directory that contains libopenxr_monado.so.0. The absolute path in openxr_monado-dev.json takes care of this for you.

Distribution packages for monado may provide the "active runtime" file /etc/xdg/openxr/1/active_runtime.json. In this case the loader will automatically use Monado when starting an OpenXR application. This global configuration can be overridden on a per user basis by creating ~/.config/openxr/1/active_runtime.json.

Direct mode

On AMD and Intel GPUs our direct mode code requires a connected HMD to have the non-desktop xrandr property set to 1. Only the most common HMDs have the needed quirks added to the linux kernel.

If you know that your HMD lacks the quirk you can run this command before or after connecting the HMD and it will have it. Where HDMI-A-0 is the xrandr output name where you plug the HMD in.

xrandr --output HDMI-A-0 --prop --set non-desktop 1

You can verify that it stuck with the command.

xrandr --prop

Running Vulkan Validation

To run Monado with Vulkan validation the loader's layer functionality can be used.

VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ./build/src/xrt/targets/service/monado-service

The same can be done when launching a Vulkan client.

If you want a backtrace to be produced at validation errors, create a vk_layer_settings.txt file with the following content:

khronos_validation.debug_action = VK_DBG_LAYER_ACTION_LOG_MSG,VK_DBG_LAYER_ACTION_BREAK
khronos_validation.report_flags = error,warn
khronos_validation.log_filename = stdout

Coding style and formatting

clang-format is used, and a .clang-format config file is present in the repo to allow your editor to use them.

To manually apply clang-format to every non-external source file in the tree, run this command in the source dir with a sh-compatible shell (Git for Windows git-bash should be OK):

scripts/format-project.sh

You can optionally put something like CLANG_FORMAT=clang-format-7 before that command if your clang-format binary isn't named clang-format. Note that you'll typically prefer to use something like git clang-format to re-format only your changes, in case version differences in tools result in overall format changes. The CI "style" job currently runs on Debian Bullseye, so it has clang-format-11.

Contributing, Code of Conduct

See CONTRIBUTING.md for details of contribution guidelines. GitLab Issues and Merge Requests are the preferred way to discuss problems, suggest enhancements, or submit changes for review. In case of a security issue, you should choose the "confidential" option when using the GitLab issues page. For highest security, you can send encrypted email (using GPG/OpenPGP) to Ryan Pavlik, with the address below and the associated key on https://keys.openpgp.org.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

We follow the standard freedesktop.org code of conduct, available at https://www.freedesktop.org/wiki/CodeOfConduct/, which is based on the Contributor Covenant.

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting:

Code of Conduct section excerpt adapted from the Contributor Covenant, version 1.4.1, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html, and from the freedesktop.org-specific version of that code, available at https://www.freedesktop.org/wiki/CodeOfConduct/, used under CC-BY-4.0.