pub trait OpenXrImageSource {
type FrameToken: Clone + Send + 'static;
type TextureFormat: Send + 'static;
// Required methods
fn size(&self) -> PhysicalExtent;
fn format(&self) -> Self::TextureFormat;
fn acquire(&self) -> OpenXrHostResult<OpenXrImageFrame<Self::FrameToken>>;
fn present(&self, token: Self::FrameToken) -> OpenXrHostResult<()>;
// Provided method
fn pre_present_notify(&self) { ... }
}Expand description
Abstraction over external wgpu frame providers (mock backends, render-to-texture pipelines, tests).
Implementations must not hand the same image to overlapping acquisitions.
A successful Self::acquire must be paired with exactly one
Self::present using the returned token.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn inspect<S: OpenXrImageSource>(source: &S) {
let _size = source.size();
let _format: S::TextureFormat = source.format();
}Required Associated Types§
Sourcetype FrameToken: Clone + Send + 'static
type FrameToken: Clone + Send + 'static
Token that identifies an acquired image until presentation.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn require_clone<S: OpenXrImageSource>() where S::FrameToken: Clone {}Sourcetype TextureFormat: Send + 'static
type TextureFormat: Send + 'static
Backend texture-format value returned by Self::format.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn require_send<S: OpenXrImageSource>() where S::TextureFormat: Send {}Required Methods§
Sourcefn size(&self) -> PhysicalExtent
fn size(&self) -> PhysicalExtent
Returns the physical pixel extent of future acquired textures.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn width<S: OpenXrImageSource>(source: &S) -> u32 { source.size().width }Sourcefn format(&self) -> Self::TextureFormat
fn format(&self) -> Self::TextureFormat
Returns the format of future acquired textures.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn format<S: OpenXrImageSource>(source: &S) -> S::TextureFormat { source.format() }Sourcefn acquire(&self) -> OpenXrHostResult<OpenXrImageFrame<Self::FrameToken>>
fn acquire(&self) -> OpenXrHostResult<OpenXrImageFrame<Self::FrameToken>>
Acquires one writable texture and its presentation token.
§Errors
Returns a host error when no image is available or acquisition fails.
§Examples
use ailloli_ui_openxr::{OpenXrHostResult, OpenXrImageFrame, OpenXrImageSource};
fn acquire<S: OpenXrImageSource>(source: &S) -> OpenXrHostResult<OpenXrImageFrame<S::FrameToken>> { source.acquire() }Sourcefn present(&self, token: Self::FrameToken) -> OpenXrHostResult<()>
fn present(&self, token: Self::FrameToken) -> OpenXrHostResult<()>
Presents or releases the image identified by token.
§Errors
Returns a host error if the token cannot be submitted or released.
§Examples
use ailloli_ui_openxr::{OpenXrHostResult, OpenXrImageSource};
fn present<S: OpenXrImageSource>(source: &S, token: S::FrameToken) -> OpenXrHostResult<()> { source.present(token) }Provided Methods§
Sourcefn pre_present_notify(&self)
fn pre_present_notify(&self)
Notifies the source immediately before renderer presentation work.
The default is a no-op. Hosts may use this hook for backend ordering.
§Examples
use ailloli_ui_openxr::OpenXrImageSource;
fn notify<S: OpenXrImageSource>(source: &S) { source.pre_present_notify(); }