LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::XRSession Class Referenceabstract

XR session interface. More...

#include <XRSession.h>

Inheritance diagram for LLGL::XRSession:
LLGL::Interface LLGL::NonCopyable

Public Member Functions

 ~XRSession ()
 Releases internal data. The owning XRSystem releases native XR resources.
virtual XRSessionState GetState () const =0
 Returns the current runtime-reported session state.
virtual XREnvironmentBlendMode GetEnvironmentBlendMode () const =0
 Returns the environment blend mode the runtime selected for this session.
virtual ArrayView< Format > GetSupportedColorFormats () const =0
 Returns the list of color formats supported by this session for swap-chains, in runtime-preferred order.
virtual ArrayView< Format > GetSupportedDepthFormats () const =0
 Returns the list of depth-stencil formats supported by this session for swap-chains, in runtime-preferred order.
virtual XRSwapChain * CreateSwapChain (const XRSwapChainDescriptor &swapChainDesc)=0
 Creates a new XR swap-chain.
virtual void Release (XRSwapChain &swapChain)=0
 Releases the specified swap-chain. After this call, the specified object must no longer be used.
virtual bool IsRunning () const =0
 Returns true if the session has been signalled ready by the runtime and BeginFrame may be invoked.
virtual bool WaitFrame (XRFrameState &frameState)=0
 Waits for the previous frame to finish and retrieves the next frame state. Must be called before BeginFrame at the beginning of the app's update.
virtual bool BeginFrame ()=0
 Begins a new XR frame. Must be called after WaitFrame().
virtual bool EndFrame (float nearZ, float farZ, ArrayView< XRSwapChain * > swapChains)=0
 Submits a frame to the runtime.
virtual bool GetViewState (DynamicVector< XRViewPose > &viewsOut)=0
 Sample and return the latest predicted poses for the session's views.
virtual bool GetNativeHandle (void *nativeHandle, std::size_t nativeHandleSize)=0
 Returns the native handle of this XR Session.
virtual const Report * GetReport () const =0
 Returns a pointer to the report or null if there is none.
Public Member Functions inherited from LLGL::Interface
virtual bool IsInstanceOf (int id) const
 Returns true if this object is an instance of the specified interface.
Public Member Functions inherited from LLGL::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
virtual ~NonCopyable ()=default

Protected Member Functions

 XRSession ()
 Allocates the internal data.
Protected Member Functions inherited from LLGL::NonCopyable
 NonCopyable ()=default

Detailed Description

XR session interface.

Remarks
Drives the per-frame loop: BeginFrame yields predicted view poses, the application renders into one swap-chain image per view, and EndFrame submits the projection layer back to the runtime.
See also
XRSystem::CreateSession

Constructor & Destructor Documentation

◆ ~XRSession()

LLGL::XRSession::~XRSession ( )

Releases internal data. The owning XRSystem releases native XR resources.

◆ XRSession()

LLGL::XRSession::XRSession ( )
protected

Allocates the internal data.

Member Function Documentation

◆ BeginFrame()

virtual bool LLGL::XRSession::BeginFrame ( )
pure virtual

Begins a new XR frame. Must be called after WaitFrame().

Returns
True on success. On failure, the frame must be skipped (do not call EndFrame).

◆ CreateSwapChain()

virtual XRSwapChain * LLGL::XRSession::CreateSwapChain ( const XRSwapChainDescriptor & swapChainDesc)
pure virtual

Creates a new XR swap-chain.

Parameters
[in]swapChainDescSpecifies the swap-chain descriptor.
Returns
Pointer to the new XRSwapChain or null on failure (see XRSystem::GetReport).
Remarks
The session retains ownership of the swap-chain; releasing it through ReleaseSwapChain or destroying the session frees the underlying XR resources.

◆ EndFrame()

virtual bool LLGL::XRSession::EndFrame ( float nearZ,
float farZ,
ArrayView< XRSwapChain * > swapChains )
pure virtual

Submits a frame to the runtime.

Parameters
[in]nearZNear clipping plane (in meters) the application used to render this frame.
[in]farZFar clipping plane (in metres) the application used to render this frame.
[in]swapChainsOne swap-chain per view, in the same order as XRSystem::GetViewConfigurations().
Returns
True on success.
Remarks
This submits a projection composition layer using the swap-chains' currently released images. If WaitFrame returned false in frameState.shouldRender, an empty layer set is submitted instead (the runtime still requires a paired EndFrame call).

◆ GetEnvironmentBlendMode()

virtual XREnvironmentBlendMode LLGL::XRSession::GetEnvironmentBlendMode ( ) const
pure virtual

Returns the environment blend mode the runtime selected for this session.

◆ GetNativeHandle()

virtual bool LLGL::XRSession::GetNativeHandle ( void * nativeHandle,
std::size_t nativeHandleSize )
pure virtual

Returns the native handle of this XR Session.

Parameters
[out]nativeHandlePointer to the backend-specific native handle structure. Obtain it from #include <LLGL/Backend/OpenXR/NativeHandle.h>.
[in]nativeHandleSizeSize (in bytes) of the native handle structure.
Returns
True if the native handle was successfully retrieved.
See also
OpenXR::SessionNativeHandle

◆ GetReport()

virtual const Report * LLGL::XRSession::GetReport ( ) const
pure virtual

Returns a pointer to the report or null if there is none.

Remarks
Indicates errors from a previous session operation.
See also
Report

◆ GetState()

virtual XRSessionState LLGL::XRSession::GetState ( ) const
pure virtual

Returns the current runtime-reported session state.

◆ GetSupportedColorFormats()

virtual ArrayView< Format > LLGL::XRSession::GetSupportedColorFormats ( ) const
pure virtual

Returns the list of color formats supported by this session for swap-chains, in runtime-preferred order.

Remarks
The application should pick the first format that satisfies its rendering needs.
See also
CreateSwapChain

◆ GetSupportedDepthFormats()

virtual ArrayView< Format > LLGL::XRSession::GetSupportedDepthFormats ( ) const
pure virtual

Returns the list of depth-stencil formats supported by this session for swap-chains, in runtime-preferred order.

Remarks
Empty if the runtime doesn't support depth swap-chain submission (i.e. XR_KHR_composition_layer_depth is unavailable). When non-empty, pass the chosen format in XRSwapChainDescriptor::depthStencilFormat to have the swap-chain submit depth to the runtime for reprojection; otherwise the swap-chain falls back to a private depth texture that is not submitted.
See also
CreateSwapChain
XRSwapChainDescriptor::depthStencilFormat

◆ GetViewState()

virtual bool LLGL::XRSession::GetViewState ( DynamicVector< XRViewPose > & viewsOut)
pure virtual

Sample and return the latest predicted poses for the session's views.

Parameters
[out]viewsOutReceives the view poses and projection parameters. The size of this array matches the view count returned by XRSystem::GetViewConfigurations().
Returns
True on success.
Remarks
Each time this is called, the runtime updates the view poses based on the latest predicted display time. The application should call this at least once per frame after WaitFrame() to get the latest view poses for rendering and reprojection. If EndFrame is called with a non-empty swap-chain array, the runtime also uses these poses for reprojection of the submitted layer.

◆ IsRunning()

virtual bool LLGL::XRSession::IsRunning ( ) const
pure virtual

Returns true if the session has been signalled ready by the runtime and BeginFrame may be invoked.

Remarks
This becomes true after the runtime transitions to XRSessionState::Ready. Most applications should not call BeginFrame/EndFrame while this returns false.

◆ Release()

virtual void LLGL::XRSession::Release ( XRSwapChain & swapChain)
pure virtual

Releases the specified swap-chain. After this call, the specified object must no longer be used.

◆ WaitFrame()

virtual bool LLGL::XRSession::WaitFrame ( XRFrameState & frameState)
pure virtual

Waits for the previous frame to finish and retrieves the next frame state. Must be called before BeginFrame at the beginning of the app's update.

Parameters
[out]frameStateReceives the predicted display time and a flag indicating whether the application should render.
Returns
True on success

The documentation for this class was generated from the following file: