Monado OpenXR Runtime
client_gl_compositor Class Reference

Wraps the real compositor providing a OpenGL based interface. More...

#include <client/comp_gl_client.h>

Inheritance diagram for client_gl_compositor:
Collaboration diagram for client_gl_compositor:

Public Member Functions

bool client_gl_compositor_init (struct client_gl_compositor *c, struct xrt_compositor_native *xcn, client_gl_context_begin_locked_func_t context_begin, client_gl_context_end_locked_func_t context_end, client_gl_swapchain_create_func_t create_swapchain, client_gl_insert_fence_func_t insert_fence)
 Fill in a client_gl_compositor and do common OpenGL readiness checking. More...
 
void client_gl_compositor_close (struct client_gl_compositor *c)
 Free all resources from the client_gl_compositor, does not free the client_gl_compositor itself. More...
 
static xrt_result_t client_gl_compositor_context_begin (struct xrt_compositor *xc, enum client_gl_context_reason reason)
 Fetches the OpenGL context that is current on this thread and makes the OpenGL context given in the graphics binding current instead. More...
 
static void client_gl_compositor_context_end (struct xrt_compositor *xc, enum client_gl_context_reason reason)
 Makes the OpenGL context current that was current before client_gl_context_begin_locked_func_t was called. More...
 
- Public Member Functions inherited from xrt_compositor
static xrt_result_t xrt_comp_get_swapchain_create_properties (struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_create_properties *xsccp)
 For a given xrt_swapchain_create_info struct returns a filled out xrt_swapchain_create_properties. More...
 
static xrt_result_t xrt_comp_create_passthrough (struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
 Create a passthrough. More...
 
static xrt_result_t xrt_comp_create_passthrough_layer (struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
 Create a passthrough layer. More...
 
static xrt_result_t xrt_comp_destroy_passthrough (struct xrt_compositor *xc)
 Destroy a passthrough. More...
 
static xrt_result_t xrt_comp_get_display_refresh_rate (struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
 Get the current display refresh rate. More...
 
static xrt_result_t xrt_comp_request_display_refresh_rate (struct xrt_compositor *xc, float display_refresh_rate_hz)
 Request system to change the display refresh rate to the requested value. More...
 
static xrt_result_t xrt_comp_set_performance_level (struct xrt_compositor *xc, enum xrt_perf_domain domain, enum xrt_perf_set_level level)
 Set CPU/GPU performance level. More...
 
static void xrt_comp_destroy (struct xrt_compositor **xc_ptr)
 Teardown the compositor. More...
 
static xrt_result_t xrt_comp_create_swapchain (struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
 Create a swapchain with a set of images. More...
 
static xrt_result_t xrt_comp_import_swapchain (struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_image_native *native_images, uint32_t image_count, struct xrt_swapchain **out_xsc)
 Create a swapchain from a set of native images. More...
 
static xrt_result_t xrt_comp_import_fence (struct xrt_compositor *xc, xrt_graphics_sync_handle_t handle, struct xrt_compositor_fence **out_xcf)
 Create a compositor fence from a native sync handle. More...
 
static xrt_result_t xrt_comp_create_semaphore (struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle, struct xrt_compositor_semaphore **out_xcsem)
 Create a compositor semaphore, also returns a native handle. More...
 
static xrt_result_t xrt_comp_begin_session (struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
 See xrBeginSession. More...
 
static xrt_result_t xrt_comp_end_session (struct xrt_compositor *xc)
 See xrEndSession, unlike the OpenXR one the state tracker is responsible to call discard frame before calling this function. More...
 
static xrt_result_t xrt_comp_predict_frame (struct xrt_compositor *xc, int64_t *out_frame_id, uint64_t *out_wake_time_ns, uint64_t *out_predicted_gpu_time_ns, uint64_t *out_predicted_display_time_ns, uint64_t *out_predicted_display_period_ns)
 This function and mark_frame function calls are a alternative to wait_frame. More...
 
static xrt_result_t xrt_comp_mark_frame (struct xrt_compositor *xc, int64_t frame_id, enum xrt_compositor_frame_point point, uint64_t when_ns)
 This function and predict_frame function calls are a alternative to wait_frame. More...
 
static xrt_result_t xrt_comp_wait_frame (struct xrt_compositor *xc, int64_t *out_frame_id, uint64_t *out_predicted_display_time, uint64_t *out_predicted_display_period)
 See xrWaitFrame. More...
 
static xrt_result_t xrt_comp_begin_frame (struct xrt_compositor *xc, int64_t frame_id)
 See xrBeginFrame. More...
 
static xrt_result_t xrt_comp_discard_frame (struct xrt_compositor *xc, int64_t frame_id)
 Explicitly discard a frame. More...
 
static xrt_result_t xrt_comp_layer_begin (struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
 Begins layer submission. More...
 
static xrt_result_t xrt_comp_layer_projection (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 Adds a projection layer for submissions. More...
 
static xrt_result_t xrt_comp_layer_projection_depth (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 Adds a projection layer for submission, has depth information. More...
 
static xrt_result_t xrt_comp_layer_quad (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a quad layer for submission, the center of the quad is specified by the pose and extends outwards from it. More...
 
static xrt_result_t xrt_comp_layer_cube (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a cube layer for submission. More...
 
static xrt_result_t xrt_comp_layer_cylinder (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a cylinder layer for submission. More...
 
static xrt_result_t xrt_comp_layer_equirect1 (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a equirect1 layer for submission. More...
 
static xrt_result_t xrt_comp_layer_equirect2 (struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a equirect2 layer for submission. More...
 
static xrt_result_t xrt_comp_layer_passthrough (struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
 Adds a passthrough layer for submission. More...
 
static xrt_result_t xrt_comp_layer_commit (struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
 Commits all of the submitted layers. More...
 
static xrt_result_t xrt_comp_layer_commit_with_semaphore (struct xrt_compositor *xc, struct xrt_compositor_semaphore *xcsem, uint64_t value)
 Commits all of the submitted layers, with a semaphore. More...
 

Data Fields

struct xrt_compositor_gl base
 
struct xrt_compositor_nativexcn
 
client_gl_context_begin_locked_func_t context_begin_locked
 Function pointer for making the OpenGL context current. More...
 
client_gl_context_end_locked_func_t context_end_locked
 Function pointer for restoring prior OpenGL context. More...
 
client_gl_swapchain_create_func_t create_swapchain
 Function pointer for creating the client swapchain. More...
 
client_gl_insert_fence_func_t insert_fence
 Function pointer for inserting fences on xrt_compositor::layer_commit. More...
 
struct os_mutex context_mutex
 client_gl_xlib_compositor::app_context can only be current on one thread; block other threads while we know it is bound to a thread. More...
 
bool renderdoc_enabled
 
- Data Fields inherited from xrt_compositor_gl
struct xrt_compositor base
 
- Data Fields inherited from xrt_compositor
struct xrt_compositor_info info
 Capabilities and recommended values information. More...
 
xrt_result_t(* get_swapchain_create_properties )(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain_create_properties *xsccp)
 For a given xrt_swapchain_create_info struct returns a filled out xrt_swapchain_create_properties. More...
 
xrt_result_t(* create_passthrough )(struct xrt_compositor *xc, const struct xrt_passthrough_create_info *info)
 Create a passthrough. More...
 
xrt_result_t(* create_passthrough_layer )(struct xrt_compositor *xc, const struct xrt_passthrough_layer_create_info *info)
 Create a passthrough layer. More...
 
xrt_result_t(* destroy_passthrough )(struct xrt_compositor *xc)
 Destroy a passthrough. More...
 
xrt_result_t(* set_performance_level )(struct xrt_compositor *xc, enum xrt_perf_domain domain, enum xrt_perf_set_level level)
 Set CPU/GPU performance level. More...
 
void(* destroy )(struct xrt_compositor *xc)
 Teardown the compositor. More...
 
xrt_result_t(* create_swapchain )(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
 Create a swapchain with a set of images. More...
 
xrt_result_t(* import_swapchain )(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_image_native *native_images, uint32_t image_count, struct xrt_swapchain **out_xsc)
 Create a swapchain from a set of native images. More...
 
xrt_result_t(* import_fence )(struct xrt_compositor *xc, xrt_graphics_sync_handle_t handle, struct xrt_compositor_fence **out_xcf)
 Create a compositor fence from a native sync handle. More...
 
xrt_result_t(* create_semaphore )(struct xrt_compositor *xc, xrt_graphics_sync_handle_t *out_handle, struct xrt_compositor_semaphore **out_xcsem)
 Create a compositor semaphore, also returns a native handle. More...
 
xrt_result_t(* begin_session )(struct xrt_compositor *xc, const struct xrt_begin_session_info *info)
 See xrBeginSession. More...
 
xrt_result_t(* end_session )(struct xrt_compositor *xc)
 See xrEndSession, unlike the OpenXR one the state tracker is responsible to call discard frame before calling this function. More...
 
xrt_result_t(* predict_frame )(struct xrt_compositor *xc, int64_t *out_frame_id, uint64_t *out_wake_time_ns, uint64_t *out_predicted_gpu_time_ns, uint64_t *out_predicted_display_time_ns, uint64_t *out_predicted_display_period_ns)
 This function and mark_frame function calls are a alternative to wait_frame. More...
 
xrt_result_t(* mark_frame )(struct xrt_compositor *xc, int64_t frame_id, enum xrt_compositor_frame_point point, uint64_t when_ns)
 This function and predict_frame function calls are a alternative to wait_frame. More...
 
xrt_result_t(* wait_frame )(struct xrt_compositor *xc, int64_t *out_frame_id, uint64_t *out_predicted_display_time, uint64_t *out_predicted_display_period)
 See xrWaitFrame. More...
 
xrt_result_t(* begin_frame )(struct xrt_compositor *xc, int64_t frame_id)
 See xrBeginFrame. More...
 
xrt_result_t(* discard_frame )(struct xrt_compositor *xc, int64_t frame_id)
 Explicitly discard a frame. More...
 
xrt_result_t(* layer_begin )(struct xrt_compositor *xc, const struct xrt_layer_frame_data *data)
 Begins layer submission. More...
 
xrt_result_t(* layer_projection )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 Adds a projection layer for submissions. More...
 
xrt_result_t(* layer_projection_depth )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc[XRT_MAX_VIEWS], struct xrt_swapchain *d_xsc[XRT_MAX_VIEWS], const struct xrt_layer_data *data)
 Adds a projection layer for submission, has depth information. More...
 
xrt_result_t(* layer_quad )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a quad layer for submission, the center of the quad is specified by the pose and extends outwards from it. More...
 
xrt_result_t(* layer_cube )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a cube layer for submission. More...
 
xrt_result_t(* layer_cylinder )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a cylinder layer for submission. More...
 
xrt_result_t(* layer_equirect1 )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a equirect1 layer for submission. More...
 
xrt_result_t(* layer_equirect2 )(struct xrt_compositor *xc, struct xrt_device *xdev, struct xrt_swapchain *xsc, const struct xrt_layer_data *data)
 Adds a equirect2 layer for submission. More...
 
xrt_result_t(* layer_passthrough )(struct xrt_compositor *xc, struct xrt_device *xdev, const struct xrt_layer_data *data)
 Adds a passthrough layer for submission. More...
 
xrt_result_t(* layer_commit )(struct xrt_compositor *xc, xrt_graphics_sync_handle_t sync_handle)
 Commits all of the submitted layers. More...
 
xrt_result_t(* layer_commit_with_semaphore )(struct xrt_compositor *xc, struct xrt_compositor_semaphore *xcsem, uint64_t value)
 Commits all of the submitted layers, with a semaphore. More...
 
xrt_result_t(* get_display_refresh_rate )(struct xrt_compositor *xc, float *out_display_refresh_rate_hz)
 Get the current display refresh rate. More...
 
xrt_result_t(* request_display_refresh_rate )(struct xrt_compositor *xc, float display_refresh_rate_hz)
 Request system to change the display refresh rate to the requested value. More...
 
xrt_result_t(* set_thread_hint )(struct xrt_compositor *xc, enum xrt_thread_hint hint, uint32_t thread_id)
 Set thread attributes according to thread type. More...
 

Protected Member Functions

static struct client_gl_compositorclient_gl_compositor (struct xrt_compositor *xc)
 Down-cast helper. More...
 

Detailed Description

Wraps the real compositor providing a OpenGL based interface.

Constructor & Destructor Documentation

◆ client_gl_compositor()

static struct client_gl_compositor * client_gl_compositor ( struct xrt_compositor xc)
inlineprotected

Member Function Documentation

◆ client_gl_compositor_close()

void client_gl_compositor_close ( struct client_gl_compositor c)

Free all resources from the client_gl_compositor, does not free the client_gl_compositor itself.

Nor does it free the xrt_compositor_native given at init as that is not owned by us.

References context_mutex, and os_mutex::os_mutex_destroy().

◆ client_gl_compositor_context_begin()

static xrt_result_t client_gl_compositor_context_begin ( struct xrt_compositor xc,
enum client_gl_context_reason  reason 
)
inline

Fetches the OpenGL context that is current on this thread and makes the OpenGL context given in the graphics binding current instead.

Only one thread at a time can operate on the sections between client_gl_context_begin_locked_func_t and client_gl_context_end_locked_func_t, therefore client_gl_context_end_locked_func_t MUST be called to avoid blocking the next thread calling client_gl_context_begin_locked_func_t.

This function must be called with the context_mutex locked held, that is handled by the helper function client_gl_compositor_context_begin.

If the return value is not XRT_SUCCESS, client_gl_context_end_locked_func_t should not be called.

Helper for calling through the function pointer.

References client_gl_compositor(), context_begin_locked, context_mutex, os_mutex::os_mutex_lock(), os_mutex::os_mutex_unlock(), and XRT_SUCCESS.

◆ client_gl_compositor_context_end()

static void client_gl_compositor_context_end ( struct xrt_compositor xc,
enum client_gl_context_reason  reason 
)
inline

Makes the OpenGL context current that was current before client_gl_context_begin_locked_func_t was called.

This function must be called with the context_mutex locked held, successful call to client_gl_compositor_context_begin will ensure that. The lock is not released by this function, but client_gl_compositor_context_end does release it.

Helper for calling through the function pointer.

◆ client_gl_compositor_init()

bool client_gl_compositor_init ( struct client_gl_compositor c,
struct xrt_compositor_native xcn,
client_gl_context_begin_locked_func_t  context_begin,
client_gl_context_end_locked_func_t  context_end,
client_gl_swapchain_create_func_t  create_swapchain,
client_gl_insert_fence_func_t  insert_fence 
)

Fill in a client_gl_compositor and do common OpenGL readiness checking.

OpenGL can have multiple backing window systems we have to interact with, so there isn't just one unified OpenGL client constructor.

Moves ownership of provided xcn to the client_gl_compositor.

Be sure to load your GL loader/wrapper (GLAD) before calling into here, it won't be called for you.

See also
xrt_compositor_native

References context_begin_locked, context_end_locked, and xrt_compositor::get_swapchain_create_properties.

Field Documentation

◆ context_begin_locked

client_gl_context_begin_locked_func_t client_gl_compositor::context_begin_locked

Function pointer for making the OpenGL context current.

Referenced by client_gl_compositor_context_begin(), and client_gl_compositor_init().

◆ context_end_locked

client_gl_context_end_locked_func_t client_gl_compositor::context_end_locked

Function pointer for restoring prior OpenGL context.

Referenced by client_gl_compositor_init().

◆ context_mutex

struct os_mutex client_gl_compositor::context_mutex

client_gl_xlib_compositor::app_context can only be current on one thread; block other threads while we know it is bound to a thread.

Referenced by client_gl_compositor_close(), and client_gl_compositor_context_begin().

◆ create_swapchain

client_gl_swapchain_create_func_t client_gl_compositor::create_swapchain

Function pointer for creating the client swapchain.

◆ insert_fence

client_gl_insert_fence_func_t client_gl_compositor::insert_fence

Function pointer for inserting fences on xrt_compositor::layer_commit.

Referenced by handle_fencing_or_finish().


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