|
Vulkan Schnee 0.0.1
High-performance rendering engine
|
#include <Headset.h>
Classes | |
| struct | Eye |
| struct | ImageBuffer |
| struct | WaitFrameResult |
| Result from waitForXrFrame indicating what the main loop should do. More... | |
Public Types | |
| enum class | BeginFrameResult { Error , RenderFully , SkipRender , SkipFully , ComputeOnly } |
Public Member Functions | |
| Headset (const Core::ApplicationContext *context=nullptr) | |
| ~Headset () | |
| void | cleanup () |
| void | updateViewMatrix () |
| Updates the eye matrix for the headset. | |
| 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) |
| Combines waitForXrFrame and beginXrFrameAfterWait. | |
| void | endXrFrame () |
| void | endXrFrameNoRender () |
| void | beginXrSession () const |
| VkImage | getSwapchainImage (size_t swapchainImageIndex) const |
| Getter. | |
| std::vector< RenderTarget > | getSwapchainRenderTargets () |
| void | endXrSession () const |
| Ends the XR 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 |
| Getter. | |
| VkExtent2D | getEyeResolution (size_t eyeIndex) const |
| Gets eye resolution in x and y for a specified eye index. 0 is left. | |
| VkRenderPass | getRenderPass () const |
| Getter. | |
| glm::mat4 | getEyeViewMatrix (size_t eyeIndex) const |
| Returns the view matrix of the specified eye. | |
| glm::mat4 | getRawEyeViewMatrix (size_t eyeIndex) const |
| Gets the raw eye view matrix without player position offset. | |
| void | setPlayerPosition (const glm::vec3 &position) |
| Setter. | |
| glm::vec3 | getPlayerPosition () const |
| Getter. | |
| void | setPlayerRotation (const glm::quat &rotation) |
| Setter for the player/play-space rotation applied around the world origin. | |
| glm::quat | getPlayerRotation () const |
| Getter for 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 multiplied view and projection matrix. | |
| XrSpace | getReferenceSpace () const |
| Getter. | |
| XrSession | getSession () const |
| Getter. | |
| bool | getIsExitRequested () const |
| Returns true if the headset has requested the application to exit. | |
| XrFrameState | getXrFrameState () const |
| Getter. | |
| const RenderTarget * | getRenderTarget (size_t swapchainImageIndex) const |
| Getter. | |
| VkImage | getDepthBufferImage () const |
| Getter. | |
| VkImageView | getDepthBufferView () const |
| Getter. | |
| VkImage | getColorBufferImage () const |
| Getter. | |
| VkImageView | getColorBufferView () const |
| Getter. | |
| VkImage | getResolveBufferImage () const |
| Getter. | |
| VkImageView | getResolveBufferView () const |
| Getter. | |
| VkFormat | getColorFormat () const |
| Getter. | |
| VkFormat | getSceneColorFormat () const |
Private Attributes | |
| XrViewState | xrViewState = {} |
| XrFrameState | xrFrameState = {} |
| XrSessionState | xrSessionState = XR_SESSION_STATE_UNKNOWN |
| bool | isExistRequested = false |
| const Core::ApplicationContext * | context = nullptr |
| VkRenderPass | vkRenderPass = VK_NULL_HANDLE |
| The vulkan render pass. | |
| XrSession | xrSession = XR_NULL_HANDLE |
| The xr session. | |
| XrSpace | xrReferenceSpace = XR_NULL_HANDLE |
| The xr reference space. | |
| XrReferenceSpaceType | xrReferenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL |
| Type of the xr reference space, if it is room scale or just sitting vr. | |
| uint32_t | eyeCount = 0u |
| std::vector< XrViewConfigurationView > | eyeImageInfos |
| std::vector< XrView > | eyePoses |
| ImageBuffer | colorBuffer |
| ImageBuffer | depthBuffer |
| ImageBuffer | resolveBuffer |
| XrSwapchain | xrSwapchain = nullptr |
| std::unique_ptr< NamedThreadPool > | xrWaitThreadPool_ |
| std::vector< RenderTarget > | swapchainRenderTargets |
| The swapchain render targets. The images get rendered onto those render targets. | |
| std::vector< XrCompositionLayerProjectionView > | eyeRenderInfos |
| std::vector< Eye > | eyes = {} |
| XrTime | lastUpdateTime = 0 |
| glm::vec3 | playerPosition_ { 0.0f, 0.0f, 0.0f } |
| glm::quat | playerRotation_ { 1.0f, 0.0f, 0.0f, 0.0f } |
| VkFormat | colorFormat_ = VK_FORMAT_R8G8B8A8_UNORM |
| VkFormat | sceneColorFormat_ = VK_FORMAT_R16G16B16A16_SFLOAT |
|
strong |
| Engine::Rendering::Headset::Headset | ( | const Core::ApplicationContext * | context = nullptr | ) |
References context.
| Engine::Rendering::Headset::~Headset | ( | ) |
| BeginFrameResult Engine::Rendering::Headset::beginXrFrame | ( | uint32_t & | swapchainImageIndex, |
| Renderer * | renderer ) |
Combines waitForXrFrame and beginXrFrameAfterWait.
| 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 |
| void Engine::Rendering::Headset::cleanup | ( | ) |
| void Engine::Rendering::Headset::endXrFrame | ( | ) |
| void Engine::Rendering::Headset::endXrFrameNoRender | ( | ) |
| void Engine::Rendering::Headset::endXrSession | ( | ) | const |
Ends the XR session.
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
|
nodiscard |
Getter.
|
nodiscard |
Gets the projection matrix for an eye.
| eyeIndex | left or right eye (0, 1) |
|
nodiscard |
Gets eye resolution in x and y for a specified eye index. 0 is left.
| eyeIndex | Zero-based index of the eye |
|
nodiscard |
Returns the view matrix of the specified eye.
| eyeIndex | left and right eye |
|
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 true if the headset has requested the application to exit.
|
inlinenodiscard |
|
inlinenodiscard |
Getter for the player/play-space rotation.
Definition at line 163 of file Headset.h.
References playerRotation_.
|
nodiscard |
Gets the raw eye view matrix without player position offset.
|
nodiscard |
Getter.
|
nodiscard |
Getter.
| const RenderTarget * Engine::Rendering::Headset::getRenderTarget | ( | size_t | swapchainImageIndex | ) | const |
Getter.
|
inlinenodiscard |
|
inlinenodiscard |
|
inlinenodiscard |
Definition at line 367 of file Headset.h.
References sceneColorFormat_.
|
nodiscard |
Getter.
|
nodiscard |
Getter.
| std::vector< RenderTarget > Engine::Rendering::Headset::getSwapchainRenderTargets | ( | ) |
|
nodiscard |
Gets the multiplied view and projection matrix.
| eyeIndex | The frame index |
|
nodiscard |
Getter.
| 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.
|
inline |
| void Engine::Rendering::Headset::setPlayerRotation | ( | const glm::quat & | rotation | ) |
Setter for the player/play-space rotation applied around the world origin.
|
nodiscard |
Converts an OpenXR play-space orientation into world space.
|
nodiscard |
Converts an OpenXR play-space position into world space.
| void Engine::Rendering::Headset::updateViewMatrix | ( | ) |
Updates the eye matrix for the headset.
| 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 | Pointer to renderer (used for Tracy context reset on state transitions) |
|
private |
Definition at line 274 of file Headset.h.
Referenced by getColorBufferImage(), and getColorBufferView().
|
private |
Definition at line 373 of file Headset.h.
Referenced by getColorFormat().
|
private |
Definition at line 238 of file Headset.h.
Referenced by Engine::Rendering::Headset::ImageBuffer::cleanup(), and Headset().
|
private |
Definition at line 275 of file Headset.h.
Referenced by getDepthBufferImage(), and getDepthBufferView().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
Definition at line 302 of file Headset.h.
Referenced by getPlayerPosition(), and setPlayerPosition().
|
private |
Definition at line 303 of file Headset.h.
Referenced by getPlayerRotation().
|
private |
Definition at line 276 of file Headset.h.
Referenced by getResolveBufferImage(), and getResolveBufferView().
|
private |
Definition at line 374 of file Headset.h.
Referenced by getSceneColorFormat().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |