Struct openxr::Instance

source ·
pub struct Instance { /* private fields */ }
Expand description

Root object mediating an application’s interaction with OpenXR

Constructed from an Entry.

Implementations§

source§

impl Instance

source

pub unsafe fn from_raw( entry: Entry, handle: Instance, exts: InstanceExtensions ) -> Result<Self>

Take ownership of an existing instance handle

§Safety

handle must be the instance handle that was used to load exts.

source

pub fn as_raw(&self) -> Instance

source

pub fn entry(&self) -> &Entry

Access the entry points used to create self

source

pub fn fp(&self) -> &Instance

Access the core function pointers

source

pub fn exts(&self) -> &InstanceExtensions

Access the internal extension function pointers

source

pub fn set_name(&mut self, name: &str) -> Result<()>

Set the debug name of this Instance, if XR_EXT_debug_utils is loaded

source

pub fn properties(&self) -> Result<InstanceProperties>

source

pub fn result_to_string(&self, result: Result) -> Result<String>

source

pub fn structure_type_to_string(&self, ty: StructureType) -> Result<String>

source

pub fn system(&self, form_factor: FormFactor) -> Result<SystemId>

source

pub fn system_properties(&self, system: SystemId) -> Result<SystemProperties>

source

pub fn supports_hand_tracking(&self, system: SystemId) -> Result<bool>

source

pub fn string_to_path(&self, string: &str) -> Result<Path>

Construct a Path from a string

A Path should only be used with the instance that produced it.

source

pub fn path_to_string(&self, path: Path) -> Result<String>

source

pub unsafe fn create_vulkan_instance( &self, system: SystemId, get_instance_proc_addr: VkGetInstanceProcAddr, create_info: *const VkInstanceCreateInfo ) -> Result<Result<VkInstance, VkResult>>

Create a Vulkan instance suitable for use with a particular system

Instance::graphics_requirements::<Vulkan>() must be called first.

§Safety

See XR_KHR_vulkan_enable2.

source

pub fn vulkan_legacy_instance_extensions( &self, system: SystemId ) -> Result<String>

Identify the Vulkan instance extensions required by a system

Returns a space-delimited list of Vulkan instance extension names.

Note: This method requires the khr_vulkan_enable extension. Applications should use khr_vulkan_enable2 instead, if possible.

source

pub fn vulkan_legacy_device_extensions( &self, system: SystemId ) -> Result<String>

Identify the Vulkan device extensions required by a system

Returns a space-delimited list of Vulkan device extension names.

Note: This method requires the khr_vulkan_enable extension. Applications should use khr_vulkan_enable2 instead, if possible.

source

pub unsafe fn vulkan_graphics_device( &self, system: SystemId, vulkan_instance: VkInstance ) -> Result<VkPhysicalDevice>

Get a suitable VkPhysicalDevice for use with a particular system

When using ’khr_vulkan_enable2, call [Instance::create_vulkan_instance()] first to get a suitable VkInstance`.

§Safety

vulkan_instance must be a valid Vulkan instance, and must have been obtained from Instance::create_vulkan_instance() unless khr_vulkan_enable2 is not in use.

source

pub unsafe fn create_vulkan_device( &self, system: SystemId, get_instance_proc_addr: VkGetInstanceProcAddr, physical_device: VkPhysicalDevice, create_info: *const VkDeviceCreateInfo ) -> Result<Result<VkDevice, VkResult>>

Get a suitable VkDevice for use with a particular system

Call Instance::vulkan_graphics_device() first to get a suitable VkPhysicalDevice.

§Safety

See XR_KHR_vulkan_enable2.

source

pub fn graphics_requirements<G: Graphics>( &self, system: SystemId ) -> Result<G::Requirements>

Query graphics API version requirements

source

pub unsafe fn create_session<G: Graphics>( &self, system: SystemId, info: &G::SessionCreateInfo ) -> Result<(Session<G>, FrameWaiter, FrameStream<G>)>

Create a session for a particular graphics API

Returns three separate objects:

  • Session exposes most session-related operations and is cheap to clone
  • FrameWaiter allows blocking until it is time to begin graphics device work, and cannot be cloned
  • FrameStream allows callers to mark the beginning of graphics device work and submit completed frames for presentation

These objects are separate to ensure multithreaded pipelined renderers can safely wait for the cue to begin a new frame while a prior frame is still being rendered without additional synchronization.

§Safety

The requirements documented by the graphics API extension must be respected. Among other requirements, info must contain valid handles, and certain operations must be externally synchronized.

source

pub unsafe fn create_session_with_guard<G: Graphics>( &self, system: SystemId, info: &G::SessionCreateInfo, drop_guard: Box<dyn Any + Send + Sync> ) -> Result<(Session<G>, FrameWaiter, FrameStream<G>)>

Refer to Instance::create_session(). The extra drop_guard argument is dropped after the session is destroyed and this can be used to ensure safety.

§Safety

The requirements documented by the graphics API extension must be respected. Among other requirements, info must contain valid handles, and certain operations must be externally synchronized.

source

pub fn poll_event<'a>( &self, storage: &'a mut EventDataBuffer ) -> Result<Option<Event<'a>>>

Get the next event, if available

Returns immediately regardless of whether an event was available.

source

pub fn enumerate_view_configurations( &self, system: SystemId ) -> Result<Vec<ViewConfigurationType>>

Enumerates the supported view configuration types

source

pub fn view_configuration_properties( &self, system: SystemId, ty: ViewConfigurationType ) -> Result<ViewConfigurationProperties>

Query properties of an individual view configuration

source

pub fn enumerate_view_configuration_views( &self, system: SystemId, ty: ViewConfigurationType ) -> Result<Vec<ViewConfigurationView>>

source

pub fn enumerate_environment_blend_modes( &self, system: SystemId, view_configuration_type: ViewConfigurationType ) -> Result<Vec<EnvironmentBlendMode>>

source

pub fn now(&self) -> Result<Time>

Obtain the current Time

Requires KHR_convert_timespec_time. Most applications should use times from FrameStream::wait and Action::state instead.

source

pub fn suggest_interaction_profile_bindings( &self, interaction_profile: Path, bindings: &[Binding<'_>] ) -> Result<()>

Specify default bindings for a well-known input archetype

source

pub fn create_action_set( &self, name: &str, localized_name: &str, priority: u32 ) -> Result<ActionSet>

Allocate a new ActionSet

Trait Implementations§

source§

impl Clone for Instance

source§

fn clone(&self) -> Instance

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.