|
evan 2026.1.4
Evan
|
The XrDeviceBackend class is responsible for managing the OpenXR device backend, including instance creation, session management, and frame processing. More...
#include <headers/evan/openxr/XrDeviceBackend.hpp>


Public Member Functions | |
| XrDeviceBackend (const IPlatform &platform) | |
| Constructs an XrDeviceBackend instance with the specified platform. | |
| Error | preprocessFrame (ASwapchainContext &swapchainContext) override |
| Prepares the current frame for rendering in an OpenXR session. | |
| Error | processFrame (VkPresentInfoKHR presentInfo, ASwapchainImage &swapchainImage) override |
| Processes a frame by releasing the OpenXR swapchain image. | |
| Error | postprocessFrame (ASwapchainContext &swapchainContext) override |
| Postprocesses a frame and submits it to the OpenXR compositor. | |
| QueueFamilyIndices | findQueueFamilies () override |
| Finds the queue family indices for graphics and presentation operations. | |
| uint32_t | countSwapchainFormats () const override |
| Count the number of available swapchain formats for the Vulkan device. | |
| std::vector< int64_t > | enumerateSwapchainFormats (uint32_t swapchainFormatCount) const override |
| Enumerates the available swapchain formats for the Vulkan device. | |
| std::vector< XrViewConfigurationView > | enumerateViewConfigurations () const |
| Enumerates the available view configurations for the OpenXR system. | |
| std::vector< std::shared_ptr< utility::event::Event > > | pollActions () |
| Polls input actions for the OpenXR session. | |
| XrSession | getSession () const |
| Retrieves the OpenXR session handle. | |
| XrViewConfigurationType | getViewConfigurationType () const |
| Retrieves the primary view configuration type selected for this OpenXR system. | |
| const OpenXrOptions & | getOpenXrOptions () const |
| Retrieves the user-configurable OpenXR options. | |
| std::vector< XrViewConfigurationType > | enumerateViewConfigurationTypes () const |
| Enumerates the primary view configuration types supported by the OpenXR system. | |
Public Member Functions inherited from evan::ADeviceBackend | |
| virtual | ~ADeviceBackend () |
| Virtual destructor for the ADeviceBackend class. | |
| Error | createBuffer (const CreateBufferProperties &properties) const |
| Creates a Vulkan buffer and allocates memory for it. | |
| Error | transitionImageLayout (const TransitionImageLayoutProperties &properties) const |
| Transitions the layout of a Vulkan image. | |
| VkCommandBuffer | beginSingleTimeCommands (VkCommandPool commandPool) const |
| Begins recording a single-use command buffer for one-time operations. | |
| void | endSingleTimeCommands (VkCommandPool commandPool, VkQueue graphicsQueue, VkCommandBuffer commandBuffer) const |
| Ends recording of a single-use command buffer and submits it for execution. | |
| Error | createImage (const CreateImageProperties &properties) const |
| Creates a Vulkan image and allocates memory for it. | |
| Error | copyBufferToImage (const CopyBufferToImageProperties &properties) const |
| Copies data from a Vulkan buffer to a Vulkan image. | |
| Error | copyBuffer (const CopyBufferProperties &properties) const |
| Copies data from one Vulkan buffer to another. | |
| Result< VkImageView > | createImageView (VkImage image, VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels, uint32_t layerCount=1) const |
| Creates a Vulkan image view for a given image. | |
| virtual VkDevice | getDevice () const |
| Retrieves the Vulkan logical device handle. | |
| virtual VkInstance | getInstance () const |
| Retrieves the Vulkan instance handle. | |
| virtual VkPhysicalDevice | getPhysicalDevice () const |
| Retrieves the Vulkan physical device handle. | |
| bool | supportsMultiview () const |
| Indicates whether multiview rendering is available. | |
| bool | supportsTimestampQueries () |
| Indicates whether GPU timestamp queries can be used. | |
| float | getTimestampPeriod () const |
| Nanoseconds per timestamp tick. | |
| uint32_t | getTimestampValidBits () |
| Number of valid bits in a timestamp value. | |
Static Public Member Functions | |
| static XrViewConfigurationType | selectViewConfigurationType (const std::vector< XrViewConfigurationType > &configurations) |
| Selects a primary view configuration type from the ones supported by the runtime. | |
Public Attributes | |
| XrInstance | _XrInstance = XR_NULL_HANDLE |
| XrSystemId | _systemId = XR_NULL_SYSTEM_ID |
| XrSession | _session = XR_NULL_HANDLE |
| XrSpace | _space = XR_NULL_HANDLE |
| std::unique_ptr< XrManageActions > | _actionManager |
| The action manager for handling input actions in the OpenXR session. | |
| bool | _sessionRunning = false |
| XrTime | _predictedDisplayTime = 0 |
| std::array< XrPath, _handCount > | _handActionSubactionPath |
Static Public Attributes | |
| static const size_t | _handCount = 2 |
Protected Member Functions | |
| void | createInstance (const IPlatform &platform, const std::string &appName, Version &appVersion) override |
| Creates an OpenXR instance with the specified application name and version. | |
| void | createLogicalDevice () override |
| Creates a logical device for the OpenXR session. | |
| void | pickPhysicalDevice () override |
| Picks a physical device that is compatible with the OpenXR session. | |
| void | createVisualizedSpace () |
| Creates a visualized space for the XR session. | |
| std::vector< VkExtensionProperties > | getInstanceExtensions () const |
Protected Member Functions inherited from evan::ADeviceBackend | |
| std::vector< VkLayerProperties > | getAvailableLayers () |
| Retrieves the available Vulkan layers on the system. | |
Additional Inherited Members | |
Static Protected Member Functions inherited from evan::ADeviceBackend | |
| static bool | queryMultiviewSupport (VkPhysicalDevice physicalDevice, uint32_t apiVersion) |
| Queries whether a physical device can run multiview passes. | |
Protected Attributes inherited from evan::ADeviceBackend | |
| VkPhysicalDevice | _physicalDevice = VK_NULL_HANDLE |
| VkDevice | _device = VK_NULL_HANDLE |
| VkInstance | _VkInstance = VK_NULL_HANDLE |
| bool | _multiviewSupported = false |
| Whether the multiview feature was enabled on the logical device created by this backend. | |
The XrDeviceBackend class is responsible for managing the OpenXR device backend, including instance creation, session management, and frame processing.
This class encapsulates the functionality required to interface with the OpenXR runtime, including creating an instance, picking a physical device, creating a logical device, and managing the rendering loop for XR applications. It also handles platform-specific configurations and extensions required for OpenXR on different platforms.
Definition at line 38 of file XrDeviceBackend.hpp.
Constructs an XrDeviceBackend instance with the specified platform.
Initializes the OpenXR instance and retrieves the system ID for the XR device. It also sets up the necessary resources for managing the XR session and rendering loop.
| platform | The platform interface providing required extensions and configurations for OpenXR instance creation. |
Definition at line 15 of file XrDeviceBackend.cpp.

|
override |
Definition at line 46 of file XrDeviceBackend.cpp.
|
overridevirtual |
Count the number of available swapchain formats for the Vulkan device.
This method queries the OpenXR runtime to determine how many swapchain formats are supported by the physical device. The count of swapchain formats is essential for creating a swapchain that is compatible with the device's capabilities.
Implements evan::ADeviceBackend.
Definition at line 207 of file XrDeviceBackend.cpp.
|
overrideprotectedvirtual |
Creates an OpenXR instance with the specified application name and version.
This method initializes the OpenXR instance by configuring the necessary parameters, including the application name and version. It also retrieves the required instance extensions from the platform and includes them in the instance creation process. The created instance is stored in the member variable _XrInstance for later use in managing the XR session and rendering.
| platform | The platform interface providing required extensions and configurations for OpenXR instance creation. |
| appName | The name of the application, used for identifying the application to the OpenXR runtime. |
| appVersion | The version of the application, used for identifying the application to the |
Implements evan::ADeviceBackend.
Definition at line 320 of file XrDeviceBackend.cpp.

|
overrideprotectedvirtual |
Creates a logical device for the OpenXR session.
This method sets up the necessary resources and configurations to create a logical device that can be used for rendering and interacting with the OpenXR session. It involves selecting appropriate queue families, configuring device features, and creating the logical device using the OpenXR runtime. The created logical device is essential for submitting rendering commands and managing resources within the XR environment.
Implements evan::ADeviceBackend.
Definition at line 429 of file XrDeviceBackend.cpp.

|
protected |
Creates a visualized space for the XR session.
This method sets up a reference space that can be used for rendering and tracking within the XR environment. It defines the coordinate system for the application and allows for accurate tracking of the XR device's position and orientation in the virtual space.
Definition at line 554 of file XrDeviceBackend.cpp.

|
overridevirtual |
Enumerates the available swapchain formats for the Vulkan device.
This method retrieves the list of supported swapchain formats from the OpenXR runtime. It takes the count of swapchain formats as a parameter and returns a vector of int64_t values representing the available formats. These formats are crucial for configuring the swapchain to ensure compatibility with the device's capabilities.
| swapchainFormatCount | The number of swapchain formats to enumerate, typically obtained from countSwapchainFormats(). |
Implements evan::ADeviceBackend.
Definition at line 214 of file XrDeviceBackend.cpp.
| std::vector< XrViewConfigurationView > evan::XrDeviceBackend::enumerateViewConfigurations | ( | ) | const |
Enumerates the available view configurations for the OpenXR system.
This method queries the OpenXR runtime to retrieve the list of supported view configurations for the XR system. It returns a vector of XrViewConfigurationView structures, each containing information about a specific view configuration, such as recommended image rect dimensions and swapchain sample counts. This information is essential for setting up the rendering pipeline to match the capabilities of the XR device.
Definition at line 227 of file XrDeviceBackend.cpp.
| std::vector< XrViewConfigurationType > evan::XrDeviceBackend::enumerateViewConfigurationTypes | ( | ) | const |
Enumerates the primary view configuration types supported by the OpenXR system.
Definition at line 251 of file XrDeviceBackend.cpp.

|
overridevirtual |
Finds the queue family indices for graphics and presentation operations.
This method queries the OpenXR runtime to determine the queue family indices that support graphics and presentation operations. It returns a QueueFamilyIndices structure containing the indices of the graphics and presentation queue families, if they are found. If the required queue families are not found, the corresponding optional values in the QueueFamilyIndices structure will be empty.
Implements evan::ADeviceBackend.
Definition at line 183 of file XrDeviceBackend.cpp.
|
protected |
Retrieves the list of Vulkan instance extensions available for the validation layer.
This function enumerates all instance extension properties supported by the VK_LAYER_KHRONOS_validation layer. It performs two queries: first to determine the number of available extensions, then to retrieve the full extension list.
Definition at line 581 of file XrDeviceBackend.cpp.
|
inline |
Retrieves the user-configurable OpenXR options.
These are copied from the platform when the backend is constructed.
Definition at line 263 of file XrDeviceBackend.hpp.
|
inline |
Retrieves the OpenXR session handle.
Definition at line 236 of file XrDeviceBackend.hpp.
|
inline |
Retrieves the primary view configuration type selected for this OpenXR system.
The value is chosen during construction by enumerating the view configurations supported by the runtime and preferring stereo over mono.
Definition at line 251 of file XrDeviceBackend.hpp.
|
overrideprotectedvirtual |
Picks a physical device that is compatible with the OpenXR session.
This method queries the OpenXR runtime to identify and select a physical device (e.g., GPU) that is compatible with the requirements of the XR session. It evaluates the available devices based on their capabilities, such as support for required features and extensions, and selects the most suitable device for rendering and interaction within the XR environment. The selected physical device is essential for creating a logical device and managing resources for the XR session.
Implements evan::ADeviceBackend.
Definition at line 518 of file XrDeviceBackend.cpp.

| std::vector< std::shared_ptr< utility::event::Event > > evan::XrDeviceBackend::pollActions | ( | ) |
Polls input actions for the OpenXR session.
This method is responsible for polling the input actions defined for the OpenXR session, including actions for the left and right hands. It interacts with the action manager to retrieve the current state of input actions and to handle any user interactions within the XR environment. Polling actions is essential for enabling responsive and interactive experiences in the XR application.
Definition at line 299 of file XrDeviceBackend.cpp.
|
overridevirtual |
Postprocesses a frame and submits it to the OpenXR compositor.
This method updates the projection layer views for the given swapchain context, constructs a composition layer with the updated views, and submits the frame to the OpenXR runtime via xrEndFrame().
| swapchainContext | Reference to the swapchain context to postprocess. Must be a valid evan::XrSwapchainContext instance. |
Implements evan::ADeviceBackend.
Definition at line 153 of file XrDeviceBackend.cpp.
|
overridevirtual |
Prepares the current frame for rendering in an OpenXR session.
This method performs frame synchronization and view localization for OpenXR rendering. It waits for the next frame, begins frame processing, and retrieves the current view configurations. If the runtime indicates rendering should be skipped, the frame is properly concluded without processing.
| [in,out] | swapchainContext | Reference to the swapchain context that will be populated with view information for rendering. |
The method performs the following operations:
Implements evan::ADeviceBackend.
Definition at line 76 of file XrDeviceBackend.cpp.
|
overridevirtual |
Processes a frame by releasing the OpenXR swapchain image.
This function releases the swapchain image associated with the given presentation information back to the OpenXR runtime for reuse.
| presentInfo | The Vulkan present information for the frame (currently unused). |
| swapchainImage | Reference to the swapchain image to be released. Must be castable to evan::XrSwapchainImage. |
Implements evan::ADeviceBackend.
Definition at line 133 of file XrDeviceBackend.cpp.
|
static |
Selects a primary view configuration type from the ones supported by the runtime.
Prefers XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO, then XR_VIEW_CONFIGURATION_TYPE_PRIMARY_MONO, then the first entry. If no configuration is provided, PRIMARY_MONO is returned as a safe fallback.
| configurations | The view configuration types enumerated from the OpenXR system. |
Definition at line 279 of file XrDeviceBackend.cpp.

| std::unique_ptr<XrManageActions> evan::XrDeviceBackend::_actionManager |
The action manager for handling input actions in the OpenXR session.
This member variable is responsible for managing the input actions defined for the OpenXR session, including actions for the left and right hands. It encapsulates the functionality required to create and manage action sets, as well as to handle input from various input sources such as controllers and hand tracking. The action manager is essential for enabling interactive experiences in the XR environment by allowing the application to respond to user input in a flexible and extensible manner.
Definition at line 343 of file XrDeviceBackend.hpp.
| std::array<XrPath, _handCount> evan::XrDeviceBackend::_handActionSubactionPath |
Subaction paths for hand input actions, used to differentiate between left and right hand actions in the OpenXR session. These paths are used when polling input actions to determine which hand is associated with a particular action state, allowing for accurate handling of user input from both hands in the XR environment.
Definition at line 378 of file XrDeviceBackend.hpp.
The count of view configurations available for the XR system, which indicates how many different ways the application can render content based on the capabilities of the XR device. This count is used to manage rendering for multiple views, such as for stereo rendering in VR applications.
Definition at line 369 of file XrDeviceBackend.hpp.
| XrTime evan::XrDeviceBackend::_predictedDisplayTime = 0 |
The predicted display time for the next frame, used for synchronizing rendering with the XR device's display refresh cycle. It is updated each frame to ensure smooth and responsive rendering in the XR environment.
Definition at line 360 of file XrDeviceBackend.hpp.
| XrSession evan::XrDeviceBackend::_session = XR_NULL_HANDLE |
The OpenXR session, which represents an active connection to the XR system. It is used to manage the lifecycle of the XR experience and to submit rendering commands for display on the XR device.
Definition at line 319 of file XrDeviceBackend.hpp.
Flag to track if the session is currently running.
This is used to determine if the application should continue running or if it should exit based on the session state changes received from the OpenXR runtime.
Definition at line 352 of file XrDeviceBackend.hpp.
| XrSpace evan::XrDeviceBackend::_space = XR_NULL_HANDLE |
The OpenXR space, which defines a coordinate system for the application. It is used to track the position and orientation of the XR device and to render content in the correct location within the XR environment.
Definition at line 328 of file XrDeviceBackend.hpp.
| XrSystemId evan::XrDeviceBackend::_systemId = XR_NULL_SYSTEM_ID |
The OpenXR system ID, which represents the specific XR system (e.g., VR headset) that the application is targeting. It is used to query the capabilities of the XR system and to create sessions for rendering.
Definition at line 311 of file XrDeviceBackend.hpp.
| XrInstance evan::XrDeviceBackend::_XrInstance = XR_NULL_HANDLE |
The OpenXR instance, which represents the connection between the application and the OpenXR runtime. It is used to create and manage OpenXR resources and to query the capabilities of the OpenXR implementation.
Definition at line 302 of file XrDeviceBackend.hpp.