pub struct OpenXrRenderTarget<S>where
S: OpenXrImageSource<TextureFormat = TextureFormat> + Send + 'static,{ /* private fields */ }Expand description
Legacy wgpu RenderTarget backed by a generic OpenXrImageSource.
The target serializes source callbacks behind a mutex and converts source failures into renderer errors. A poisoned mutex reports a conservative 1x1 BGRA target for metadata queries and fails acquisition.
§Examples
use ailloli_ui_openxr::{OpenXrImageSource, OpenXrRenderTarget};
fn accept<S>(target: OpenXrRenderTarget<S>)
where S: OpenXrImageSource<TextureFormat = wgpu::TextureFormat> + Send + 'static
{ drop(target); }Implementations§
Source§impl<S> OpenXrRenderTarget<S>where
S: OpenXrImageSource<TextureFormat = TextureFormat> + Send + 'static,
impl<S> OpenXrRenderTarget<S>where
S: OpenXrImageSource<TextureFormat = TextureFormat> + Send + 'static,
Sourcepub fn new(source: S) -> Self
pub fn new(source: S) -> Self
Wraps an image source in a renderer-compatible target.
§Examples
use ailloli_ui_openxr::{CallbackImageSource, OpenXrHostResult, OpenXrImageFrame, OpenXrRenderTarget};
use ailloli_ui_render::render_target::PhysicalExtent;
let source = CallbackImageSource::new(
PhysicalExtent::new(640, 480),
wgpu::TextureFormat::Bgra8Unorm,
|| -> OpenXrHostResult<OpenXrImageFrame<u64>> { panic!("host callback") },
|_| Ok(()),
);
let _target = OpenXrRenderTarget::new(source);Sourcepub fn replace_source(&mut self, source: S)
pub fn replace_source(&mut self, source: S)
Replaces the source while preserving the target value used by a renderer.
Any unpresented frame from the old source remains the caller’s lifecycle responsibility.
§Examples
use ailloli_ui_openxr::{CallbackImageSource, OpenXrHostResult, OpenXrImageFrame, OpenXrRenderTarget};
use ailloli_ui_render::render_target::PhysicalExtent;
fn source() -> CallbackImageSource<impl FnMut() -> OpenXrHostResult<OpenXrImageFrame<u64>> + Send, impl FnMut(u64) -> OpenXrHostResult<()> + Send> {
CallbackImageSource::new(PhysicalExtent::new(1, 1), wgpu::TextureFormat::Bgra8Unorm, || panic!(), |_| Ok(()))
}
let mut target = OpenXrRenderTarget::new(source());
target.replace_source(source());Trait Implementations§
Source§impl<S> RenderTarget for OpenXrRenderTarget<S>where
S: OpenXrImageSource<TextureFormat = TextureFormat> + Send + 'static,
impl<S> RenderTarget for OpenXrRenderTarget<S>where
S: OpenXrImageSource<TextureFormat = TextureFormat> + Send + 'static,
Source§fn size(&self) -> PhysicalExtent
fn size(&self) -> PhysicalExtent
Returns the current physical-pixel extent. Read more
Source§fn format(&self) -> TextureFormat
fn format(&self) -> TextureFormat
Returns the texture format of subsequently acquired frames. Read more
Source§fn acquire_frame(&mut self) -> Result<RenderFrame, RendererError>
fn acquire_frame(&mut self) -> Result<RenderFrame, RendererError>
Acquires one renderable frame or a typed renderer error. Read more
Source§fn pre_present_notify(&self)
fn pre_present_notify(&self)
Gives the host a chance to notify its window system before presentation. Read more
Source§fn try_resize(
&mut self,
_size: PhysicalExtent,
) -> Result<ResizeOutcome, RendererError>
fn try_resize( &mut self, _size: PhysicalExtent, ) -> Result<ResizeOutcome, RendererError>
Requests a new physical-pixel extent. Read more
Auto Trait Implementations§
impl<S> Freeze for OpenXrRenderTarget<S>
impl<S> !RefUnwindSafe for OpenXrRenderTarget<S>
impl<S> Send for OpenXrRenderTarget<S>
impl<S> Sync for OpenXrRenderTarget<S>
impl<S> Unpin for OpenXrRenderTarget<S>
impl<S> !UnwindSafe for OpenXrRenderTarget<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more