Struct OpenXrRuntime

Source
pub struct OpenXrRuntime {
    pub view_space: Space,
    pub reference_space: Space,
    pub frame_stream: FrameStream<Vulkan>,
    pub frame_waiter: FrameWaiter,
    pub session: Session<Vulkan>,
    pub vk: OpenXrVulkanContext,
    pub xr: OpenXrInstance,
    pub blend_mode: EnvironmentBlendMode,
}
Expand description

Owned OpenXR session and Vulkan objects for built-in frame loops.

Fields are declared in dependency-safe drop order: session-owned XR objects precede Vulkan, then the instance. A runtime must be driven from one thread in accordance with its OpenXR platform requirements.

§Examples

use ailloli_ui_openxr::OpenXrRuntime;
fn runtime_name(runtime: &OpenXrRuntime) -> &str { &runtime.xr.runtime_name }

Fields§

§view_space: Space

Viewer reference space used to locate the HMD pose.

§reference_space: Space

Application reference space selected from runtime preference.

§frame_stream: FrameStream<Vulkan>

Frame submission stream paired with frame_waiter.

§frame_waiter: FrameWaiter

Wait handle that yields predicted frame timing.

§session: Session<Vulkan>

Vulkan-backed OpenXR session.

§vk: OpenXrVulkanContext

Vulkan instance, device, queue, pool, and memory properties.

§xr: OpenXrInstance

Loader instance, system identity, and negotiated extensions.

§blend_mode: EnvironmentBlendMode

Environment blend mode used by built-in frame submissions.

Implementations§

Source§

impl OpenXrRuntime

Source

pub fn new(options: OpenXrRuntimeOptions) -> Result<Self, OpenXrRuntimeError>

Loads OpenXR/Vulkan and creates a stereo session and reference spaces.

Vulkan 1.0 is requested through XR_KHR_vulkan_enable2; graphics queue family zero within the selected family is used. No frame loop is started.

§Errors

Returns loader, extension, name, instance/system, Vulkan, session, or reference-space initialization failures.

§Examples
use ailloli_ui_openxr::{OpenXrRuntime, OpenXrRuntimeOptions};
let runtime = OpenXrRuntime::new(OpenXrRuntimeOptions::default())?;
println!("{}", runtime.xr.runtime_name);
Source

pub fn input_capabilities(&self) -> OpenXrInputCapabilities

Returns normalized hand-tracking and hand-aim capabilities.

§Examples
use ailloli_ui_openxr::{OpenXrInputCapabilities, OpenXrRuntime};
fn capabilities(runtime: &OpenXrRuntime) -> OpenXrInputCapabilities { runtime.input_capabilities() }
Source

pub fn external_vulkan_context(&self) -> OpenXrExternalVulkanContext<'_>

Borrows the runtime’s Vulkan handles as an external render context.

Physical-device memory properties are included, enabling staging uploads.

§Examples
use ailloli_ui_openxr::{OpenXrExternalVulkanContext, OpenXrRuntime};
fn context(runtime: &OpenXrRuntime) -> OpenXrExternalVulkanContext<'_> { runtime.external_vulkan_context() }
Source

pub fn locate_view_pose( &self, time: Time, ) -> Result<Option<Posef>, OpenXrRuntimeError>

Locates the HMD view space relative to the application reference space.

Returns Ok(None) when position validity is absent. Orientation validity is not separately required by this helper.

§Errors

Returns the native space-location failure.

§Examples
use ailloli_ui_openxr::{OpenXrRuntime, OpenXrRuntimeError};
fn pose(runtime: &OpenXrRuntime, time: openxr::Time) -> Result<Option<openxr::Posef>, OpenXrRuntimeError> { runtime.locate_view_pose(time) }
Source

pub fn run_empty_frame_loop( &mut self, shutdown: impl FnMut() -> bool, ) -> Result<(), OpenXrRuntimeError>

Runs a session loop that submits zero composition layers.

The shutdown callback is checked before each event/frame iteration. Non-running sessions sleep for 16 ms. Runtime exit/loss and a true callback return Ok(()).

§Errors

Returns event, session transition, frame wait/begin, or frame end failures.

§Examples
use ailloli_ui_openxr::{OpenXrRuntime, OpenXrRuntimeError};
fn run(runtime: &mut OpenXrRuntime) -> Result<(), OpenXrRuntimeError> { runtime.run_empty_frame_loop(|| false) }
Source

pub fn run_quad_frame_loop( &mut self, options: OpenXrQuadFrameLoopOptions, shutdown: impl FnMut() -> bool, ) -> Result<(), OpenXrRuntimeError>

Runs a clear-only quad-layer frame loop.

Skipped-render frames submit no layers. Acquired images are synchronously cleared and released before their quad is submitted.

§Errors

Returns session/frame, swapchain, clear, release, or submission failures.

§Examples
use ailloli_ui_openxr::{OpenXrQuadFrameLoopOptions, OpenXrRuntime, OpenXrRuntimeError};
fn run(runtime: &mut OpenXrRuntime) -> Result<(), OpenXrRuntimeError> { runtime.run_quad_frame_loop(OpenXrQuadFrameLoopOptions::default(), || false) }
Source

pub fn run_ailloli_ui_render_vulkan_frame_loop( &mut self, options: OpenXrRenderVulkanFrameLoopOptions, scene_provider: impl FnMut() -> Scene, shutdown: impl FnMut() -> bool, ) -> Result<(), OpenXrRuntimeError>

Runs a quad loop that asks scene_provider for Ailloli Vulkan content.

The scene callback runs only on frames the runtime says should render. Image release is attempted after every render attempt, and render errors take precedence if release also fails.

§Errors

Returns session/frame, renderer, swapchain, render, release, or submission failures.

§Examples
use ailloli_ui_openxr::{OpenXrRenderVulkanFrameLoopOptions, OpenXrRuntime, OpenXrRuntimeError};
use ailloli_ui_runtime::Scene;
fn run(runtime: &mut OpenXrRuntime) -> Result<(), OpenXrRuntimeError> { runtime.run_ailloli_ui_render_vulkan_frame_loop(OpenXrRenderVulkanFrameLoopOptions::default(), Scene::default, || false) }
Source§

impl OpenXrRuntime

Source

pub fn run_ailloli_ui_frame_loop<A: 'static>( &mut self, options: OpenXrUiFrameLoopOptions, runtime_handle: RuntimeHandle<A>, root: impl IntoView<A>, shutdown: impl FnMut() -> bool, ) -> Result<(), OpenXrRuntimeError>

Runs the full Ailloli UI lifecycle in a quad composition layer.

Session focus controls input polling; focus/session transitions clear retained input. The shutdown callback is checked each iteration. Frames marked non-renderable submit no layer. Render release is always attempted, with render failure taking precedence over simultaneous release failure.

§Errors

Returns UI initialization, actions, session/frame, swapchain, rendering, release, or composition submission failures.

§Examples
use ailloli_ui_openxr::{OpenXrRuntime, OpenXrRuntimeError, OpenXrUiFrameLoopOptions};
use ailloli_ui_runtime::{app::RuntimeHandle, component::IntoView};
fn run<A: 'static>(runtime: &mut OpenXrRuntime, handle: RuntimeHandle<A>, root: impl IntoView<A>) -> Result<(), OpenXrRuntimeError> {
    runtime.run_ailloli_ui_frame_loop(OpenXrUiFrameLoopOptions::default(), handle, root, || false)
}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,