-
-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): ✨ Make lobby use passthrough (#2485)
- Loading branch information
Showing
14 changed files
with
322 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,4 +55,4 @@ fn fragment_main(@location(0) uv: vec2f) -> @location(0) vec4f { | |
} | ||
|
||
return vec4f(result, 1.0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
use openxr::{self as xr, raw, sys}; | ||
use std::ptr; | ||
|
||
pub struct PassthroughFB { | ||
handle: sys::PassthroughFB, | ||
layer_handle: sys::PassthroughLayerFB, | ||
layer: sys::CompositionLayerPassthroughFB, | ||
ext_fns: raw::PassthroughFB, | ||
} | ||
|
||
impl PassthroughFB { | ||
pub fn new(session: &xr::Session<xr::OpenGlEs>) -> xr::Result<Self> { | ||
let ext_fns = session | ||
.instance() | ||
.exts() | ||
.fb_passthrough | ||
.ok_or(sys::Result::ERROR_EXTENSION_NOT_PRESENT)?; | ||
|
||
let mut handle = sys::PassthroughFB::NULL; | ||
let info = sys::PassthroughCreateInfoFB { | ||
ty: sys::PassthroughCreateInfoFB::TYPE, | ||
next: ptr::null(), | ||
flags: sys::PassthroughFlagsFB::IS_RUNNING_AT_CREATION, | ||
}; | ||
unsafe { | ||
super::xr_res((ext_fns.create_passthrough)( | ||
session.as_raw(), | ||
&info, | ||
&mut handle, | ||
))? | ||
}; | ||
|
||
let mut layer_handle = sys::PassthroughLayerFB::NULL; | ||
let info = sys::PassthroughLayerCreateInfoFB { | ||
ty: sys::PassthroughLayerCreateInfoFB::TYPE, | ||
next: ptr::null(), | ||
passthrough: handle, | ||
flags: sys::PassthroughFlagsFB::IS_RUNNING_AT_CREATION, | ||
purpose: sys::PassthroughLayerPurposeFB::RECONSTRUCTION, | ||
}; | ||
unsafe { | ||
super::xr_res((ext_fns.create_passthrough_layer)( | ||
session.as_raw(), | ||
&info, | ||
&mut layer_handle, | ||
))? | ||
}; | ||
|
||
let layer = sys::CompositionLayerPassthroughFB { | ||
ty: sys::CompositionLayerPassthroughFB::TYPE, | ||
next: ptr::null(), | ||
flags: xr::CompositionLayerFlags::EMPTY, | ||
space: sys::Space::NULL, | ||
layer_handle, | ||
}; | ||
|
||
Ok(Self { | ||
handle, | ||
layer_handle, | ||
layer, | ||
ext_fns, | ||
}) | ||
} | ||
|
||
// return reference to make sure the passthrough handle is not dropped while the layer is in use | ||
pub fn layer(&self) -> &sys::CompositionLayerPassthroughFB { | ||
&self.layer | ||
} | ||
} | ||
|
||
impl Drop for PassthroughFB { | ||
fn drop(&mut self) { | ||
unsafe { | ||
(self.ext_fns.destroy_passthrough_layer)(self.layer_handle); | ||
(self.ext_fns.destroy_passthrough)(self.handle); | ||
} | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
alvr/client_openxr/src/extra_extensions/passthrough_htc.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use openxr::{self as xr, raw, sys}; | ||
use std::ptr; | ||
|
||
pub struct PassthroughHTC { | ||
handle: sys::PassthroughHTC, | ||
layer: sys::CompositionLayerPassthroughHTC, | ||
ext_fns: raw::PassthroughHTC, | ||
} | ||
|
||
impl PassthroughHTC { | ||
pub fn new(session: &xr::Session<xr::OpenGlEs>) -> xr::Result<Self> { | ||
let ext_fns = session | ||
.instance() | ||
.exts() | ||
.htc_passthrough | ||
.ok_or(sys::Result::ERROR_EXTENSION_NOT_PRESENT)?; | ||
|
||
let mut handle = sys::PassthroughHTC::NULL; | ||
let info = sys::PassthroughCreateInfoHTC { | ||
ty: sys::PassthroughCreateInfoHTC::TYPE, | ||
next: ptr::null(), | ||
form: sys::PassthroughFormHTC::PLANAR, | ||
}; | ||
unsafe { | ||
super::xr_res((ext_fns.create_passthrough)( | ||
session.as_raw(), | ||
&info, | ||
&mut handle, | ||
))? | ||
}; | ||
|
||
let layer = sys::CompositionLayerPassthroughHTC { | ||
ty: sys::CompositionLayerPassthroughHTC::TYPE, | ||
next: ptr::null(), | ||
layer_flags: xr::CompositionLayerFlags::EMPTY, | ||
space: sys::Space::NULL, | ||
passthrough: handle, | ||
color: sys::PassthroughColorHTC { | ||
ty: sys::PassthroughColorHTC::TYPE, | ||
next: ptr::null(), | ||
alpha: 1.0, | ||
}, | ||
}; | ||
|
||
Ok(Self { | ||
handle, | ||
layer, | ||
ext_fns, | ||
}) | ||
} | ||
|
||
// return reference to make sure the passthrough handle is not dropped while the layer is in use | ||
pub fn layer(&self) -> &sys::CompositionLayerPassthroughHTC { | ||
&self.layer | ||
} | ||
} | ||
|
||
impl Drop for PassthroughHTC { | ||
fn drop(&mut self) { | ||
unsafe { | ||
(self.ext_fns.destroy_passthrough)(self.handle); | ||
} | ||
} | ||
} |
Oops, something went wrong.