pub struct Instance { /* private fields */ }
Expand description
Root object mediating an application’s interaction with OpenXR
Constructed from an Entry
.
Implementations§
source§impl Instance
impl Instance
sourcepub unsafe fn from_raw(
entry: Entry,
handle: Instance,
exts: InstanceExtensions
) -> Result<Self>
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
.
pub fn as_raw(&self) -> Instance
sourcepub fn exts(&self) -> &InstanceExtensions
pub fn exts(&self) -> &InstanceExtensions
Access the internal extension function pointers
sourcepub fn set_name(&mut self, name: &str) -> Result<()>
pub fn set_name(&mut self, name: &str) -> Result<()>
Set the debug name of this Instance
, if XR_EXT_debug_utils
is loaded
pub fn properties(&self) -> Result<InstanceProperties>
pub fn result_to_string(&self, result: Result) -> Result<String>
pub fn structure_type_to_string(&self, ty: StructureType) -> Result<String>
pub fn system(&self, form_factor: FormFactor) -> Result<SystemId>
pub fn system_properties(&self, system: SystemId) -> Result<SystemProperties>
pub fn supports_hand_tracking(&self, system: SystemId) -> Result<bool>
sourcepub fn string_to_path(&self, string: &str) -> Result<Path>
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.
pub fn path_to_string(&self, path: Path) -> Result<String>
sourcepub unsafe fn create_vulkan_instance(
&self,
system: SystemId,
get_instance_proc_addr: VkGetInstanceProcAddr,
create_info: *const VkInstanceCreateInfo
) -> Result<Result<VkInstance, VkResult>>
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
sourcepub fn vulkan_legacy_instance_extensions(
&self,
system: SystemId
) -> Result<String>
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.
sourcepub fn vulkan_legacy_device_extensions(
&self,
system: SystemId
) -> Result<String>
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.
sourcepub unsafe fn vulkan_graphics_device(
&self,
system: SystemId,
vulkan_instance: VkInstance
) -> Result<VkPhysicalDevice>
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.
sourcepub unsafe fn create_vulkan_device(
&self,
system: SystemId,
get_instance_proc_addr: VkGetInstanceProcAddr,
physical_device: VkPhysicalDevice,
create_info: *const VkDeviceCreateInfo
) -> Result<Result<VkDevice, VkResult>>
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
sourcepub fn graphics_requirements<G: Graphics>(
&self,
system: SystemId
) -> Result<G::Requirements>
pub fn graphics_requirements<G: Graphics>( &self, system: SystemId ) -> Result<G::Requirements>
Query graphics API version requirements
sourcepub unsafe fn create_session<G: Graphics>(
&self,
system: SystemId,
info: &G::SessionCreateInfo
) -> Result<(Session<G>, FrameWaiter, FrameStream<G>)>
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 cloneFrameWaiter
allows blocking until it is time to begin graphics device work, and cannot be clonedFrameStream
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.
sourcepub 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>)>
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.
sourcepub fn poll_event<'a>(
&self,
storage: &'a mut EventDataBuffer
) -> Result<Option<Event<'a>>>
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.
sourcepub fn enumerate_view_configurations(
&self,
system: SystemId
) -> Result<Vec<ViewConfigurationType>>
pub fn enumerate_view_configurations( &self, system: SystemId ) -> Result<Vec<ViewConfigurationType>>
Enumerates the supported view configuration types
sourcepub fn view_configuration_properties(
&self,
system: SystemId,
ty: ViewConfigurationType
) -> Result<ViewConfigurationProperties>
pub fn view_configuration_properties( &self, system: SystemId, ty: ViewConfigurationType ) -> Result<ViewConfigurationProperties>
Query properties of an individual view configuration
pub fn enumerate_view_configuration_views( &self, system: SystemId, ty: ViewConfigurationType ) -> Result<Vec<ViewConfigurationView>>
pub fn enumerate_environment_blend_modes( &self, system: SystemId, view_configuration_type: ViewConfigurationType ) -> Result<Vec<EnvironmentBlendMode>>
sourcepub fn now(&self) -> Result<Time>
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.