13#ifndef vtkOpenXRManager_h
14#define vtkOpenXRManager_h
16#include "vtkRenderingOpenXRModule.h"
30VTK_ABI_NAMESPACE_BEGIN
45 return UniqueInstance;
69 std::uint16_t Major{};
70 std::uint16_t Minor{};
71 std::uint32_t Patch{};
130 return static_cast<uint32_t
>(this->RenderResources->ConfigViews.size());
150 if (eye >= this->GetViewCount())
154 return &(this->RenderResources->Views[eye].pose);
166 if (eye >= this->GetViewCount())
170 return &(this->RenderResources->Views[eye].fov);
190 return this->OptionalExtensions.SceneUnderstandingSupported;
287 bool CreateActionSet(
const std::string& actionSetName,
const std::string& localizedActionSetName);
321 Action_t& actionT,
const std::string& name,
const std::string& localizedName);
329 const std::string& profile, std::vector<XrActionSuggestedBinding>& actionSuggestedBindings);
357 float duration = 25000000.0,
float frequency = XR_FREQUENCY_UNSPECIFIED);
366 NumberOfControllers = 4
380 } States[ControllerIndex::NumberOfControllers];
382 XrSpace PoseSpaces[ControllerIndex::NumberOfControllers];
383 XrSpaceLocation PoseLocations[ControllerIndex::NumberOfControllers];
384 XrSpaceVelocity PoseVelocities[ControllerIndex::NumberOfControllers];
404 "Use vtkOpenXRRenderWindow::SetUseDepthExtension instead. This has no effect!")
405 void SetUseDepthExtension(
bool) {}
407 "Use vtkOpenXRRenderWindow::GetUseDepthExtension instead. This returns false!")
408 bool GetUseDepthExtension()
const {
return false; }
506 XrSwapchainCreateFlags createFlags, XrSwapchainUsageFlags usageFlags);
523 const XrPosef& poseInActionSpace, XrSpace& space);
542 constexpr static XrFormFactor FormFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
545 constexpr static XrViewConfigurationType ViewType = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
548 constexpr static uint32_t StereoViewCount = 2;
553 XrReferenceSpaceType ReferenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE;
573 bool RenderingBackendExtensionSupported =
false;
582 bool DepthExtensionSupported{
false };
583 bool ControllerModelExtensionSupported{
false };
584 bool UnboundedRefSpaceSupported{
false };
585 bool SpatialAnchorSupported{
false };
586 bool HandInteractionSupported{
false };
587 bool HandTrackingSupported{
false };
588 bool RemotingSupported{
false };
589 bool SceneUnderstandingSupported{
false };
590 bool SceneMarkerSupported{
false };
591 } OptionalExtensions;
603 uint32_t Height{ 0 };
615 XrViewState ViewState{ XR_TYPE_VIEW_STATE };
634 XrActionSet* ActiveActionSet =
nullptr;
642 bool SessionRunning =
false;
648 bool ShouldRenderCurrentFrame =
false;
651 bool StorePoseVelocities =
false;
OpenXR manager connection no-op implementation.
OpenXR manager graphics implementation.
Singleton class that holds a collection of utility functions and member variables to communicate with...
XrSpace GetReferenceSpace() const
Return XrSpace associated with the XrSession.
const XrInstance & GetXrRuntimeInstance()
Return the instance used to communicate with the runtime.
void PrintViewConfigViewInfo(const std::vector< XrViewConfigurationView > &)
Utility functions to print information about OpenXR manager internal structures.
bool CreateOneActionSpace(const XrAction &action, const XrPath &subactionPath, const XrPosef &poseInActionSpace, XrSpace &space)
For pose actions, we must create an action space to locate it.
XrTime PredictedDisplayTime
Store the frame predicted display time in WaitAndBeginFrame To get the action data at this time and t...
bool BeginSession()
Start the OpenXR session.
void PrintOptionalExtensions()
Print the optional extensions which were found and enabled.
const XrPosef * GetViewPose(uint32_t eye)
Returns a pointer to the view pose that contains the view orientation and position for the specified ...
bool GetShouldRenderCurrentFrame()
Return true if the current frame should be rendered.
vtkOpenXRManagerGraphics * GetGraphicsStrategy()
Set/Get the rendering backend strategy.
void PrintInstanceProperties()
Utility functions to print information about OpenXR manager internal structures.
static InstanceVersion QueryInstanceVersion(vtkOpenXRManagerConnection *cs)
Utility function to get XrInstance runtime version for given ConnectionStrategy This function creates...
void PrintSystemProperties(XrSystemProperties *system_properties)
Utility functions to print information about OpenXR manager internal structures.
bool WaitAndBeginFrame()
This function is used to start a frame.
std::tuple< int64_t, int64_t > SelectSwapchainPixelFormats()
During the creation of the swapchains, we need to check the runtime available pixels formats,...
bool AttachSessionActionSets()
Attach all action sets in the ActionSets vector to the session.
bool CreateInstance(vtkOpenXRRenderWindow *window)
OpenXR Instance creation.
~vtkOpenXRManager()=default
XrSystemId GetSystemID() const
Return OpenXR System ID associated with the XrSession.
bool IsSessionRunning()
Return true if the OpenXR session is currently running, ie.
bool ApplyVibration(const Action_t &actionT, int hand, float amplitude=0.5, float duration=25000000.0, float frequency=XR_FREQUENCY_UNSPECIFIED)
Apply haptic vibration action to emit vibration on hand to emit on amplitude 0.0 to 1....
const XrFovf * GetProjectionFov(uint32_t eye)
Returns a pointer to the projection field of view for the specified eye, or nullptr if eye exceeds or...
bool CreateSystem()
OpenXR System creation.
bool CreateReferenceSpace()
Creates the reference space of type ReferenceSpaceType that will be used to locate views.
void SetGraphicsStrategy(vtkOpenXRManagerGraphics *gs)
Set/Get the rendering backend strategy.
bool IsDepthExtensionSupported()
Return true if the runtime supports the depth extension.
std::tuple< uint32_t, uint32_t > GetRecommendedImageRectSize()
Return as a tuple the OpenXR recommended texture size to be sent to the device.
uint32_t GetViewCount()
Return the number of OpenXR views (typically one per physical display / eye)
XrPath GetXrPath(const std::string &path)
Get the XrPath from the well-formed string path.
uint32_t WaitAndAcquireSwapchainImage(const XrSwapchain &swapchainHandle)
When preparing the rendering for an eye, we must ask the runtime for a texture to draw in it.
vtkSmartPointer< vtkOpenXRManagerConnection > ConnectionStrategy
XrTime GetPredictedDisplayTime() const
Return runtime predicted display time for next frame.
vtkOpenXRManagerConnection * GetConnectionStrategy()
Set/Get the connection strategy.
bool EndFrame()
Submit the composition layers for the predicted display time of the current frame.
bool PollEvent(XrEventDataBuffer &eventData)
Store in eventData the result of xrPollEvent.
static vtkOpenXRManager & GetInstance()
Return the singleton instance.
bool CreateOneAction(Action_t &actionT, const std::string &name, const std::string &localizedName)
Creates one action with name name and localizedName localizedName and store the action handle inside ...
uint32_t GetRecommendedSampleCount()
Return the recommended swapchain sample count.
std::array< XrPath, 2 > SubactionPaths
bool SyncActions()
Update the action states using the active action set.
bool CreateActionSet(const std::string &actionSetName, const std::string &localizedActionSetName)
Creates an action set and add it to the vector of action sets.
Swapchain_t CreateSwapchain(int64_t format, uint32_t width, uint32_t height, uint32_t sampleCount, XrSwapchainCreateFlags createFlags, XrSwapchainUsageFlags usageFlags)
Create an XrSwapchain handle used to present rendered image to the user with the given parameters for...
bool CreateSystemProperties()
Enable system properties such as hand tracking, and choose environment blend modes.
std::string GetOpenXRPropertiesAsString()
Return the OpenXR properties as a string, with format "RuntimeName MAJOR.MINOR.PATCH".
void Finalize()
Internal API.
bool XrCheckOutput(OutputLevel level, const XrResult &, const std::string &message)
Utility function to check the XrResult, print the result message as a debug, warning or error message...
void SetConnectionStrategy(vtkOpenXRManagerConnection *cs)
Set/Get the connection strategy.
void ReleaseSwapchainImage(uint32_t eye)
When the rendering in a swapchain image is done, it must be released with this function.
bool SelectActiveActionSet(unsigned int index)
Selects the current active action set from the ActionSets vector using its index.
bool CreateConfigViews()
There is one configuration view per view, and it contains the recommended texture resolution in pixel...
XrSessionState SessionState
bool IsSceneUnderstandingSupported()
Return true if the runtime supports the scene understanding extension.
bool PrepareRendering(vtkOpenXRRenderWindow *win, void *colorTextureId, void *depthTextureId)
Prepare the rendering resources for the specified eye and store in colorTextureId and in depthTexture...
bool Initialize(vtkOpenXRRenderWindow *xrWindow)
Internal API.
bool CreateSwapchains()
Swapchaines creation : there is one swapchain per view / display.
void DestroyActionSets()
Iterate over and destroy all action sets that have been created.
bool CreateSession()
Create the session and pass the GraphicsBinding to the next pointer of the XrSessionCreateInfo.
std::vector< XrActionSet > ActionSets
const XrSession & GetSession()
Return the OpenXR Session.
void PrintSupportedViewConfigs()
Utility functions to print information about OpenXR manager internal structures.
const std::array< XrPath, 2 > & GetSubactionPaths()
XrEnvironmentBlendMode EnvironmentBlendMode
bool LoadControllerModels()
bool UpdateActionData(Action_t &action_t, int hand)
Update the action data and store it in action_t.States for one hand.
bool SuggestActions(const std::string &profile, std::vector< XrActionSuggestedBinding > &actionSuggestedBindings)
Suggest actions stored in actionSuggestedBindings for the interaction profile profile.
bool CreateSubactionPaths()
Creates one subaction path for each hand.
bool PrintReferenceSpaces()
Utility functions to print information about OpenXR manager internal structures.
std::unique_ptr< RenderResources_t > RenderResources
std::vector< const char * > SelectExtensions(vtkOpenXRRenderWindow *window)
OpenXR Instance creation.
vtkSmartPointer< vtkOpenXRManagerGraphics > GraphicsStrategy
Hold a reference to a vtkObjectBase instance.
XrActionStateFloat _float
XrActionStateVector2f _vec2f
XrActionStateBoolean _boolean
Structure representing OpenXR instance version.
This struct stores all needed information to render the images and send it to the user We can't make ...
std::vector< XrView > Views
std::vector< Swapchain_t > ColorSwapchains
std::vector< XrViewConfigurationView > ConfigViews
std::vector< Swapchain_t > DepthSwapchains
std::vector< XrCompositionLayerProjectionView > ProjectionLayerViews
std::vector< XrCompositionLayerDepthInfoKHR > DepthInfoViews
Swapchain structure storing information common to all rendering backend.
#define VTK_DEPRECATED_IN_9_5_0(reason)
Defines the OpenXR types and extensions common to all platforms.