35 XrViewConfigurationType
view_type = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
78 oxr_->swapchains.clear();
79 oxr_->action_sets.clear();
81 if (oxr_->reference_space != XR_NULL_HANDLE) {
84 if (oxr_->view_space != XR_NULL_HANDLE) {
87 if (oxr_->combined_eye_space != XR_NULL_HANDLE) {
90 if (oxr_->session != XR_NULL_HANDLE) {
94 oxr_->session = XR_NULL_HANDLE;
95 oxr_->session_state = XR_SESSION_STATE_UNKNOWN;
97 oxr_->passthrough_supported =
false;
98 oxr_->passthrough_layer.layerHandle = XR_NULL_HANDLE;
100 context_->getCustomFuncs().session_exit_fn(context_->getCustomFuncs().session_exit_customdata);
107void GHOST_XrSession::initSystem()
110 assert(oxr_->system_id == XR_NULL_SYSTEM_ID);
112 XrSystemGetInfo system_info = {};
113 system_info.type = XR_TYPE_SYSTEM_GET_INFO;
114 system_info.formFactor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
116 CHECK_XR(xrGetSystem(context_->getInstance(), &system_info, &oxr_->system_id),
117 "Failed to get device information. Is a device plugged in?");
129 XrReferenceSpaceCreateInfo create_info = {XR_TYPE_REFERENCE_SPACE_CREATE_INFO};
130 create_info.poseInReferenceSpace.orientation.w = 1.0f;
140 if (supported_spaces.
contains(XR_REFERENCE_SPACE_TYPE_STAGE)) {
141 create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_STAGE;
143 "Failed to create stage reference space.");
148 CHECK_XR(xrGetReferenceSpaceBoundsRect(oxr.
session, XR_REFERENCE_SPACE_TYPE_STAGE, &extents),
149 "Failed to get stage reference space bounds.");
150 if (extents.width != 0.0f && extents.height != 0.0f) {
161 "Invalid stage reference space bounds, falling back to local floor reference "
162 "space. To use the stage reference space, please define a tracking space via the "
167 if (supported_spaces.
contains(XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT)) {
169 "Stage reference space unavailable, falling back to local floor reference space.");
170 create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL_FLOOR_EXT;
172 "Failed to create local floor reference space.");
178 "Stage and local floor reference space unavailable, falling back to local "
180 create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_LOCAL;
182 "Failed to create local reference space.");
187 XrReferenceSpaceCreateInfo create_info = {XR_TYPE_REFERENCE_SPACE_CREATE_INFO};
188 create_info.poseInReferenceSpace.orientation.w = 1.0f;
191 uint32_t space_count = 0;
192 CHECK_XR(xrEnumerateReferenceSpaces(oxr.
session, 0, &space_count,
nullptr),
193 "Failed to enumerate available reference space count.");
195 std::vector<XrReferenceSpaceType> supported_spaces_vec(space_count);
196 CHECK_XR(xrEnumerateReferenceSpaces(
197 oxr.
session, space_count, &space_count, supported_spaces_vec.data()),
198 "Failed to enumerate available reference spaces.");
205 create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_VIEW;
207 "Failed to create view reference space.");
211 create_info.referenceSpaceType = XR_REFERENCE_SPACE_TYPE_COMBINED_EYE_VARJO;
213 "Failed to create combined eye reference space.");
219 assert(context_->getInstance() != XR_NULL_HANDLE);
220 assert(oxr_->session == XR_NULL_HANDLE);
221 if (context_->getCustomFuncs().gpu_ctx_bind_fn ==
nullptr) {
223 "Invalid API usage: No way to bind graphics context to the XR session. Call "
224 "GHOST_XrGraphicsContextBindFuncs() with valid parameters before starting the "
225 "session (through GHOST_XrSessionStart()).");
230 bindGraphicsContext();
231 if (gpu_ctx_ ==
nullptr) {
233 "Invalid API usage: No graphics context returned through the callback set with "
234 "GHOST_XrGraphicsContextBindFuncs(). This is required for session starting (through "
235 "GHOST_XrSessionStart()).");
238 std::string requirement_str;
241 if (!gpu_binding_->loadExtensionFunctions(context_->getInstance())) {
243 "Unable to load graphics bindings (could not load the needed extension functions from the "
246 if (!gpu_binding_->checkVersionRequirements(
247 *gpu_ctx_, context_->getInstance(), oxr_->system_id, &requirement_str))
249 std::ostringstream strstream;
250 strstream <<
"Available graphics context version does not meet the following requirements: "
254 gpu_binding_->initFromGhostContext(*gpu_ctx_, context_->getInstance(), oxr_->system_id);
256 XrSessionCreateInfo create_info = {};
257 create_info.type = XR_TYPE_SESSION_CREATE_INFO;
258 create_info.systemId = oxr_->system_id;
259 create_info.next = &gpu_binding_->oxr_binding;
261 CHECK_XR(xrCreateSession(context_->getInstance(), &create_info, &oxr_->session),
262 "Failed to create VR session. The OpenXR runtime may have additional requirements for "
263 "the graphics driver that are not met. Other causes are possible too however.\nTip: "
264 "The --debug-xr command line option for Blender might allow the runtime to output "
265 "detailed error information to the command line.");
271 context_->getCustomFuncs().session_create_fn();
276 xrRequestExitSession(oxr_->session);
279void GHOST_XrSession::beginSession()
281 XrSessionBeginInfo begin_info = {XR_TYPE_SESSION_BEGIN_INFO};
282 begin_info.primaryViewConfigurationType = oxr_->view_type;
283 CHECK_XR(xrBeginSession(oxr_->session, &begin_info),
"Failed to cleanly begin the VR session.");
286void GHOST_XrSession::endSession()
288 assert(oxr_->session != XR_NULL_HANDLE);
289 CHECK_XR(xrEndSession(oxr_->session),
"Failed to cleanly end the VR session.");
293 const XrEventDataSessionStateChanged &lifecycle)
295 oxr_->session_state = lifecycle.state;
299 assert(oxr_->session == XR_NULL_HANDLE || oxr_->session == lifecycle.session);
301 switch (lifecycle.state) {
302 case XR_SESSION_STATE_READY:
305 case XR_SESSION_STATE_STOPPING:
308 case XR_SESSION_STATE_EXITING:
309 case XR_SESSION_STATE_LOSS_PENDING:
324void GHOST_XrSession::prepareDrawing()
328 std::vector<XrViewConfigurationView> view_configs;
333 oxr_->view_type = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_QUAD_VARJO;
336 oxr_->foveation_supported = context_->isExtensionEnabled(
337 XR_VARJO_FOVEATED_RENDERING_EXTENSION_NAME);
339 CHECK_XR(xrEnumerateViewConfigurationViews(
340 context_->getInstance(), oxr_->system_id, oxr_->view_type, 0, &view_count,
nullptr),
341 "Failed to get count of view configurations.");
342 view_configs.resize(view_count, {XR_TYPE_VIEW_CONFIGURATION_VIEW});
343 CHECK_XR(xrEnumerateViewConfigurationViews(context_->getInstance(),
348 view_configs.data()),
349 "Failed to get view configurations.");
352 if (oxr_->foveation_supported) {
353 std::vector<XrFoveatedViewConfigurationViewVARJO> request_foveated_config{
354 view_count, {XR_TYPE_FOVEATED_VIEW_CONFIGURATION_VIEW_VARJO,
nullptr, XR_TRUE}};
356 auto foveated_views = std::vector<XrViewConfigurationView>(view_count,
357 {XR_TYPE_VIEW_CONFIGURATION_VIEW});
359 for (uint32_t i = 0; i < view_count; i++) {
360 foveated_views[i].next = &request_foveated_config[i];
362 CHECK_XR(xrEnumerateViewConfigurationViews(context_->getInstance(),
367 foveated_views.data()),
368 "Failed to get foveated view configurations.");
371 for (uint32_t i = 0; i < view_count; i++) {
372 view_configs[i].recommendedImageRectWidth = std::max(
373 view_configs[i].recommendedImageRectWidth, foveated_views[i].recommendedImageRectWidth);
374 view_configs[i].recommendedImageRectHeight = std::max(
375 view_configs[i].recommendedImageRectHeight,
376 foveated_views[i].recommendedImageRectHeight);
380 for (
const XrViewConfigurationView &view_config : view_configs) {
381 oxr_->swapchains.emplace_back(*gpu_binding_, oxr_->session, view_config);
384 oxr_->views.resize(view_count, {XR_TYPE_VIEW});
386 draw_info_ = std::make_unique<GHOST_XrDrawInfo>();
389void GHOST_XrSession::beginFrameDrawing()
391 XrFrameWaitInfo wait_info = {XR_TYPE_FRAME_WAIT_INFO};
392 XrFrameBeginInfo begin_info = {XR_TYPE_FRAME_BEGIN_INFO};
393 XrFrameState frame_state = {XR_TYPE_FRAME_STATE};
396 CHECK_XR(xrWaitFrame(oxr_->session, &wait_info, &frame_state),
397 "Failed to synchronize frame rates between Blender and the device.");
400 draw_info_->foveation_active =
false;
401 if (oxr_->foveation_supported) {
402 XrSpaceLocation render_gaze_location{XR_TYPE_SPACE_LOCATION};
403 CHECK_XR(xrLocateSpace(oxr_->combined_eye_space,
405 frame_state.predictedDisplayTime,
406 &render_gaze_location),
407 "Failed to locate combined eye space.");
409 draw_info_->foveation_active = (render_gaze_location.locationFlags &
410 XR_SPACE_LOCATION_ORIENTATION_TRACKED_BIT) != 0;
413 CHECK_XR(xrBeginFrame(oxr_->session, &begin_info),
414 "Failed to submit frame rendering start state.");
416 draw_info_->frame_state = frame_state;
418 if (context_->isDebugTimeMode()) {
419 draw_info_->frame_begin_time = std::chrono::high_resolution_clock::now();
426 std::chrono::duration<double, std::milli> duration = std::chrono::high_resolution_clock::now() -
428 const double duration_ms = duration.count();
429 const int avg_frame_count = 8;
430 double avg_ms_tot = 0.0;
438 avg_ms_tot += ms_iter;
442 "VR frame render time: %.0fms - %.2f FPS (%.2f FPS 8 frames average)",
444 1000.0 / duration_ms,
448void GHOST_XrSession::endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers)
450 XrFrameEndInfo end_info = {XR_TYPE_FRAME_END_INFO};
452 end_info.displayTime = draw_info_->frame_state.predictedDisplayTime;
453 end_info.environmentBlendMode = XR_ENVIRONMENT_BLEND_MODE_OPAQUE;
454 end_info.layerCount = layers.size();
455 end_info.layers = layers.data();
457 CHECK_XR(xrEndFrame(oxr_->session, &end_info),
"Failed to submit rendered frame.");
459 if (context_->isDebugTimeMode()) {
466 std::vector<XrCompositionLayerProjectionView>
467 projection_layer_views;
468 XrCompositionLayerProjection proj_layer;
469 std::vector<XrCompositionLayerBaseHeader *> layers;
473 if (context_->getCustomFuncs().passthrough_enabled_fn(draw_customdata)) {
475 if (oxr_->passthrough_supported) {
476 layers.push_back((XrCompositionLayerBaseHeader *)&oxr_->passthrough_layer);
479 context_->getCustomFuncs().disable_passthrough_fn(draw_customdata);
483 if (draw_info_->frame_state.shouldRender) {
484 proj_layer = drawLayer(projection_layer_views, draw_customdata);
485 if (layers.size() > 0) {
486 proj_layer.layerFlags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT;
488 layers.push_back(
reinterpret_cast<XrCompositionLayerBaseHeader *
>(&proj_layer));
491 endFrameDrawing(layers);
499 r_info.fov.angle_left = view.fov.angleLeft;
500 r_info.fov.angle_right = view.fov.angleRight;
501 r_info.fov.angle_up = view.fov.angleUp;
502 r_info.fov.angle_down = view.fov.angleDown;
506 XrSwapchainImageBaseHeader &swapchain_image,
507 XrCompositionLayerProjectionView &r_proj_layer_view,
508 const XrSpaceLocation &view_location,
511 void *draw_customdata)
513 r_proj_layer_view.type = XR_TYPE_COMPOSITION_LAYER_PROJECTION_VIEW;
514 r_proj_layer_view.pose = view.pose;
515 r_proj_layer_view.fov = view.fov;
519 GHOST_XrDrawViewInfo draw_view_info = {};
520 draw_view_info.view_idx = char(view_idx);
521 draw_view_info.swapchain_format = swapchain.
getFormat();
522 draw_view_info.gpu_swapchain_format = swapchain.
getGPUFormat();
523 draw_view_info.expects_srgb_buffer = swapchain.
isBufferSRGB();
524 draw_view_info.ofsx = r_proj_layer_view.subImage.imageRect.offset.x;
525 draw_view_info.ofsy = r_proj_layer_view.subImage.imageRect.offset.y;
526 draw_view_info.width = r_proj_layer_view.subImage.imageRect.extent.width;
527 draw_view_info.height = r_proj_layer_view.subImage.imageRect.extent.height;
532 context_->getCustomFuncs().draw_view_fn(&draw_view_info, draw_customdata);
533 gpu_binding_->submitToSwapchainImage(swapchain_image, draw_view_info);
536XrCompositionLayerProjection GHOST_XrSession::drawLayer(
537 std::vector<XrCompositionLayerProjectionView> &r_proj_layer_views,
void *draw_customdata)
539 XrViewLocateInfo viewloc_info = {XR_TYPE_VIEW_LOCATE_INFO};
540 XrViewLocateFoveatedRenderingVARJO foveated_info{
541 XR_TYPE_VIEW_LOCATE_FOVEATED_RENDERING_VARJO,
nullptr,
true};
542 XrViewState view_state = {XR_TYPE_VIEW_STATE};
543 XrCompositionLayerProjection
layer = {XR_TYPE_COMPOSITION_LAYER_PROJECTION};
544 XrSpaceLocation view_location{XR_TYPE_SPACE_LOCATION};
547 viewloc_info.viewConfigurationType = oxr_->view_type;
548 viewloc_info.displayTime = draw_info_->frame_state.predictedDisplayTime;
549 viewloc_info.space = oxr_->reference_space;
551 if (draw_info_->foveation_active) {
552 viewloc_info.next = &foveated_info;
555 CHECK_XR(xrLocateViews(oxr_->session,
561 "Failed to query frame view and projection state.");
563 assert(oxr_->swapchains.size() == view_count);
566 oxr_->view_space, oxr_->reference_space, viewloc_info.displayTime, &view_location),
567 "Failed to query frame view space");
569 r_proj_layer_views.resize(view_count);
570 std::vector<XrSwapchainImageBaseHeader *> swapchain_images;
571 swapchain_images.resize(view_count);
573 for (uint32_t view_idx = 0; view_idx < view_count; view_idx++) {
574 GHOST_XrSwapchain &swapchain = oxr_->swapchains[view_idx];
578 gpu_binding_->submitToSwapchainBegin();
579 for (uint32_t view_idx = 0; view_idx < view_count; view_idx++) {
580 GHOST_XrSwapchain &swapchain = oxr_->swapchains[view_idx];
581 XrSwapchainImageBaseHeader &swapchain_image = *swapchain_images[view_idx];
584 r_proj_layer_views[view_idx],
586 oxr_->views[view_idx],
590 gpu_binding_->submitToSwapchainEnd();
592 for (uint32_t view_idx = 0; view_idx < view_count; view_idx++) {
593 GHOST_XrSwapchain &swapchain = oxr_->swapchains[view_idx];
595 swapchain_images[view_idx] =
nullptr;
598 layer.space = oxr_->reference_space;
599 layer.viewCount = r_proj_layer_views.size();
600 layer.views = r_proj_layer_views.data();
607 return gpu_binding_ && gpu_binding_->needsUpsideDownDrawing(*gpu_ctx_);
618 if (oxr_->session == XR_NULL_HANDLE) {
621 switch (oxr_->session_state) {
622 case XR_SESSION_STATE_READY:
623 case XR_SESSION_STATE_SYNCHRONIZED:
624 case XR_SESSION_STATE_VISIBLE:
625 case XR_SESSION_STATE_FOCUSED:
644void GHOST_XrSession::bindGraphicsContext()
669 std::map<std::string, GHOST_XrActionSet>::iterator it = oxr->
action_sets.find(action_set_name);
678 std::map<std::string, GHOST_XrActionSet> &action_sets = oxr_->action_sets;
679 if (action_sets.find(info.name) != action_sets.end()) {
683 XrInstance instance = context_->getInstance();
686 std::piecewise_construct, std::make_tuple(info.name), std::make_tuple(instance, info));
693 std::map<std::string, GHOST_XrActionSet> &action_sets = oxr_->action_sets;
695 action_sets.erase(action_set_name);
700 const GHOST_XrActionInfo *infos)
703 if (action_set ==
nullptr) {
707 XrInstance instance = context_->getInstance();
709 for (uint32_t i = 0; i < count; ++i) {
720 const char *
const *action_names)
723 if (action_set ==
nullptr) {
727 for (uint32_t i = 0; i < count; ++i) {
734 const GHOST_XrActionProfileInfo *infos)
737 if (action_set ==
nullptr) {
741 XrInstance instance = context_->getInstance();
742 XrSession session = oxr_->session;
744 for (uint32_t profile_idx = 0; profile_idx < count; ++profile_idx) {
745 const GHOST_XrActionProfileInfo &info = infos[profile_idx];
748 if (action ==
nullptr) {
760 const char *
const *action_names,
761 const char *
const *profile_paths)
764 if (action_set ==
nullptr) {
768 for (uint32_t i = 0; i < count; ++i) {
770 if (action ==
nullptr) {
781 std::map<XrPath, std::vector<XrActionSuggestedBinding>> profile_bindings;
782 for (
auto &[name, action_set] : oxr_->action_sets) {
783 action_set.getBindings(profile_bindings);
786 if (profile_bindings.size() < 1) {
790 XrInteractionProfileSuggestedBinding bindings_info{
791 XR_TYPE_INTERACTION_PROFILE_SUGGESTED_BINDING};
792 XrInstance instance = context_->getInstance();
794 for (
auto &[profile, bindings] : profile_bindings) {
795 bindings_info.interactionProfile = profile;
796 bindings_info.countSuggestedBindings = uint32_t(bindings.size());
797 bindings_info.suggestedBindings = bindings.data();
799 CHECK_XR(xrSuggestInteractionProfileBindings(instance, &bindings_info),
800 "Failed to suggest interaction profile bindings.");
804 XrSessionActionSetsAttachInfo attach_info{XR_TYPE_SESSION_ACTION_SETS_ATTACH_INFO};
805 attach_info.countActionSets = uint32_t(oxr_->action_sets.size());
808 std::vector<XrActionSet> action_sets(attach_info.countActionSets);
810 for (
auto &[name, action_set] : oxr_->action_sets) {
811 action_sets[i++] = action_set.getActionSet();
813 attach_info.actionSets = action_sets.data();
815 CHECK_XR(xrAttachSessionActionSets(oxr_->session, &attach_info),
816 "Failed to attach XR action sets.");
823 std::map<std::string, GHOST_XrActionSet> &action_sets = oxr_->action_sets;
825 XrActionsSyncInfo sync_info{XR_TYPE_ACTIONS_SYNC_INFO};
826 sync_info.countActiveActionSets = (action_set_name !=
nullptr) ? 1 :
827 uint32_t(action_sets.size());
828 if (sync_info.countActiveActionSets < 1) {
832 std::vector<XrActiveActionSet> active_action_sets(sync_info.countActiveActionSets);
835 if (action_set_name !=
nullptr) {
837 if (action_set ==
nullptr) {
841 XrActiveActionSet &active_action_set = active_action_sets[0];
842 active_action_set.actionSet = action_set->
getActionSet();
843 active_action_set.subactionPath = XR_NULL_PATH;
847 for (
auto &[name, action_set] : action_sets) {
848 XrActiveActionSet &active_action_set = active_action_sets[i++];
849 active_action_set.actionSet = action_set.
getActionSet();
850 active_action_set.subactionPath = XR_NULL_PATH;
853 sync_info.activeActionSets = active_action_sets.data();
855 CHECK_XR(xrSyncActions(oxr_->session, &sync_info),
"Failed to synchronize XR actions.");
858 XrSession session = oxr_->session;
859 XrSpace reference_space = oxr_->reference_space;
860 const XrTime &predicted_display_time = draw_info_->frame_state.predictedDisplayTime;
862 if (action_set !=
nullptr) {
863 action_set->
updateStates(session, reference_space, predicted_display_time);
866 for (
auto &[name, action_set] : action_sets) {
867 action_set.
updateStates(session, reference_space, predicted_display_time);
875 const char *action_name,
876 const char *subaction_path,
879 const float &litude)
882 if (action_set ==
nullptr) {
887 if (action ==
nullptr) {
892 oxr_->session, action_name, subaction_path, duration,
frequency, amplitude);
898 const char *action_name,
899 const char *subaction_path)
902 if (action_set ==
nullptr) {
907 if (action ==
nullptr) {
917 if (action_set ==
nullptr) {
927 if (action_set ==
nullptr) {
932 if (action ==
nullptr) {
942 if (action_set ==
nullptr) {
950 void **r_customdata_array)
953 if (action_set ==
nullptr) {
969 if (!context_->isExtensionEnabled(XR_MSFT_CONTROLLER_MODEL_EXTENSION_NAME)) {
973 XrSession session = oxr_->session;
974 std::map<std::string, GHOST_XrControllerModel> &controller_models = oxr_->controller_models;
975 std::map<std::string, GHOST_XrControllerModel>::iterator it = controller_models.find(
978 if (it == controller_models.end()) {
979 XrInstance instance = context_->getInstance();
980 it = controller_models
981 .emplace(std::piecewise_construct,
982 std::make_tuple(subaction_path),
983 std::make_tuple(instance, subaction_path))
987 it->second.load(session);
994 std::map<std::string, GHOST_XrControllerModel> &controller_models = oxr_->controller_models;
996 controller_models.erase(subaction_path);
1001 XrSession session = oxr_->session;
1002 std::map<std::string, GHOST_XrControllerModel>::iterator it = oxr_->controller_models.find(
1004 if (it == oxr_->controller_models.end()) {
1008 it->second.updateComponents(session);
1014 GHOST_XrControllerModelData &r_data)
1016 std::map<std::string, GHOST_XrControllerModel>::iterator it = oxr_->controller_models.find(
1018 if (it == oxr_->controller_models.end()) {
1022 it->second.getData(r_data);
1055void GHOST_XrSession::enablePassthrough()
1057 oxr_->passthrough_supported =
false;
1059 if (!context_->isExtensionEnabled(XR_FB_PASSTHROUGH_EXTENSION_NAME)) {
1063 if (oxr_->passthrough_layer.layerHandle != XR_NULL_HANDLE) {
1064 oxr_->passthrough_supported =
true;
1070 XrPassthroughCreateInfoFB passthrough_create_info = {};
1071 passthrough_create_info.type = XR_TYPE_PASSTHROUGH_CREATE_INFO_FB;
1072 passthrough_create_info.next =
nullptr;
1073 passthrough_create_info.flags |= XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB;
1075 XrPassthroughFB passthrough_handle;
1082 XrPassthroughLayerCreateInfoFB passthrough_layer_create_info = {};
1083 passthrough_layer_create_info.type = XR_TYPE_PASSTHROUGH_LAYER_CREATE_INFO_FB;
1084 passthrough_layer_create_info.next =
nullptr;
1085 passthrough_layer_create_info.passthrough = passthrough_handle;
1086 passthrough_layer_create_info.flags |= XR_PASSTHROUGH_IS_RUNNING_AT_CREATION_BIT_FB;
1087 passthrough_layer_create_info.purpose = XR_PASSTHROUGH_LAYER_PURPOSE_RECONSTRUCTION_FB;
1089 XrPassthroughLayerFB passthrough_layer_handle;
1091 oxr_->session, &passthrough_layer_create_info, &passthrough_layer_handle)))
1099 oxr_->passthrough_layer.type = XR_TYPE_COMPOSITION_LAYER_PASSTHROUGH_FB;
1100 oxr_->passthrough_layer.next =
nullptr;
1101 oxr_->passthrough_layer.flags = XR_COMPOSITION_LAYER_BLEND_TEXTURE_SOURCE_ALPHA_BIT;
1102 oxr_->passthrough_layer.space = XR_NULL_HANDLE;
1103 oxr_->passthrough_layer.layerHandle = passthrough_layer_handle;
1105 oxr_->passthrough_supported =
true;
#define CLOG_WARN(clg_ref,...)
#define CLOG_INFO(clg_ref,...)
std::unique_ptr< GHOST_IXrGraphicsBinding > GHOST_XrGraphicsBindingCreateFromType(GHOST_TXrGraphicsBinding type, GHOST_Context &context)
static void init_passthrough_extension_functions(XrInstance instance)
static void print_debug_timings(GHOST_XrDrawInfo &draw_info)
static void ghost_xr_draw_view_info_from_view(const XrView &view, GHOST_XrDrawViewInfo &r_info)
static PFN_xrCreatePassthroughLayerFB g_xrCreatePassthroughLayerFB
static PFN_xrPassthroughLayerResumeFB g_xrPassthroughLayerResumeFB
static void create_main_reference_space(OpenXRSessionData &oxr, const blender::Span< XrReferenceSpaceType > supported_spaces)
static PFN_xrCreatePassthroughFB g_xrCreatePassthroughFB
static void create_reference_spaces(OpenXRSessionData &oxr)
static PFN_xrPassthroughStartFB g_xrPassthroughStartFB
static GHOST_XrActionSet * find_action_set(OpenXRSessionData *oxr, const char *action_set_name)
CLG_LogRef * LOG_GHOST_XR
void copy_openxr_pose_to_ghost_pose(const XrPosef &oxr_pose, GHOST_XrPose &r_ghost_pose)
#define INIT_EXTENSION_FUNCTION(name)
#define CHECK_XR_ASSERT(call)
#define CHECK_XR(call, error_msg)
void updateStates(XrSession session, XrSpace reference_space, const XrTime &predicted_display_time)
GHOST_XrAction * findAction(const char *action_name)
bool createAction(XrInstance instance, const GHOST_XrActionInfo &info)
XrActionSet getActionSet() const
void getActionCustomdataArray(void **r_customdata_array)
uint32_t getActionCount() const
void destroyAction(const char *action_name)
bool createBinding(XrInstance instance, XrSession session, const GHOST_XrActionProfileInfo &info)
void destroyBinding(const char *profile_path)
void applyHapticFeedback(XrSession session, const char *action_name, const char *subaction_path_str, const int64_t &duration, const float &frequency, const float &litude)
void stopHapticFeedback(XrSession session, const char *action_name, const char *subaction_path_str)
Main GHOST container to manage OpenXR through.
XrInstance getInstance() const
const GHOST_XrCustomFuncs & getCustomFuncs() const
bool isExtensionEnabled(const char *ext) const
GHOST_XrException(const char *msg, int result=0)
void destroyActionBindings(const char *action_set_name, uint32_t count, const char *const *action_names, const char *const *profile_paths)
void destroyActionSet(const char *action_set_name)
void draw(void *draw_customdata)
bool createActionSet(const GHOST_XrActionSetInfo &info)
void * getActionCustomdata(const char *action_set_name, const char *action_name)
void unloadControllerModel(const char *subaction_path)
void * getActionSetCustomdata(const char *action_set_name)
bool updateControllerModelComponents(const char *subaction_path)
bool createActionBindings(const char *action_set_name, uint32_t count, const GHOST_XrActionProfileInfo *infos)
GHOST_XrSession(GHOST_XrContext &xr_context)
void stopHapticAction(const char *action_set_name, const char *action_name, const char *subaction_path)
LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle)
void getActionCustomdataArray(const char *action_set_name, void **r_customdata_array)
bool loadControllerModel(const char *subaction_path)
bool syncActions(const char *action_set_name=nullptr)
bool needsUpsideDownDrawing() const
void destroyActions(const char *action_set_name, uint32_t count, const char *const *action_names)
void unbindGraphicsContext()
bool applyHapticAction(const char *action_set_name, const char *action_name, const char *subaction_path, const int64_t &duration, const float &frequency, const float &litude)
uint32_t getActionCount(const char *action_set_name)
bool getControllerModelData(const char *subaction_path, GHOST_XrControllerModelData &r_data)
bool createActions(const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos)
int64_t getGPUFormat() const
return the swapchain format selected by the graphic binding.
GHOST_TXrSwapchainFormat getFormat() const
void updateCompositionLayerProjectViewSubImage(XrSwapchainSubImage &r_sub_image)
bool isBufferSRGB() const
XrSwapchainImageBaseHeader * acquireDrawableSwapchainImage()
constexpr bool contains(const T &value) const
#define assert(assertion)
GHOST_XrGraphicsContextUnbindFn gpu_ctx_unbind_fn
GHOST_XrGraphicsContextBindFn gpu_ctx_bind_fn
std::chrono::high_resolution_clock::time_point frame_begin_time
std::list< double > last_frame_times
XrSpace combined_eye_space
XrCompositionLayerPassthroughFB passthrough_layer
std::map< std::string, GHOST_XrControllerModel > controller_models
bool passthrough_supported
XrViewConfigurationType view_type
std::map< std::string, GHOST_XrActionSet > action_sets
XrSessionState session_state
std::vector< GHOST_XrSwapchain > swapchains
std::vector< XrView > views