Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Rendering::Headset Class Reference

#include <Headset.h>

Collaboration diagram for Engine::Rendering::Headset:

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< RenderTargetgetSwapchainRenderTargets ()
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 RenderTargetgetRenderTarget (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::ApplicationContextcontext = 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< NamedThreadPoolxrWaitThreadPool_
std::vector< RenderTargetswapchainRenderTargets
 The swapchain render targets. The images get rendered onto those render targets.
std::vector< XrCompositionLayerProjectionView > eyeRenderInfos
std::vector< Eyeeyes = {}
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

Detailed Description

Definition at line 35 of file Headset.h.

Member Enumeration Documentation

◆ BeginFrameResult

Enumerator
Error 
RenderFully 
SkipRender 
SkipFully 
ComputeOnly 

Definition at line 43 of file Headset.h.

Constructor & Destructor Documentation

◆ Headset()

Engine::Rendering::Headset::Headset ( const Core::ApplicationContext * context = nullptr)

References context.

◆ ~Headset()

Engine::Rendering::Headset::~Headset ( )

Member Function Documentation

◆ beginXrFrame()

BeginFrameResult Engine::Rendering::Headset::beginXrFrame ( uint32_t & swapchainImageIndex,
Renderer * renderer )

Combines waitForXrFrame and beginXrFrameAfterWait.

◆ 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.

Parameters
swapchainImageIndexOutput parameter for the acquired swapchain image index
Returns
BeginFrameResult indicating rendering status

◆ beginXrSession()

void Engine::Rendering::Headset::beginXrSession ( ) const

◆ cleanup()

void Engine::Rendering::Headset::cleanup ( )

◆ endXrFrame()

void Engine::Rendering::Headset::endXrFrame ( )

◆ endXrFrameNoRender()

void Engine::Rendering::Headset::endXrFrameNoRender ( )

◆ endXrSession()

void Engine::Rendering::Headset::endXrSession ( ) const

Ends the XR session.

◆ getColorBufferImage()

VkImage Engine::Rendering::Headset::getColorBufferImage ( ) const
inlinenodiscard

Getter.

Definition at line 330 of file Headset.h.

References colorBuffer.

◆ getColorBufferView()

VkImageView Engine::Rendering::Headset::getColorBufferView ( ) const
inlinenodiscard

Getter.

Definition at line 338 of file Headset.h.

References colorBuffer.

◆ getColorFormat()

VkFormat Engine::Rendering::Headset::getColorFormat ( ) const
inlinenodiscard

Getter.

Definition at line 362 of file Headset.h.

References colorFormat_.

◆ getDepthBufferImage()

VkImage Engine::Rendering::Headset::getDepthBufferImage ( ) const
inlinenodiscard

Getter.

Definition at line 314 of file Headset.h.

References depthBuffer.

◆ getDepthBufferView()

VkImageView Engine::Rendering::Headset::getDepthBufferView ( ) const
inlinenodiscard

Getter.

Definition at line 322 of file Headset.h.

References depthBuffer.

◆ getEyeCount()

uint32_t Engine::Rendering::Headset::getEyeCount ( ) const
nodiscard

Getter.

◆ getEyeProjectionMatrix()

glm::mat4 Engine::Rendering::Headset::getEyeProjectionMatrix ( size_t eyeIndex) const
nodiscard

Gets the projection matrix for an eye.

Parameters
eyeIndexleft or right eye (0, 1)

◆ getEyeResolution()

VkExtent2D Engine::Rendering::Headset::getEyeResolution ( size_t eyeIndex) const
nodiscard

Gets eye resolution in x and y for a specified eye index. 0 is left.

Parameters
eyeIndexZero-based index of the eye

◆ getEyeViewMatrix()

glm::mat4 Engine::Rendering::Headset::getEyeViewMatrix ( size_t eyeIndex) const
nodiscard

Returns the view matrix of the specified eye.

Parameters
eyeIndexleft and right eye

◆ getHeadsetLocalOrientation()

glm::quat Engine::Rendering::Headset::getHeadsetLocalOrientation ( ) const
nodiscard

Gets the headset's local orientation relative to the play space.

◆ getHeadsetLocalPosition()

glm::vec3 Engine::Rendering::Headset::getHeadsetLocalPosition ( ) const
nodiscard

Gets the headset's local position relative to the play space origin.

◆ getHeadsetWorldOrientation()

glm::quat Engine::Rendering::Headset::getHeadsetWorldOrientation ( ) const
nodiscard

Gets the headset orientation after player rotation is applied.

◆ getHeadsetWorldPosition()

glm::vec3 Engine::Rendering::Headset::getHeadsetWorldPosition ( ) const
nodiscard

Gets the headset position after player position/rotation are applied.

◆ getIsExitRequested()

bool Engine::Rendering::Headset::getIsExitRequested ( ) const
nodiscard

Returns true if the headset has requested the application to exit.

◆ getPlayerPosition()

glm::vec3 Engine::Rendering::Headset::getPlayerPosition ( ) const
inlinenodiscard

Getter.

Definition at line 150 of file Headset.h.

References playerPosition_.

◆ getPlayerRotation()

glm::quat Engine::Rendering::Headset::getPlayerRotation ( ) const
inlinenodiscard

Getter for the player/play-space rotation.

Definition at line 163 of file Headset.h.

References playerRotation_.

◆ getRawEyeViewMatrix()

glm::mat4 Engine::Rendering::Headset::getRawEyeViewMatrix ( size_t eyeIndex) const
nodiscard

Gets the raw eye view matrix without player position offset.

◆ getReferenceSpace()

XrSpace Engine::Rendering::Headset::getReferenceSpace ( ) const
nodiscard

Getter.

◆ getRenderPass()

VkRenderPass Engine::Rendering::Headset::getRenderPass ( ) const
nodiscard

Getter.

◆ getRenderTarget()

const RenderTarget * Engine::Rendering::Headset::getRenderTarget ( size_t swapchainImageIndex) const

Getter.

◆ getResolveBufferImage()

VkImage Engine::Rendering::Headset::getResolveBufferImage ( ) const
inlinenodiscard

Getter.

Definition at line 346 of file Headset.h.

References resolveBuffer.

◆ getResolveBufferView()

VkImageView Engine::Rendering::Headset::getResolveBufferView ( ) const
inlinenodiscard

Getter.

Definition at line 354 of file Headset.h.

References resolveBuffer.

◆ getSceneColorFormat()

VkFormat Engine::Rendering::Headset::getSceneColorFormat ( ) const
inlinenodiscard

Definition at line 367 of file Headset.h.

References sceneColorFormat_.

◆ getSession()

XrSession Engine::Rendering::Headset::getSession ( ) const
nodiscard

Getter.

◆ getSwapchainImage()

VkImage Engine::Rendering::Headset::getSwapchainImage ( size_t swapchainImageIndex) const
nodiscard

Getter.

◆ getSwapchainRenderTargets()

std::vector< RenderTarget > Engine::Rendering::Headset::getSwapchainRenderTargets ( )

◆ getViewProjectionMatrix()

glm::mat4 Engine::Rendering::Headset::getViewProjectionMatrix ( size_t eyeIndex) const
nodiscard

Gets the multiplied view and projection matrix.

Parameters
eyeIndexThe frame index

◆ getXrFrameState()

XrFrameState Engine::Rendering::Headset::getXrFrameState ( ) const
nodiscard

Getter.

◆ requestExitSession()

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.

◆ setPlayerPosition()

void Engine::Rendering::Headset::setPlayerPosition ( const glm::vec3 & position)
inline

Setter.

Definition at line 142 of file Headset.h.

References playerPosition_.

◆ setPlayerRotation()

void Engine::Rendering::Headset::setPlayerRotation ( const glm::quat & rotation)

Setter for the player/play-space rotation applied around the world origin.

◆ transformPlaySpaceOrientation()

glm::quat Engine::Rendering::Headset::transformPlaySpaceOrientation ( const glm::quat & orientation) const
nodiscard

Converts an OpenXR play-space orientation into world space.

◆ transformPlaySpacePosition()

glm::vec3 Engine::Rendering::Headset::transformPlaySpacePosition ( const glm::vec3 & position) const
nodiscard

Converts an OpenXR play-space position into world space.

◆ updateViewMatrix()

void Engine::Rendering::Headset::updateViewMatrix ( )

Updates the eye matrix for the headset.

◆ waitForXrFrame()

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.

Parameters
rendererPointer to renderer (used for Tracy context reset on state transitions)
Returns
WaitFrameResult indicating what to do next

Member Data Documentation

◆ colorBuffer

ImageBuffer Engine::Rendering::Headset::colorBuffer
private

Definition at line 274 of file Headset.h.

Referenced by getColorBufferImage(), and getColorBufferView().

◆ colorFormat_

VkFormat Engine::Rendering::Headset::colorFormat_ = VK_FORMAT_R8G8B8A8_UNORM
private

Definition at line 373 of file Headset.h.

Referenced by getColorFormat().

◆ context

const Core::ApplicationContext* Engine::Rendering::Headset::context = nullptr
private

Definition at line 238 of file Headset.h.

Referenced by Engine::Rendering::Headset::ImageBuffer::cleanup(), and Headset().

◆ depthBuffer

ImageBuffer Engine::Rendering::Headset::depthBuffer
private

Definition at line 275 of file Headset.h.

Referenced by getDepthBufferImage(), and getDepthBufferView().

◆ eyeCount

uint32_t Engine::Rendering::Headset::eyeCount = 0u
private

Definition at line 259 of file Headset.h.

◆ eyeImageInfos

std::vector<XrViewConfigurationView> Engine::Rendering::Headset::eyeImageInfos
private

Definition at line 261 of file Headset.h.

◆ eyePoses

std::vector<XrView> Engine::Rendering::Headset::eyePoses
private

Definition at line 263 of file Headset.h.

◆ eyeRenderInfos

std::vector<XrCompositionLayerProjectionView> Engine::Rendering::Headset::eyeRenderInfos
private

Definition at line 289 of file Headset.h.

◆ eyes

std::vector<Eye> Engine::Rendering::Headset::eyes = {}
private

Definition at line 297 of file Headset.h.

◆ isExistRequested

bool Engine::Rendering::Headset::isExistRequested = false
private

Definition at line 236 of file Headset.h.

◆ lastUpdateTime

XrTime Engine::Rendering::Headset::lastUpdateTime = 0
private

Definition at line 299 of file Headset.h.

◆ playerPosition_

glm::vec3 Engine::Rendering::Headset::playerPosition_ { 0.0f, 0.0f, 0.0f }
private

Definition at line 302 of file Headset.h.

Referenced by getPlayerPosition(), and setPlayerPosition().

◆ playerRotation_

glm::quat Engine::Rendering::Headset::playerRotation_ { 1.0f, 0.0f, 0.0f, 0.0f }
private

Definition at line 303 of file Headset.h.

Referenced by getPlayerRotation().

◆ resolveBuffer

ImageBuffer Engine::Rendering::Headset::resolveBuffer
private

Definition at line 276 of file Headset.h.

Referenced by getResolveBufferImage(), and getResolveBufferView().

◆ sceneColorFormat_

VkFormat Engine::Rendering::Headset::sceneColorFormat_ = VK_FORMAT_R16G16B16A16_SFLOAT
private

Definition at line 374 of file Headset.h.

Referenced by getSceneColorFormat().

◆ swapchainRenderTargets

std::vector<RenderTarget> Engine::Rendering::Headset::swapchainRenderTargets
private

The swapchain render targets. The images get rendered onto those render targets.

Definition at line 287 of file Headset.h.

◆ vkRenderPass

VkRenderPass Engine::Rendering::Headset::vkRenderPass = VK_NULL_HANDLE
private

The vulkan render pass.

Definition at line 243 of file Headset.h.

◆ xrFrameState

XrFrameState Engine::Rendering::Headset::xrFrameState = {}
private

Definition at line 232 of file Headset.h.

◆ xrReferenceSpace

XrSpace Engine::Rendering::Headset::xrReferenceSpace = XR_NULL_HANDLE
private

The xr reference space.

Definition at line 253 of file Headset.h.

◆ xrReferenceSpaceType

XrReferenceSpaceType Engine::Rendering::Headset::xrReferenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL
private

Type of the xr reference space, if it is room scale or just sitting vr.

Definition at line 257 of file Headset.h.

◆ xrSession

XrSession Engine::Rendering::Headset::xrSession = XR_NULL_HANDLE
private

The xr session.

Definition at line 248 of file Headset.h.

◆ xrSessionState

XrSessionState Engine::Rendering::Headset::xrSessionState = XR_SESSION_STATE_UNKNOWN
private

Definition at line 234 of file Headset.h.

◆ xrSwapchain

XrSwapchain Engine::Rendering::Headset::xrSwapchain = nullptr
private

Definition at line 278 of file Headset.h.

◆ xrViewState

XrViewState Engine::Rendering::Headset::xrViewState = {}
private

Definition at line 231 of file Headset.h.

◆ xrWaitThreadPool_

std::unique_ptr<NamedThreadPool> Engine::Rendering::Headset::xrWaitThreadPool_
private

Definition at line 281 of file Headset.h.


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Renderer/Headset.h