Monado OpenXR Runtime
sdl_internal.h File Reference

Internal header for SDL XR system. More...

#include "xrt/xrt_system.h"
#include "xrt/xrt_device.h"
#include "xrt/xrt_instance.h"
#include "xrt/xrt_tracking.h"
#include "xrt/xrt_compositor.h"
#include "util/u_pacing.h"
#include "util/u_logging.h"
#include "util/comp_base.h"
#include "util/comp_swapchain.h"
#include "SDL2/SDL.h"
#include "ogl/ogl_api.h"
Include dependency graph for sdl_internal.h:

Go to the source code of this file.

Data Structures

struct  sdl_swapchain
 Sub-class of comp_swapchain, used to do OpenGL rendering. More...
 
struct  sdl_comp_frame
 Tracking frame state. More...
 
struct  sdl_compositor
 Split out for convenience. More...
 
struct  sdl_program
 C base class for the SDL program. More...
 

Macros

#define CHECK_GL()
 Check for OpenGL errors, context needs to be current. More...
 

Functions

static struct sdl_programfrom_xinst (struct xrt_instance *xinst)
 
static struct sdl_programfrom_xsysd (struct xrt_system_devices *xsysd)
 
static struct sdl_programfrom_xdev (struct xrt_device *xdev)
 
static struct sdl_programfrom_comp (struct xrt_compositor *xc)
 
static void sdl_make_current (struct sdl_program *sp)
 Makes the OpenGL context current in this thread, takes lock. More...
 
static void sdl_make_uncurrent (struct sdl_program *sp)
 Unmakes the any OpenGL context current in this thread, releases the lock. More...
 
void sdl_device_init (struct sdl_program *sp)
 Init the xrt_device sub struct. More...
 
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. More...
 
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. More...
 
void sdl_compositor_init (struct sdl_program *sp)
 Initializes the compositor part of the SDL program. More...
 
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. More...
 
void sdl_system_init (struct sdl_program *sp)
 Init the xrt_system (and u_system) struct. More...
 
void sdl_system_devices_init (struct sdl_program *sp)
 Init the xrt_system_devices sub struct. More...
 
void sdl_instance_init (struct sdl_program *sp)
 Init the xrt_instance sub struct. More...
 
struct sdl_programsdl_program_plus_create (void)
 Create the SDL program. More...
 
void sdl_program_plus_render (struct sdl_program_plus *spp)
 Render a frame, called by the compositor when layers have been committed. More...
 
void sdl_program_plus_destroy (struct sdl_program_plus *spp)
 Destroy the SDL program. More...
 

Detailed Description

Internal header for SDL XR system.

Author
Jakob Bornecrantz jakob.nosp@m.@col.nosp@m.labor.nosp@m.a.co.nosp@m.m

Macro Definition Documentation

◆ CHECK_GL

#define CHECK_GL ( )
Value:
do { \
GLint err = glGetError(); \
if (err != 0) { \
U_LOG_RAW("%s:%u: error: 0x%04x", __func__, __LINE__, err); \
} \
} while (false)

Check for OpenGL errors, context needs to be current.

Function Documentation

◆ sdl_compositor_create_system()

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.

◆ sdl_compositor_init()

void sdl_compositor_init ( struct sdl_program sp)

Initializes the compositor part of the SDL program.

References sdl_program::xdev_base.

◆ sdl_device_init()

◆ sdl_instance_init()

void sdl_instance_init ( struct sdl_program sp)

Init the xrt_instance sub struct.

References xrt_instance::create_system, and sdl_program::xinst_base.

◆ sdl_make_current()

static void sdl_make_current ( struct sdl_program sp)
inlinestatic

Makes the OpenGL context current in this thread, takes lock.

References sdl_program::ctx, sdl_program::current_mutex, os_mutex::os_mutex_lock(), and sdl_program::win.

Referenced by sdl_program_plus_render().

◆ sdl_make_uncurrent()

static void sdl_make_uncurrent ( struct sdl_program sp)
inlinestatic

Unmakes the any OpenGL context current in this thread, releases the lock.

References sdl_program::current_mutex, and os_mutex::os_mutex_unlock().

◆ sdl_program_plus_create()

struct sdl_program* sdl_program_plus_create ( void  )

◆ sdl_program_plus_destroy()

void sdl_program_plus_destroy ( struct sdl_program_plus spp)

Destroy the SDL program.

References sdl_program::current_mutex, os_mutex::os_mutex_destroy(), and sdl_program::spp.

◆ sdl_program_plus_render()

void sdl_program_plus_render ( struct sdl_program_plus spp)

◆ sdl_swapchain_create()

xrt_result_t sdl_swapchain_create ( struct xrt_compositor xc,
const struct xrt_swapchain_create_info info,
struct xrt_swapchain **  out_xsc 
)

◆ sdl_swapchain_import()

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 
)

◆ sdl_system_devices_init()

void sdl_system_devices_init ( struct sdl_program sp)

◆ sdl_system_init()

void sdl_system_init ( struct sdl_program sp)

Init the xrt_system (and u_system) struct.

References u_system::u_system_create(), and sdl_program::usys.