Blender V5.3
GHOST_Xr.cc File Reference
#include "GHOST_XrContext.hh"
#include "GHOST_XrException.hh"
#include "GHOST_XrSession.hh"
#include "GHOST_Xr-api.hh"

Go to the source code of this file.

Macros

#define GHOST_XR_CAPI_CALL(call, ctx)
#define GHOST_XR_CAPI_CALL_RET(call, ctx)

Functions

 CLG_LOGREF_DECLARE_GLOBAL (LOG_GHOST_XR, "ghost.xr")
void GHOST_XrErrorHandler (GHOST_XrErrorHandlerFn handler_fn, void *customdata)
GHOST_IXrContext * GHOST_XrContextCreate (const GHOST_XrContextCreateInfo *create_info)
 Initialize the Ghost XR-context.
void GHOST_XrContextDestroy (GHOST_IXrContext *xr_context)
void GHOST_XrSessionStart (GHOST_IXrContext *xr_context, const GHOST_XrSessionBeginInfo *begin_info)
void GHOST_XrSessionEnd (GHOST_IXrContext *xr_context)
void GHOST_XrSessionDrawViews (GHOST_IXrContext *xr_context, void *draw_customdata)
int GHOST_XrSessionIsRunning (const GHOST_IXrContext *xr_context)
void GHOST_XrGraphicsContextBindFuncs (GHOST_IXrContext *xr_context, GHOST_XrGraphicsContextBindFn bind_fn, GHOST_XrGraphicsContextUnbindFn unbind_fn)
void GHOST_XrDrawViewFunc (GHOST_IXrContext *xr_context, GHOST_XrDrawViewFn draw_view_fn)
void GHOST_XrPassthroughEnabledFunc (GHOST_IXrContext *xr_context, GHOST_XrPassthroughEnabledFn passthrough_enabled_fn)
void GHOST_XrDisablePassthroughFunc (GHOST_IXrContext *xr_context, GHOST_XrDisablePassthroughFn disable_passthrough_fn)
int GHOST_XrSessionNeedsUpsideDownDrawing (const GHOST_IXrContext *xr_context)
int GHOST_XrCreateActionSet (GHOST_IXrContext *xr_context, const GHOST_XrActionSetInfo *info)
void GHOST_XrDestroyActionSet (GHOST_IXrContext *xr_context, const char *action_set_name)
int GHOST_XrCreateActions (GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const GHOST_XrActionInfo *infos)
void GHOST_XrDestroyActions (GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const char *const *action_names)
int GHOST_XrCreateActionBindings (GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const GHOST_XrActionProfileInfo *infos)
void GHOST_XrDestroyActionBindings (GHOST_IXrContext *xr_context, const char *action_set_name, uint32_t count, const char *const *action_names, const char *const *profile_paths)
int GHOST_XrAttachActionSets (GHOST_IXrContext *xr_context)
int GHOST_XrSyncActions (GHOST_IXrContext *xr_context, const char *action_set_name)
int GHOST_XrApplyHapticAction (GHOST_IXrContext *xr_context, const char *action_set_name, const char *action_name, const char *subaction_path, const int64_t *duration, const float *frequency, const float *amplitude)
void GHOST_XrStopHapticAction (GHOST_IXrContext *xr_context, const char *action_set_name, const char *action_name, const char *subaction_path)
void * GHOST_XrGetActionSetCustomdata (GHOST_IXrContext *xr_context, const char *action_set_name)
void * GHOST_XrGetActionCustomdata (GHOST_IXrContext *xr_context, const char *action_set_name, const char *action_name)
uint GHOST_XrGetActionCount (GHOST_IXrContext *xr_context, const char *action_set_name)
void GHOST_XrGetActionCustomdataArray (GHOST_IXrContext *xr_context, const char *action_set_name, void **r_customdata_array)
int GHOST_XrLoadControllerModel (GHOST_IXrContext *xr_context, const char *subaction_path)
void GHOST_XrUnloadControllerModel (GHOST_IXrContext *xr_context, const char *subaction_path)
int GHOST_XrUpdateControllerModelComponents (GHOST_IXrContext *xr_context, const char *subaction_path)
int GHOST_XrGetControllerModelData (GHOST_IXrContext *xr_context, const char *subaction_path, GHOST_XrControllerModelData *r_data)

Detailed Description

Abstraction for XR (VR, AR, MR, ..) access via OpenXR.

Definition in file GHOST_Xr.cc.

Macro Definition Documentation

◆ GHOST_XR_CAPI_CALL

◆ GHOST_XR_CAPI_CALL_RET

Function Documentation

◆ CLG_LOGREF_DECLARE_GLOBAL()

CLG_LOGREF_DECLARE_GLOBAL ( LOG_GHOST_XR ,
"ghost.xr"  )

◆ GHOST_XrApplyHapticAction()

int GHOST_XrApplyHapticAction ( GHOST_IXrContext * xr_context_handle,
const char * action_set_name,
const char * action_name,
const char * subaction_path,
const int64_t * duration,
const float * frequency,
const float * amplitude )

◆ GHOST_XrAttachActionSets()

int GHOST_XrAttachActionSets ( GHOST_IXrContext * xr_context)

Attach all created action sets to the current OpenXR session.

Definition at line 169 of file GHOST_Xr.cc.

References GHOST_XrSession::attachActionSets(), GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL_RET, and GHOST_XrAttachActionSets().

Referenced by GHOST_XrAttachActionSets(), and blender::wm_xr_session_actions_init().

◆ GHOST_XrContextCreate()

GHOST_IXrContext * GHOST_XrContextCreate ( const GHOST_XrContextCreateInfo * create_info)

Initialize the Ghost XR-context.

Includes setting up the OpenXR runtime link, querying available extensions and API layers, enabling extensions and API layers.

Parameters
create_infoOptions for creating the XR-context, e.g. debug-flags and ordered array of graphics bindings to try enabling.

Definition at line 40 of file GHOST_Xr.cc.

References GHOST_XrContextCreate().

Referenced by GHOST_XrContextCreate(), and blender::wm_xr_init().

◆ GHOST_XrContextDestroy()

void GHOST_XrContextDestroy ( GHOST_IXrContext * xr_context)

Free a XR-context involving OpenXR runtime link destruction and freeing of all internal data.

Definition at line 58 of file GHOST_Xr.cc.

References GHOST_XrContextDestroy().

Referenced by GHOST_XrContextDestroy(), GHOST_XrEventsHandle(), and blender::wm_xr_runtime_data_free().

◆ GHOST_XrCreateActionBindings()

int GHOST_XrCreateActionBindings ( GHOST_IXrContext * xr_context,
const char * action_set_name,
uint32_t count,
const GHOST_XrActionProfileInfo * infos )

◆ GHOST_XrCreateActions()

int GHOST_XrCreateActions ( GHOST_IXrContext * xr_context,
const char * action_set_name,
uint32_t count,
const GHOST_XrActionInfo * infos )

◆ GHOST_XrCreateActionSet()

int GHOST_XrCreateActionSet ( GHOST_IXrContext * xr_context,
const GHOST_XrActionSetInfo * info )

◆ GHOST_XrDestroyActionBindings()

void GHOST_XrDestroyActionBindings ( GHOST_IXrContext * xr_context,
const char * action_set_name,
uint32_t count,
const char *const * action_names,
const char *const * profile_paths )

◆ GHOST_XrDestroyActions()

void GHOST_XrDestroyActions ( GHOST_IXrContext * xr_context,
const char * action_set_name,
uint32_t count,
const char *const * action_names )

Destroy previously created OpenXR actions.

Definition at line 137 of file GHOST_Xr.cc.

References GHOST_XrSession::destroyActions(), GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL, and GHOST_XrDestroyActions().

Referenced by GHOST_XrDestroyActions(), and blender::WM_xr_action_destroy().

◆ GHOST_XrDestroyActionSet()

void GHOST_XrDestroyActionSet ( GHOST_IXrContext * xr_context,
const char * action_set_name )

Destroy a previously created OpenXR action set.

Definition at line 121 of file GHOST_Xr.cc.

References GHOST_XrSession::destroyActionSet(), GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL, and GHOST_XrDestroyActionSet().

Referenced by GHOST_XrDestroyActionSet(), and blender::WM_xr_action_set_destroy().

◆ GHOST_XrDisablePassthroughFunc()

void GHOST_XrDisablePassthroughFunc ( GHOST_IXrContext * xr_context,
GHOST_XrDisablePassthroughFn disable_passthrough_fn )

Set the callback to force disable passthrough in case it is not supported. Called in GHOST_XrSession::draw().

Parameters
disable_passthrough_fnThe callback to disable passthrough.

Definition at line 102 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL, GHOST_XrDisablePassthroughFunc(), and GHOST_IXrContext::setDisablePassthroughFunc().

Referenced by GHOST_XrDisablePassthroughFunc(), and blender::wm_xr_init().

◆ GHOST_XrDrawViewFunc()

void GHOST_XrDrawViewFunc ( GHOST_IXrContext * xr_context,
GHOST_XrDrawViewFn draw_view_fn )

Set the drawing callback for views. A view would typically be either the left or the right eye, although other configurations are possible. When GHOST_XrSessionDrawViews() is called to draw an XR frame, draw_view_fn is executed for each view.

Parameters
draw_view_fnThe callback to draw a single view for an XR frame.

Definition at line 91 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL, GHOST_XrDrawViewFunc(), and GHOST_IXrContext::setDrawViewFunc().

Referenced by GHOST_XrDrawViewFunc(), and blender::wm_xr_init().

◆ GHOST_XrErrorHandler()

void GHOST_XrErrorHandler ( GHOST_XrErrorHandlerFn handler_fn,
void * customdata )

Set a custom callback to be executed whenever an error occurs. Should be set before calling GHOST_XrContextCreate() to get error handling during context creation too.

Parameters
customdataHandle to some data that will get passed to handler_fn should an error be thrown.

Definition at line 35 of file GHOST_Xr.cc.

References GHOST_XrErrorHandler(), and GHOST_XrContext::setErrorHandler().

Referenced by GHOST_XrErrorHandler(), and blender::wm_xr_init().

◆ GHOST_XrGetActionCount()

uint GHOST_XrGetActionCount ( GHOST_IXrContext * xr_context,
const char * action_set_name )

◆ GHOST_XrGetActionCustomdata()

void * GHOST_XrGetActionCustomdata ( GHOST_IXrContext * xr_context,
const char * action_set_name,
const char * action_name )

◆ GHOST_XrGetActionCustomdataArray()

void GHOST_XrGetActionCustomdataArray ( GHOST_IXrContext * xr_context,
const char * action_set_name,
void ** r_customdata_array )

◆ GHOST_XrGetActionSetCustomdata()

void * GHOST_XrGetActionSetCustomdata ( GHOST_IXrContext * xr_context,
const char * action_set_name )

Get action set custom data (owned by Blender, not GHOST).

Definition at line 209 of file GHOST_Xr.cc.

References GHOST_XrSession::getActionSetCustomdata(), GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL_RET, and GHOST_XrGetActionSetCustomdata().

Referenced by blender::action_set_find(), and GHOST_XrGetActionSetCustomdata().

◆ GHOST_XrGetControllerModelData()

int GHOST_XrGetControllerModelData ( GHOST_IXrContext * xr_context,
const char * subaction_path,
GHOST_XrControllerModelData * r_data )

◆ GHOST_XrGraphicsContextBindFuncs()

void GHOST_XrGraphicsContextBindFuncs ( GHOST_IXrContext * xr_context,
GHOST_XrGraphicsContextBindFn bind_fn,
GHOST_XrGraphicsContextUnbindFn unbind_fn )

Set callbacks for binding and unbinding a graphics context for a session. The binding callback may create a new graphics context thereby. In fact that's the sole reason for this callback approach to binding. Just make sure to have an unbind function set that properly destructs.

Parameters
bind_fnFunction to retrieve (possibly create) a graphics context.
unbind_fnFunction to release (possibly free) a graphics context.

Definition at line 84 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL, GHOST_XrGraphicsContextBindFuncs(), and GHOST_IXrContext::setGraphicsContextBindFuncs().

Referenced by GHOST_XrGraphicsContextBindFuncs(), and blender::wm_xr_init().

◆ GHOST_XrLoadControllerModel()

int GHOST_XrLoadControllerModel ( GHOST_IXrContext * xr_context,
const char * subaction_path )

◆ GHOST_XrPassthroughEnabledFunc()

void GHOST_XrPassthroughEnabledFunc ( GHOST_IXrContext * xr_context,
GHOST_XrPassthroughEnabledFn passthrough_enabled_fn )

Set the callback to check if passthrough is enabled. If enabled, the passthrough composition layer is added in GHOST_XrSession::draw().

Parameters
passthrough_enabled_fnThe callback to check if passthrough is enabled.

Definition at line 96 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL, GHOST_XrPassthroughEnabledFunc(), and GHOST_IXrContext::setPassthroughEnabledFunc().

Referenced by GHOST_XrPassthroughEnabledFunc(), and blender::wm_xr_init().

◆ GHOST_XrSessionDrawViews()

void GHOST_XrSessionDrawViews ( GHOST_IXrContext * xr_context,
void * customdata )

Draw a single frame by calling the view drawing callback defined by GHOST_XrDrawViewFunc() for each view and submit it to the OpenXR runtime.

Parameters
customdataHandle to some data that will get passed to the view drawing callback.

Definition at line 73 of file GHOST_Xr.cc.

References GHOST_IXrContext::drawSessionViews(), GHOST_XR_CAPI_CALL, and GHOST_XrSessionDrawViews().

Referenced by GHOST_XrSessionDrawViews(), and blender::wm_xr_session_surface_draw().

◆ GHOST_XrSessionEnd()

void GHOST_XrSessionEnd ( GHOST_IXrContext * xr_context)

Destruct internal session data for xr_context and ask the OpenXR runtime to stop a session.

Definition at line 68 of file GHOST_Xr.cc.

References GHOST_IXrContext::endSession(), GHOST_XR_CAPI_CALL, and GHOST_XrSessionEnd().

Referenced by GHOST_XrSessionEnd(), and blender::wm_xr_session_toggle().

◆ GHOST_XrSessionIsRunning()

int GHOST_XrSessionIsRunning ( const GHOST_IXrContext * xr_context)

Check if a xr_context has a session that, according to the OpenXR definition would be considered to be 'running' (https://www.khronos.org/registry/OpenXR/specs/1.0/html/xrspec.html#session_running).

Definition at line 78 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL_RET, GHOST_XrSessionIsRunning(), and GHOST_IXrContext::isSessionRunning().

Referenced by GHOST_XrSessionIsRunning(), and blender::WM_xr_session_is_ready().

◆ GHOST_XrSessionNeedsUpsideDownDrawing()

int GHOST_XrSessionNeedsUpsideDownDrawing ( const GHOST_IXrContext * xr_context)

Check if xr_context has a session that requires an upside-down frame-buffer (compared to GPU). If true, the render result should be flipped vertically for correct output.

Note
Only to be called after session start, may otherwise result in a false negative.

Definition at line 108 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL_RET, GHOST_XrSessionNeedsUpsideDownDrawing(), and GHOST_IXrContext::needsUpsideDownDrawing().

Referenced by GHOST_XrSessionNeedsUpsideDownDrawing(), and blender::wm_xr_draw_viewport_buffers_to_active_framebuffer().

◆ GHOST_XrSessionStart()

void GHOST_XrSessionStart ( GHOST_IXrContext * xr_context,
const GHOST_XrSessionBeginInfo * begin_info )

Create internal session data for xr_context and ask the OpenXR runtime to invoke a session.

Parameters
begin_infoOptions for the session creation.

Definition at line 63 of file GHOST_Xr.cc.

References GHOST_XR_CAPI_CALL, GHOST_XrSessionStart(), and GHOST_IXrContext::startSession().

Referenced by GHOST_XrSessionStart(), and blender::wm_xr_session_toggle().

◆ GHOST_XrStopHapticAction()

void GHOST_XrStopHapticAction ( GHOST_IXrContext * xr_context_handle,
const char * action_set_name,
const char * action_name,
const char * subaction_path )

Stop a previously applied OpenXR haptic output action.

Definition at line 199 of file GHOST_Xr.cc.

References GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL, GHOST_XrStopHapticAction(), and GHOST_XrSession::stopHapticAction().

Referenced by GHOST_XrStopHapticAction(), and blender::WM_xr_haptic_action_stop().

◆ GHOST_XrSyncActions()

int GHOST_XrSyncActions ( GHOST_IXrContext * xr_context,
const char * action_set_name )

Update button/tracking states for OpenXR actions.

Parameters
action_set_nameThe name of the action set to sync. If nullptr, all action sets attached to the session will be synced.

Definition at line 176 of file GHOST_Xr.cc.

References GHOST_IXrContext::getSession(), GHOST_XR_CAPI_CALL_RET, GHOST_XrSyncActions(), and GHOST_XrSession::syncActions().

Referenced by GHOST_XrSyncActions(), and blender::wm_xr_session_actions_update().

◆ GHOST_XrUnloadControllerModel()

void GHOST_XrUnloadControllerModel ( GHOST_IXrContext * xr_context,
const char * subaction_path )

◆ GHOST_XrUpdateControllerModelComponents()

int GHOST_XrUpdateControllerModelComponents ( GHOST_IXrContext * xr_context,
const char * subaction_path )