Mateo de Mayo

First Update

Mateo de Mayo

15 February 2021

Summary

These blog posts are a way to share and document my experience learning about VR, OpenXR and graphics in general. Hopefully, this will be the first of many to come.

Background

Graphics programming must be the area of software I’ve come across with the most without ever really diving into it.

All of those and more are instances in which I was indirectly working with graphics libraries, frameworks and concepts. Textures, z-buffers, render targets, framebuffers and many others are terms I came across and tried to understand in these contexts. A rough idea of the big picture, the rendering pipeline was generally useful but without a strong knowledge about it, the concepts sometimes did just not fit together as well as I would’ve wanted them to.

Hopefully, this is about to change. Right now I’m in the process of learning many of these concepts to use them in the context of VR. What I will do in VR? Well, it’s not entirely clear right now, it may have something to do with SLAM, but it’ll surely involve using the OpenXR standard and Monado (an open source OpenXR runtime for Linux).

Monado

Monado is an open source runtime for the OpenXR standard. Khronos provides header files and a loader that finds a runtime that has the code for those headers. I will not go into too much detail but just reference as a good resource the Monado getting started page.

I spend some time carefully compiling and placing each dependency as I’m running a distro based on Ubuntu 18.04 which is not recommended by the Monado team. So far everything is working fine. Just for reference, I needed to compile and/or install newer versions of cmake, meson, glslang-tools and libcjson-dev.

Once Monado was installed I tried out the hello_xr from Khronos, the blender OpenXR plugin, and the “developing with Monado” example. I recommend doing a complete read of the Monado website, it has very useful information. I didn’t even know what an HMD was at first, but the site has plenty of terms to search about and get a better idea of the vocabulary.

OpenXR

To familiarize myself with the OpenXR standard I cloned the openxr-simple-example demo from Monado’s GitLab. There is a file with about 1500 lines of commented code that goes through every OpenXR step to have some cubes moving in OpenGL. The way I approached this read was to have the OpenXR spec and headers at hand while reading the code. I took my time reading and going off on tangents.

In this repo, there is also a math_3d.h file that is quite well written and has basic math functions for graphics. There were some of them I didn’t have theoretical bases to understand. Also, there was quite a bit of OpenGL rendering code in the main.c file that I did not really understood. These two aspects of graphics, the theory and the library specifics like OpenGL and Vulkan are things I know are very related to OpenXR and will need to dive into.

The OpenXR API itself takes a lot of inspiration from Vulkan. For instance, the way of working with structs and the famous thousand lines from Vulkan seems to apply to OpenXR too. It is a bit cumbersome at first to read the code as sometimes you may need more than ten lines just to make a call because you need to fill some structs that then get passed as a parameter to an API call. Once you get used to it though, it is quite straightforward. The key is to identify the right concepts and their hierarchy. This talk helped with that.

Vulkan

After I finished reading the openxr-simple-example, I decided to dig a bit into the graphics library side with Vulkan. As I’ve heard that it is more explicit I figured it would be a good idea to start with it instead of OpenGL with the hopes that some concepts may translate into OpenGL in some way.

I went with the 7-part introduction to Vulkan at https://www.fasterthan.life/blog. It provides a good top-down overview of how Vulkan works. Again with the spec at hand, it is quite a similar task to the previous one. Here the similarities between Vulkan and OpenXR start to shine. Right now I’m reading the last parts of this tutorial.

Meta

It is good to join the Discord and Slack of Monado, xrdesktop and OpenXR. I’ve not made any questions yet mainly because the ones I had were answered with some more hours of reading, but it is nice to see what the community is talking about. It lets you understand a bit better the projects, who uses them and what are the state of things around them.

Also, when I dive into a new topic I like to get soaked in it. I subscribed and started to watch some consumer VR channels and watched some Skyrim VR mods development on youtube. I got interested in the Quest 2 even though there seems to be no mention of it in the spec nor in Monado. Will need to further investigate.

Lastly, I created this blog from scratch using Jekyll. I know I should’ve just used a template but my impulses were stronger.

What’s next

This is what I’ve been to. What about what I’ll be doing the following weeks? First of all, I’ll finish the Vulkan tutorial I’m doing. After that, however, I’m not yet certain but will probably be some of the following.

Besides all of the above, what I would like to do now, is to come up with a project to do. That would probably be the best way to learn any of the concepts and libraries mentioned.