|
Vulkan Schnee 0.0.1 (22840dc8)
High-performance rendering engine
|
Owns the OpenXR session, XR swapchain, eye transforms, and per-frame XR submission state. More...
#include <Headset.h>
Classes | |
| struct | Eye |
| Cached matrices for one eye. More... | |
| struct | ImageBuffer |
| Engine-owned Vulkan image, memory, and view tuple. More... | |
| struct | WaitFrameResult |
| Result from waitForXrFrame() indicating how the main loop should continue. More... | |
Public Types | |
| enum class | BeginFrameResult { Error , RenderFully , SkipRender , SkipFully , ComputeOnly } |
| Frame-begin outcome returned by XR frame lifecycle functions. More... | |
Public Member Functions | |
| Headset (const Core::ApplicationContext *context=nullptr) | |
| Creates OpenXR session, reference space, render pass, images, swapchain, and eye state. | |
| ~Headset () | |
| Does not release GPU or OpenXR resources; call cleanup() before destruction. | |
| void | cleanup () |
| Releases owned Vulkan image buffers, swapchain render targets, render pass, reference space, and session. | |
| void | updateViewMatrix () |
| Updates cached eye view and projection matrices from the latest OpenXR eye poses. | |
| WaitFrameResult | waitForXrFrame (Rendering::Renderer *renderer) |
| First part of frame setup: calls xrWaitFrame. Can be called before previous xrEndFrame completes. Polls events and waits for the next frame to be ready. | |
| BeginFrameResult | beginXrFrameAfterWait (uint32_t &swapchainImageIndex) |
| Second part of frame setup: calls xrBeginFrame, acquires swapchain image. MUST be called after previous frame's xrEndFrame has completed. | |
| BeginFrameResult | beginXrFrame (uint32_t &swapchainImageIndex, Renderer *renderer) |
| Runs waitForXrFrame() and beginXrFrameAfterWait() as a single legacy call. | |
| void | endXrFrame () |
| Releases the acquired swapchain image and submits projection layers to xrEndFrame(). | |
| void | endXrFrameNoRender () |
| Ends an OpenXR frame without releasing a swapchain image or submitting projection layers. | |
| void | beginXrSession () const |
| Begins the OpenXR session for the configured primary view type. | |
| void | setSessionStateCallback (std::function< void(XrSessionState)> callback) |
| Registers a callback invoked whenever the OpenXR session state changes. | |
| void | setInteractionProfileChangedCallback (std::function< void()> callback) |
| Registers a callback invoked when the runtime reports an interaction profile change. | |
| VkImage | getSwapchainImage (size_t swapchainImageIndex) const |
| Returns a borrowed OpenXR swapchain image handle. | |
| std::vector< RenderTarget > | getSwapchainRenderTargets () |
| Returns a copy of the swapchain render-target list. | |
| void | endXrSession () const |
| Ends the active OpenXR session. | |
| void | requestExitSession () |
| Requests the XR runtime to exit the session gracefully. This should be called when the application wants to shut down (e.g., window close). The XR runtime will transition through proper states before exiting. | |
| uint32_t | getEyeCount () const |
| Returns the number of configured XR views. | |
| VkExtent2D | getEyeResolution (size_t eyeIndex) const |
| Returns the recommended render resolution for an eye. | |
| VkRenderPass | getRenderPass () const |
| Returns the legacy multiview render pass. | |
| glm::mat4 | getEyeViewMatrix (size_t eyeIndex) const |
| Returns the world-adjusted view matrix for an eye. | |
| glm::mat4 | getRawEyeViewMatrix (size_t eyeIndex) const |
| Returns the raw OpenXR view matrix for an eye. | |
| void | setPlayerPosition (const glm::vec3 &position) |
| Sets the player/play-space world position. | |
| glm::vec3 | getPlayerPosition () const |
| Returns the current player/play-space world position. | |
| void | setPlayerRotation (const glm::quat &rotation) |
| Setter for the player/play-space rotation applied around the world origin. | |
| glm::quat | getPlayerRotation () const |
| Returns the player/play-space rotation. | |
| glm::vec3 | transformPlaySpacePosition (const glm::vec3 &position) const |
| Converts an OpenXR play-space position into world space. | |
| glm::quat | transformPlaySpaceOrientation (const glm::quat &orientation) const |
| Converts an OpenXR play-space orientation into world space. | |
| glm::vec3 | getHeadsetLocalPosition () const |
| Gets the headset's local position relative to the play space origin. | |
| glm::quat | getHeadsetLocalOrientation () const |
| Gets the headset's local orientation relative to the play space. | |
| glm::vec3 | getHeadsetWorldPosition () const |
| Gets the headset position after player position/rotation are applied. | |
| glm::quat | getHeadsetWorldOrientation () const |
| Gets the headset orientation after player rotation is applied. | |
| glm::mat4 | getEyeProjectionMatrix (size_t eyeIndex) const |
| Gets the projection matrix for an eye. | |
| glm::mat4 | getViewProjectionMatrix (size_t eyeIndex) const |
| Gets the projection-view matrix for an eye. | |
| XrSpace | getReferenceSpace () const |
| Returns the OpenXR reference space used for view location and layer submission. | |
| XrSession | getSession () const |
| Returns the OpenXR session handle. | |
| bool | getIsExitRequested () const |
| Returns whether OpenXR requested application exit or session shutdown. | |
| XrFrameState | getXrFrameState () const |
| Returns the latest OpenXR frame state. | |
| const RenderTarget * | getRenderTarget (size_t swapchainImageIndex) const |
| Returns the render target for a swapchain image. | |
| VkImage | getDepthBufferImage () const |
| Returns the depth image used by headset rendering. | |
| VkImageView | getDepthBufferView () const |
| Returns the depth image view used by headset rendering. | |
| VkImage | getColorBufferImage () const |
| Returns the multisampled color image used by headset rendering. | |
| VkImageView | getColorBufferView () const |
| Returns the multisampled color image view used by headset rendering. | |
| VkImage | getResolveBufferImage () const |
| Returns the single-sample resolve image used before XR swapchain tonemapping. | |
| VkImageView | getResolveBufferView () const |
| Returns the single-sample resolve image view used before XR swapchain tonemapping. | |
| VkFormat | getColorFormat () const |
| Returns the format used by XR swapchain color attachment views. | |
| VkFormat | getSceneColorFormat () const |
| Returns the HDR scene color format used for engine-owned color and resolve buffers. | |
Private Attributes | |
| XrViewState | xrViewState = {} |
| Validity flags for the latest xrLocateViews() result. | |
| XrFrameState | xrFrameState = {} |
| State returned by the latest xrWaitFrame() call. | |
| XrSessionState | xrSessionState = XR_SESSION_STATE_UNKNOWN |
| Current OpenXR session lifecycle state. | |
| bool | isExistRequested = false |
| True once OpenXR or the application requests session exit. | |
| const Core::ApplicationContext * | context = nullptr |
| Application context that owns Vulkan and OpenXR handles. | |
| VkRenderPass | vkRenderPass = VK_NULL_HANDLE |
| Legacy multiview render pass used by framebuffer rendering. | |
| XrSession | xrSession = XR_NULL_HANDLE |
| OpenXR session created for the application context's system id. | |
| XrSpace | xrReferenceSpace = XR_NULL_HANDLE |
| Reference space used to locate views and submit layers. | |
| XrReferenceSpaceType | xrReferenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL |
| Configured reference-space type. | |
| uint32_t | eyeCount = 0u |
| Number of views reported by the OpenXR runtime. | |
| std::vector< XrViewConfigurationView > | eyeImageInfos |
| Runtime-recommended image settings per eye. | |
| std::vector< XrView > | eyePoses |
| Eye poses and fields of view from the latest xrLocateViews() call. | |
| ImageBuffer | colorBuffer |
| Multisampled HDR color attachment for multiview rendering. | |
| ImageBuffer | depthBuffer |
| Multisampled depth attachment, also sampled by Hi-Z generation. | |
| ImageBuffer | resolveBuffer |
| Single-sample HDR resolve target before tonemapping to the XR swapchain. | |
| XrSwapchain | xrSwapchain = nullptr |
| OpenXR color swapchain submitted to the runtime. | |
| std::unique_ptr< NamedThreadPool > | xrWaitThreadPool_ |
| Thread pool used to timeout xrWaitFrame() safely. | |
| std::function< void(XrSessionState)> | sessionStateCallback_ |
| Invoked on OpenXR session state changes. | |
| std::function< void()> | interactionProfileChangedCallback_ |
| Invoked on OpenXR interaction profile changes. | |
| std::vector< RenderTarget > | swapchainRenderTargets |
| Render target wrappers for OpenXR swapchain images. | |
| std::vector< XrCompositionLayerProjectionView > | eyeRenderInfos |
| Projection-layer views submitted to xrEndFrame(). | |
| std::vector< Eye > | eyes = {} |
| Cached eye matrices indexed by zero-based eye index. | |
| XrTime | lastUpdateTime = 0 |
| Reserved timestamp for future pose update tracking. | |
| glm::vec3 | playerPosition_ { 0.0f, 0.0f, 0.0f } |
| World-space player/play-space offset. | |
| glm::quat | playerRotation_ { 1.0f, 0.0f, 0.0f, 0.0f } |
| World-space player/play-space rotation. | |
| VkFormat | swapchainFormat_ = VK_FORMAT_R8G8B8A8_UNORM |
| VkFormat used when creating the OpenXR swapchain. | |
| VkFormat | colorFormat_ = VK_FORMAT_R8G8B8A8_UNORM |
| VkFormat used for OpenXR swapchain image views. | |
| VkFormat | sceneColorFormat_ = VK_FORMAT_R16G16B16A16_SFLOAT |
| HDR format for engine-owned scene buffers. | |
| bool | useMutableSwapchainFormat_ = false |
| True when swapchain views use a different color format. | |
Owns the OpenXR session, XR swapchain, eye transforms, and per-frame XR submission state.
Headset creates the OpenXR session from an initialized ApplicationContext, allocates multiview color, depth, resolve, and swapchain views, and exposes frame lifecycle calls used by the renderer.
|
strong |
Frame-begin outcome returned by XR frame lifecycle functions.
| Engine::Rendering::Headset::Headset | ( | const Core::ApplicationContext * | context = nullptr | ) |
Creates OpenXR session, reference space, render pass, images, swapchain, and eye state.
| context | Initialized application context with Vulkan and OpenXR handles. |
References context.
| Engine::Rendering::Headset::~Headset | ( | ) |
Does not release GPU or OpenXR resources; call cleanup() before destruction.
| BeginFrameResult Engine::Rendering::Headset::beginXrFrame | ( | uint32_t & | swapchainImageIndex, |
| Renderer * | renderer ) |
Runs waitForXrFrame() and beginXrFrameAfterWait() as a single legacy call.
| swapchainImageIndex | Receives the acquired swapchain image index when rendering proceeds. |
| renderer | Renderer used for state-transition handling. |
| BeginFrameResult Engine::Rendering::Headset::beginXrFrameAfterWait | ( | uint32_t & | swapchainImageIndex | ) |
Second part of frame setup: calls xrBeginFrame, acquires swapchain image. MUST be called after previous frame's xrEndFrame has completed.
| swapchainImageIndex | Output parameter for the acquired swapchain image index |
| void Engine::Rendering::Headset::beginXrSession | ( | ) | const |
Begins the OpenXR session for the configured primary view type.
| void Engine::Rendering::Headset::cleanup | ( | ) |
Releases owned Vulkan image buffers, swapchain render targets, render pass, reference space, and session.
| void Engine::Rendering::Headset::endXrFrame | ( | ) |
Releases the acquired swapchain image and submits projection layers to xrEndFrame().
| void Engine::Rendering::Headset::endXrFrameNoRender | ( | ) |
Ends an OpenXR frame without releasing a swapchain image or submitting projection layers.
| void Engine::Rendering::Headset::endXrSession | ( | ) | const |
Ends the active OpenXR session.
|
inlinenodiscard |
Returns the multisampled color image used by headset rendering.
Definition at line 421 of file Headset.h.
References colorBuffer.
|
inlinenodiscard |
Returns the multisampled color image view used by headset rendering.
Definition at line 430 of file Headset.h.
References colorBuffer.
|
inlinenodiscard |
Returns the format used by XR swapchain color attachment views.
Definition at line 457 of file Headset.h.
References colorFormat_.
|
inlinenodiscard |
Returns the depth image used by headset rendering.
Definition at line 403 of file Headset.h.
References depthBuffer.
|
inlinenodiscard |
Returns the depth image view used by headset rendering.
Definition at line 412 of file Headset.h.
References depthBuffer.
|
nodiscard |
Returns the number of configured XR views.
|
nodiscard |
Gets the projection matrix for an eye.
| eyeIndex | Zero-based eye index. |
|
nodiscard |
Returns the recommended render resolution for an eye.
| eyeIndex | Zero-based eye index; 0 is the left eye for stereo views. |
|
nodiscard |
Returns the world-adjusted view matrix for an eye.
| eyeIndex | Zero-based eye index. |
|
nodiscard |
Gets the headset's local orientation relative to the play space.
|
nodiscard |
Gets the headset's local position relative to the play space origin.
|
nodiscard |
Gets the headset orientation after player rotation is applied.
|
nodiscard |
Gets the headset position after player position/rotation are applied.
|
nodiscard |
Returns whether OpenXR requested application exit or session shutdown.
|
inlinenodiscard |
Returns the current player/play-space world position.
Definition at line 224 of file Headset.h.
References playerPosition_.
|
inlinenodiscard |
Returns the player/play-space rotation.
Definition at line 239 of file Headset.h.
References playerRotation_.
|
nodiscard |
Returns the raw OpenXR view matrix for an eye.
| eyeIndex | Zero-based eye index. |
|
nodiscard |
Returns the OpenXR reference space used for view location and layer submission.
|
nodiscard |
Returns the legacy multiview render pass.
| const RenderTarget * Engine::Rendering::Headset::getRenderTarget | ( | size_t | swapchainImageIndex | ) | const |
Returns the render target for a swapchain image.
| swapchainImageIndex | Swapchain image index returned by beginXrFrameAfterWait(). |
|
inlinenodiscard |
Returns the single-sample resolve image used before XR swapchain tonemapping.
Definition at line 439 of file Headset.h.
References resolveBuffer.
|
inlinenodiscard |
Returns the single-sample resolve image view used before XR swapchain tonemapping.
Definition at line 448 of file Headset.h.
References resolveBuffer.
|
inlinenodiscard |
Returns the HDR scene color format used for engine-owned color and resolve buffers.
Definition at line 466 of file Headset.h.
References sceneColorFormat_.
|
nodiscard |
Returns the OpenXR session handle.
|
nodiscard |
Returns a borrowed OpenXR swapchain image handle.
| swapchainImageIndex | Swapchain image index returned by beginXrFrameAfterWait(). |
| std::vector< RenderTarget > Engine::Rendering::Headset::getSwapchainRenderTargets | ( | ) |
Returns a copy of the swapchain render-target list.
|
nodiscard |
Gets the projection-view matrix for an eye.
| eyeIndex | Zero-based eye index. |
|
nodiscard |
Returns the latest OpenXR frame state.
| void Engine::Rendering::Headset::requestExitSession | ( | ) |
Requests the XR runtime to exit the session gracefully. This should be called when the application wants to shut down (e.g., window close). The XR runtime will transition through proper states before exiting.
| void Engine::Rendering::Headset::setInteractionProfileChangedCallback | ( | std::function< void()> | callback | ) |
Registers a callback invoked when the runtime reports an interaction profile change.
| callback | Callback invoked without arguments on XR_TYPE_EVENT_DATA_INTERACTION_PROFILE_CHANGED. |
|
inline |
Sets the player/play-space world position.
| position | World-space offset applied to eye and headset transforms. |
Definition at line 215 of file Headset.h.
References playerPosition_.
| void Engine::Rendering::Headset::setPlayerRotation | ( | const glm::quat & | rotation | ) |
Setter for the player/play-space rotation applied around the world origin.
| rotation | Rotation applied to eye and headset transforms; normalized before storage. |
| void Engine::Rendering::Headset::setSessionStateCallback | ( | std::function< void(XrSessionState)> | callback | ) |
Registers a callback invoked whenever the OpenXR session state changes.
| callback | Callback receiving the new session state. |
|
nodiscard |
Converts an OpenXR play-space orientation into world space.
| orientation | Orientation in OpenXR reference-space coordinates. |
|
nodiscard |
Converts an OpenXR play-space position into world space.
| position | Position in OpenXR reference-space coordinates. |
| void Engine::Rendering::Headset::updateViewMatrix | ( | ) |
Updates cached eye view and projection matrices from the latest OpenXR eye poses.
| WaitFrameResult Engine::Rendering::Headset::waitForXrFrame | ( | Rendering::Renderer * | renderer | ) |
First part of frame setup: calls xrWaitFrame. Can be called before previous xrEndFrame completes. Polls events and waits for the next frame to be ready.
| renderer | Renderer associated with the frame loop; reserved for state-transition handling. |
|
private |
Multisampled HDR color attachment for multiview rendering.
Definition at line 359 of file Headset.h.
Referenced by getColorBufferImage(), and getColorBufferView().
|
private |
VkFormat used for OpenXR swapchain image views.
Definition at line 473 of file Headset.h.
Referenced by getColorFormat().
|
private |
Application context that owns Vulkan and OpenXR handles.
Definition at line 328 of file Headset.h.
Referenced by Engine::Rendering::Headset::ImageBuffer::cleanup(), and Headset().
|
private |
Multisampled depth attachment, also sampled by Hi-Z generation.
Definition at line 360 of file Headset.h.
Referenced by getDepthBufferImage(), and getDepthBufferView().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
World-space player/play-space offset.
Definition at line 388 of file Headset.h.
Referenced by getPlayerPosition(), and setPlayerPosition().
|
private |
World-space player/play-space rotation.
Definition at line 389 of file Headset.h.
Referenced by getPlayerRotation().
|
private |
Single-sample HDR resolve target before tonemapping to the XR swapchain.
Definition at line 361 of file Headset.h.
Referenced by getResolveBufferImage(), and getResolveBufferView().
|
private |
HDR format for engine-owned scene buffers.
Definition at line 474 of file Headset.h.
Referenced by getSceneColorFormat().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |