https://github.com/philpax/wgpu-openxr-example
a barebones example of how to integrate OpenXR with wgpu (Vulkan-only)
https://github.com/philpax/wgpu-openxr-example
openxr vulkan wgpu
Last synced: 11 months ago
JSON representation
a barebones example of how to integrate OpenXR with wgpu (Vulkan-only)
- Host: GitHub
- URL: https://github.com/philpax/wgpu-openxr-example
- Owner: philpax
- License: mit
- Created: 2022-09-27T01:45:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-05-17T04:48:37.000Z (about 3 years ago)
- Last Synced: 2025-07-04T17:13:42.435Z (11 months ago)
- Topics: openxr, vulkan, wgpu
- Language: Rust
- Homepage:
- Size: 190 KB
- Stars: 54
- Watchers: 3
- Forks: 10
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wgpu-openxr-example
a barebones example of how to integrate OpenXR with wgpu (Vulkan-only)
It has four modes:
- `cargo run --no-default-features`: desktop-only, renders the scene without _any_ XR integration
- `cargo run -- desktop`: build with XR support, but render the scene without initialising XR
- `cargo run -- desktop-with-xr-resolution`: build with XR support, initialise XR, but do not render to headset
- `cargo run -- xr`: build with XR support, and render to the headset
These modes are intended to show you how to gracefully integrate XR into your project's code
and how you can move from one stage of integration to the next.
Note that this code is not production-quality; there are a few shortcuts that have been taken
in the interest of keeping it simple and relatively modular. Make sure to clean up your resources
properly and use robust code where possible :)
## Rendering flow
The code renders three instances of a triangle (two being the controllers) to a multi-view render target.
- In desktop mode, this render target is then blitted to the swapchain, and the user can select which view
to look at using the arrow keys.
- In desktop with XR resolution mode, much the same occurs, except the window is resized to the XR headset's
render resolution.
- In XR mode, the program synchronises with the headset and blits the multi-view render target to the
headset as well.
Rendering to a render target is necessary to accommodate these:
- Showing what the user is seeing within the desktop window, without having to re-render the scene
- Decoupling the colour formats of the various display surfaces; wgpu (on my machine) will offer
`BGRA8888`, while my OpenXR runtime offers `RGBA8888`.
## Future
It should theoretically be possible to do the following:
- D3D11/12 backend with OpenXR
- WebGL2 backend with WebXR
- Metal backend with ARKit
## Reference
Cobbled together from the following sources:
-
-
-
-
-