Skip to content
This repository has been archived by the owner on Feb 16, 2025. It is now read-only.

Commit

Permalink
Support SteamVR-backed sessions for OpenXR
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Adams <msub2official@gmail.com>
  • Loading branch information
msub2 committed Sep 9, 2024
1 parent 1a2186a commit 9ce4e11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions webxr/openxr/graphics_d3d11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ impl GraphicsProviderMethods<D3D11> for GraphicsProvider {
warn!("Available formats: {:?}", formats);
for format in formats {
match *format {
dxgiformat::DXGI_FORMAT_B8G8R8A8_UNORM_SRGB => return *format,
dxgiformat::DXGI_FORMAT_B8G8R8A8_UNORM => return *format,
//dxgiformat::DXGI_FORMAT_R8G8B8A8_UNORM => return *format,
f => {
Expand Down
13 changes: 10 additions & 3 deletions webxr/openxr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,11 @@ pub fn create_instance(
let properties = instance
.view_configuration_properties(system, ViewConfigurationType::PRIMARY_STEREO)
.map_err(|e| format!("Instance::view_configuration_properties {:?}", e))?;
properties.fov_mutable
// Unfortunately we need to do a platform check here as just flipping the FOVs for the
// composition layer is seemingly no longer sufficient. As long as windows sessions are
// solely backed by D3D11, we'll need to apply the same inverted view + reversed winding
// fix for SteamVR as well as Oculus.
properties.fov_mutable && !cfg!(target_os = "windows")
};

Ok(CreatedInstance {
Expand Down Expand Up @@ -623,11 +627,14 @@ impl LayerManagerAPI<SurfmanGL> for OpenXrLayerManager {
let openxr_layers = &self.openxr_layers;

// Invert the up/down angles so that openxr flips the texture in the y axis.
// Additionally, swap between the L/R views to compensate for inverted up/down FOVs.
// This has no effect in runtimes that don't support fovMutable
let mut l_fov = data.left.view.fov;
let mut r_fov = data.right.view.fov;
std::mem::swap(&mut l_fov.angle_up, &mut l_fov.angle_down);
std::mem::swap(&mut r_fov.angle_up, &mut r_fov.angle_down);
if cfg!(target_os = "windows") {
std::mem::swap(&mut l_fov.angle_up, &mut r_fov.angle_down);
std::mem::swap(&mut r_fov.angle_up, &mut l_fov.angle_down);
}

let viewports = data.viewports();
let primary_views = layers
Expand Down

0 comments on commit 9ce4e11

Please sign in to comment.