gfx-rs / gfx

[maintenance mode] A low-overhead Vulkan-like GPU API for Rust.
http://gfx-rs.github.io/
Apache License 2.0
5.36k stars 546 forks source link

Support for OpenVR #3220

Open LaylBongers opened 4 years ago

LaylBongers commented 4 years ago

OpenVR's downside is that it's essentially locked to the Steam platform. However, because it's significantly easier to support I believe this will make a good first step for exploring a VR API in gfx-hal. And because just about every HMD on the market supports it, it will provide early infrastructure for building VR experiences in Rust.

I've discussed this a bit on discord with @grovesNL, and I'm going to make an attempt at adding this support in a pull request, as I need it myself.

LaylBongers commented 4 years ago

Unfortunately I've hit a snag in my attempt to implement this. I'm getting access violations on submission. It's unclear where this is coming from as the OpenVR API isn't giving me any information to go off. I've tried to experiment a bit to see if I can fix it but I may have hit a wall.

kvark commented 4 years ago

I suppose there must be examples in pure Vulkan on how OpenVR is integrated. As we have very little difference from Vulkan, it should help to figure out what your code is doing differently.

LaylBongers commented 4 years ago

There is a 3800 lines long sample from Valve that doesn't build on my machine because of the Qt dependency, unfortunately. I've verified with a little test application that on OpenGL the OpenVR bindings do work.

LaylBongers commented 4 years ago

I made a little sample app myself: https://gitlab.com/layl/vkvrtest With validation layers printing correctly, it's telling me the VkImage handle wasn't valid, which is weird. I don't really understand what's going wrong here.

LaylBongers commented 4 years ago

Latest push to the test code fixes the example good enough to run on Oculus drivers, with a lot of validation errors. It seems that, according to the OpenVR example, the "unique_objects" part of the validation layers can't be enabled with OpenVR. Beyond that, the Oculus driver raises a lot more validation errors, some of which cause access violations, so I also had to disable core validation. This still has validation errors, but none that crash.

This is not really an optimal solution, I'm afraid that it seems until these issues are fixed by the driver vendor there's not much that can be done. A workaround in vulkan would be to create a separate instance while enabling validating and doing anything that may cause validation errors on the different instance. This feels very hacky, and isn't platform independent, but I don't see another clean way out.