62 uint64_t predicted_display_time_ns;
63 uint64_t desired_present_time_ns;
64 uint64_t present_slop_ns;
212#define ST_TRACE(sp, ...) U_LOG_IFL_T(sp->log_level, __VA_ARGS__);
219#define ST_DEBUG(sp, ...) U_LOG_IFL_D(sp->log_level, __VA_ARGS__);
227#define ST_INFO(sp, ...) U_LOG_IFL_I(sp->log_level, __VA_ARGS__);
235#define ST_WARN(sp, ...) U_LOG_IFL_W(sp->log_level, __VA_ARGS__);
243#define ST_ERROR(sp, ...) U_LOG_IFL_E(sp->log_level, __VA_ARGS__);
252 GLint err = glGetError(); \
254 U_LOG_RAW("%s:%u: error: 0x%04x", __func__, __LINE__, err); \
267 SDL_GL_MakeCurrent(sp->
win, sp->
ctx);
278 SDL_GL_MakeCurrent(NULL, NULL);
325 uint32_t native_image_count,
Helper implementation for native compositors.
Independent swapchain implementation.
u_logging_level
Logging level enum.
Definition: u_logging.h:43
static void os_mutex_lock(struct os_mutex *om)
Lock.
Definition: os_threading.h:86
static void os_mutex_unlock(struct os_mutex *om)
Unlock.
Definition: os_threading.h:110
#define XRT_MAX_SWAPCHAIN_IMAGES
Max swapchain images, artificial limit.
Definition: xrt_limits.h:34
enum xrt_result xrt_result_t
Result type used across Monado.
#define container_of(ptr, type, field)
Get the holder from a pointer to a field.
Definition: xrt_compiler.h:149
OpenGL API wrapper header.
void sdl_compositor_init(struct sdl_program *sp)
Initializes the compositor part of the SDL program.
Definition: sdl_compositor.c:518
xrt_result_t sdl_compositor_create_system(struct sdl_program *sp, struct xrt_system_compositor **out_xsysc)
Creates the system compositor that wraps the native compositor.
Definition: sdl_compositor.c:568
void sdl_system_init(struct sdl_program *sp)
Init the xrt_system (and u_system) struct.
Definition: sdl_instance.c:123
void sdl_program_plus_destroy(struct sdl_program_plus *spp)
Destroy the SDL program.
Definition: sdl_program.cpp:174
void sdl_instance_init(struct sdl_program *sp)
Init the xrt_instance sub struct.
Definition: sdl_instance.c:162
void sdl_device_init(struct sdl_program *sp)
Init the xrt_device sub struct.
Definition: sdl_device.c:70
void sdl_program_plus_render(struct sdl_program_plus *spp)
Render a frame, called by the compositor when layers have been committed.
Definition: sdl_program.cpp:102
xrt_result_t sdl_swapchain_create(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_swapchain **out_xsc)
Implementation of xrt_compositor::create_swapchain.
Definition: sdl_swapchain.c:82
static void sdl_make_current(struct sdl_program *sp)
Makes the OpenGL context current in this thread, takes lock.
Definition: sdl_internal.h:264
xrt_result_t sdl_swapchain_import(struct xrt_compositor *xc, const struct xrt_swapchain_create_info *info, struct xrt_image_native *native_images, uint32_t native_image_count, struct xrt_swapchain **out_xsc)
Implementation of xrt_compositor::import_swapchain.
Definition: sdl_swapchain.c:120
void sdl_system_devices_init(struct sdl_program *sp)
Init the xrt_system_devices sub struct.
Definition: sdl_instance.c:132
static void sdl_make_uncurrent(struct sdl_program *sp)
Unmakes the any OpenGL context current in this thread, releases the lock.
Definition: sdl_internal.h:276
struct sdl_program * sdl_program_plus_create(void)
Create the SDL program.
Definition: sdl_program.cpp:77
A simple compositor base that handles a lot of things for you.
Definition: comp_base.h:69
struct xrt_compositor_native base
Base native compositor.
Definition: comp_base.h:71
A swapchain that is almost a one to one mapping to a OpenXR swapchain.
Definition: comp_swapchain.h:92
A wrapper around a native mutex.
Definition: os_threading.h:55
Tracking frame state.
Definition: sdl_internal.h:60
Split out for convenience.
Definition: sdl_internal.h:77
uint64_t frame_interval_ns
Frame interval that we are using.
Definition: sdl_internal.h:87
struct sdl_compositor::@284 frame
struct comp_base base
Base native compositor.
Definition: sdl_internal.h:79
struct u_pacing_compositor * upc
Pacing helper to drive us forward.
Definition: sdl_internal.h:82
C++ version of the sdl_program struct, where you place C++ only things.
Definition: sdl_internal.hpp:25
C base class for the SDL program.
Definition: sdl_internal.h:115
struct xrt_tracking_origin origin
Tracking origin that the device is located in.
Definition: sdl_internal.h:144
struct xrt_system_compositor * xsysc
Created system compositor.
Definition: sdl_internal.h:135
SDL_GLContext ctx
Main OpenGL context.
Definition: sdl_internal.h:171
struct os_mutex current_mutex
Protects the OpenGL context.
Definition: sdl_internal.h:174
struct xrt_device xdev_base
Base class for devices.
Definition: sdl_internal.h:117
SDL_Window * win
The main window.
Definition: sdl_internal.h:168
struct xrt_system_devices xsysd_base
System devices base.
Definition: sdl_internal.h:126
struct xrt_fov fov
Fov of each individual eye.
Definition: sdl_internal.h:163
struct xrt_input inputs[1]
Inputs exposed by the SDL device.
Definition: sdl_internal.h:138
enum u_logging_level log_level
The current log level.
Definition: sdl_internal.h:147
struct xrt_space_overseer * xso
Space overseer, implemented for now using helper code.
Definition: sdl_internal.h:129
struct sdl_program_plus * spp
Pointer back to the C++ part of the program.
Definition: sdl_internal.h:177
struct xrt_pose pose
The pose of the head, only used for view space.
Definition: sdl_internal.h:154
struct u_system * usys
System, implemented for now using helper code.
Definition: sdl_internal.h:123
struct xrt_hmd_parts hmd
HMD parts exposed by the SDL device to become a HMD.
Definition: sdl_internal.h:141
struct sdl_compositor c
SDL compositor struct.
Definition: sdl_internal.h:132
struct xrt_instance xinst_base
Instance base.
Definition: sdl_internal.h:120
Sub-class of comp_swapchain, used to do OpenGL rendering.
Definition: sdl_internal.h:38
int w
Cached width and height.
Definition: sdl_internal.h:45
GLuint memory[XRT_MAX_SWAPCHAIN_IMAGES]
Same number of images as textures.
Definition: sdl_internal.h:51
struct sdl_program * sp
Pointer back to main program.
Definition: sdl_internal.h:42
GLuint textures[XRT_MAX_SWAPCHAIN_IMAGES]
Number of textures in base.base.base.image_count.
Definition: sdl_internal.h:48
Compositor pacing helper interface.
Definition: u_pacing.h:68
A helper to implement a xrt_system, takes care of multiplexing events to sessions.
Definition: u_system.h:43
Common compositor client interface/base.
Definition: xrt_compositor.h:988
struct xrt_compositor_info info
Capabilities and recommended values information.
Definition: xrt_compositor.h:992
A single HMD or input device.
Definition: xrt_device.h:241
Describes a projection matrix fov.
Definition: xrt_defines.h:486
All of the device components that deals with interfacing to a users head.
Definition: xrt_device.h:90
A single image of a swapchain based on native buffer handles.
Definition: xrt_compositor.h:2150
This interface acts as a root object for Monado.
Definition: xrt_instance.h:114
A pose composed of a position and orientation.
Definition: xrt_defines.h:465
Object that oversees and manages spaces, one created for each XR system.
Definition: xrt_space.h:96
Swapchain creation info.
Definition: xrt_compositor.h:876
Common swapchain interface/base.
Definition: xrt_compositor.h:536
Capabilities and information about the system compositor (and its wrapped native compositor,...
Definition: xrt_compositor.h:2295
The system compositor handles composition for a system.
Definition: xrt_compositor.h:2414
A collection of xrt_device, and an interface for identifying the roles they have been assigned.
Definition: xrt_system.h:219
A tracking system or device origin.
Definition: xrt_tracking.h:71
Basic logging functionality.
Header declaring XRT graphics interfaces.
Header defining an xrt display or controller device.
Header for xrt_instance object.
Header for system objects.
Header defining the tracking system integration in Monado.