Monado OpenXR Runtime
Files | Data Structures | Macros | Typedefs | Enumerations | Functions
Main compositor code

Main compositor code. More...

Collaboration diagram for Main compositor code:

Files

file  comp_compositor.c
 Main compositor written using Vulkan implementation.
 
file  comp_compositor.h
 Main compositor written using Vulkan header.
 
file  comp_distortion.c
 Distortion shader code.
 
file  comp_distortion.h
 Distortion shader code header.
 
file  comp_renderer.c
 Compositor rendering code.
 
file  comp_renderer.h
 Compositor rendering code header.
 
file  comp_settings.c
 Settings struct for compositor.
 
file  comp_settings.h
 Settings struct for compositor header.
 
file  comp_swapchain.c
 Swapchain code for the main compositor.
 
file  comp_vk_swapchain.c
 Vulkan swapchain code.
 
file  comp_vk_swapchain.h
 Vulkan swapchain code header.
 
file  comp_window.h
 Compositor window header.
 
file  comp_window_direct_mode.cpp
 Direct mode window code.
 
file  comp_window_wayland.c
 Wayland window code.
 
file  comp_window_xcb.cpp
 XCB window code.
 

Data Structures

struct  comp_swapchain_image
 A single swapchain image, holds the needed state for tracking image usage. More...
 
struct  comp_swapchain
 A swapchain that is almost a one to one mapping to a OpenXR swapchain. More...
 
struct  comp_compositor
 Main compositor struct tying everything in the compositor together. More...
 
struct  comp_uniform_buffer
 Helper buffer for a single uniform buffer. More...
 
struct  comp_distortion
 Helper struct that encapsulate a distortion rendering code. More...
 
struct  comp_renderer
 Holds associated vulkan objects and state to render with a distortion. More...
 
struct  comp_settings
 Settings for the compositor. More...
 
struct  vk_swapchain_buffer
 A pair of VkImage and VkImageView. More...
 
struct  vk_swapchain
 Wraps and manage VkSwapchainKHR and VkSurfaceKHR, used by Compositor code. More...
 
struct  comp_window
 A output device or a window, often directly connected to the device. More...
 

Macros

#define COMP_SPEW(c, ...)
 Spew level logging. More...
 
#define COMP_DEBUG(c, ...)
 Debug level logging. More...
 
#define COMP_PRINT_MODE(c, ...)
 Mode printing. More...
 
#define COMP_ERROR(c, ...)
 Error level logging. More...
 

Typedefs

typedef void(* vk_swapchain_cb) (uint32_t width, uint32_t height, void *priv)
 Callback when a vk_swapchain changes size. More...
 

Enumerations

enum  window_type {
  WINDOW_NONE = 0, WINDOW_AUTO, WINDOW_XCB, WINDOW_WAYLAND,
  WINDOW_DIRECT_RANDR, WINDOW_DIRECT_NVIDIA
}
 Window type to use. More...
 

Functions

struct xrt_swapchaincomp_swapchain_create (struct xrt_compositor *xc, enum xrt_swapchain_create_flags create, enum xrt_swapchain_usage_bits bits, int64_t format, uint32_t sample_count, uint32_t width, uint32_t height, uint32_t face_count, uint32_t array_size, uint32_t mip_count)
 A compositor function that is implemented in the swapchain code. More...
 
void comp_swapchain_image_cleanup (struct vk_bundle *vk, uint32_t array_size, struct comp_swapchain_image *image)
 Free and destroy any initialized fields on the given image, safe to pass in images that has one or all fields set to NULL. More...
 
void comp_compositor_print (struct comp_compositor *c, const char *func, const char *fmt,...) XRT_PRINTF_FORMAT(3
 Printer helper. More...
 
void comp_distortion_init (struct comp_distortion *d, struct comp_compositor *c, VkRenderPass render_pass, VkPipelineCache pipeline_cache, enum xrt_distortion_model distortion_model, struct xrt_hmd_parts *parts, VkDescriptorPool descriptor_pool, bool flip_y)
 Init a distortion, pass in the distortion so it can be embedded in a struct. More...
 
void comp_distortion_destroy (struct comp_distortion *d)
 Free and destroy all fields, does not free the destortion itself. More...
 
void comp_distortion_update_descriptor_set (struct comp_distortion *d, VkSampler sampler, VkImageView view, uint32_t eye)
 Update the descriptor set to a new image. More...
 
void comp_distortion_draw_quad (struct comp_distortion *d, VkCommandBuffer command_buffer, int eye)
 Submit draw commands to the given command_buffer. More...
 
struct comp_renderercomp_renderer_create (struct comp_compositor *c)
 Called by the main compositor code to create the renderer. More...
 
void comp_renderer_frame (struct comp_renderer *r, struct comp_swapchain_image *left, uint32_t left_layer, struct comp_swapchain_image *right, uint32_t right_layer)
 Render a distorted stereo frame. More...
 
void comp_renderer_destroy (struct comp_renderer *r)
 Clean up and free the renderer. More...
 
void comp_settings_init (struct comp_settings *s, struct xrt_device *xdev)
 Initialize the settings struct with either defaults or loaded setting. More...
 
void vk_swapchain_init (struct vk_swapchain *sc, struct vk_bundle *vk, vk_swapchain_cb dimension_cb, void *priv)
 Wraps and manage VkSwapchainKHR and VkSurfaceKHR, used by Compositor code. More...
 
void vk_swapchain_create (struct vk_swapchain *sc, uint32_t width, uint32_t height, VkFormat color_format, VkColorSpaceKHR color_space, VkPresentModeKHR present_mode)
 Initialize the given vk_swapchain, does not allocate. More...
 
VkResult vk_swapchain_acquire_next_image (struct vk_swapchain *sc, VkSemaphore semaphore, uint32_t *index)
 Acquire a image index from the given vk_swapchain for rendering. More...
 
VkResult vk_swapchain_present (struct vk_swapchain *sc, VkQueue queue, uint32_t index, VkSemaphore semaphore)
 Make the given vk_swapchain present the next acquired image. More...
 
void vk_swapchain_cleanup (struct vk_swapchain *sc)
 Free all managed resources on the given vk_swapchain, does not free the struct itself. More...
 
struct comp_windowcomp_window_xcb_create (struct comp_compositor *c)
 Create a xcb window. More...
 
struct comp_windowcomp_window_wayland_create (struct comp_compositor *c)
 Create a wayland window. More...
 
struct comp_windowcomp_window_direct_create (struct comp_compositor *c)
 Create a direct surface to a HMD. More...
 

Detailed Description

Main compositor code.

Macro Definition Documentation

◆ COMP_DEBUG

#define COMP_DEBUG (   c,
  ... 
)

#include <compositor/main/comp_compositor.h>

Value:
do { \
if (c->settings.print_debug) { \
comp_compositor_print(c, __func__, __VA_ARGS__); \
} \
} while (false)

Debug level logging.

◆ COMP_ERROR

#define COMP_ERROR (   c,
  ... 
)

#include <compositor/main/comp_compositor.h>

Value:
do { \
comp_compositor_print(c, __func__, __VA_ARGS__); \
} while (false)

Error level logging.

◆ COMP_PRINT_MODE

#define COMP_PRINT_MODE (   c,
  ... 
)

#include <compositor/main/comp_compositor.h>

Value:
do { \
if (c->settings.print_modes) { \
comp_compositor_print(c, __func__, __VA_ARGS__); \
} \
} while (false)

Mode printing.

◆ COMP_SPEW

#define COMP_SPEW (   c,
  ... 
)

#include <compositor/main/comp_compositor.h>

Value:
do { \
if (c->settings.print_spew) { \
comp_compositor_print(c, __func__, __VA_ARGS__); \
} \
} while (false)

Spew level logging.

Typedef Documentation

◆ vk_swapchain_cb

typedef void(* vk_swapchain_cb) (uint32_t width, uint32_t height, void *priv)

#include <compositor/main/comp_vk_swapchain.h>

Callback when a vk_swapchain changes size.

Enumeration Type Documentation

◆ window_type

#include <compositor/main/comp_settings.h>

Window type to use.

Function Documentation

◆ comp_compositor_print()

void comp_compositor_print ( struct comp_compositor c,
const char *  func,
const char *  fmt,
  ... 
)

#include <compositor/main/comp_compositor.h>

Printer helper.

◆ comp_distortion_destroy()

void comp_distortion_destroy ( struct comp_distortion d)

#include <compositor/main/comp_distortion.h>

Free and destroy all fields, does not free the destortion itself.

◆ comp_distortion_draw_quad()

void comp_distortion_draw_quad ( struct comp_distortion d,
VkCommandBuffer  command_buffer,
int  eye 
)

#include <compositor/main/comp_distortion.h>

Submit draw commands to the given command_buffer.

◆ comp_distortion_init()

void comp_distortion_init ( struct comp_distortion d,
struct comp_compositor c,
VkRenderPass  render_pass,
VkPipelineCache  pipeline_cache,
enum xrt_distortion_model  distortion_model,
struct xrt_hmd_parts parts,
VkDescriptorPool  descriptor_pool,
bool  flip_y 
)

#include <compositor/main/comp_distortion.h>

Init a distortion, pass in the distortion so it can be embedded in a struct.

Add support for 1 channels as well.

References xrt_hmd_parts::distortion, comp_compositor::settings, comp_compositor::vk, and comp_settings::wireframe.

◆ comp_distortion_update_descriptor_set()

void comp_distortion_update_descriptor_set ( struct comp_distortion d,
VkSampler  sampler,
VkImageView  view,
uint32_t  eye 
)

#include <compositor/main/comp_distortion.h>

Update the descriptor set to a new image.

◆ comp_renderer_create()

struct comp_renderer* comp_renderer_create ( struct comp_compositor c)

#include <compositor/main/comp_renderer.h>

Called by the main compositor code to create the renderer.

References U_TYPED_CALLOC.

◆ comp_renderer_destroy()

void comp_renderer_destroy ( struct comp_renderer r)

#include <compositor/main/comp_renderer.h>

Clean up and free the renderer.

◆ comp_renderer_frame()

void comp_renderer_frame ( struct comp_renderer r,
struct comp_swapchain_image left,
uint32_t  left_layer,
struct comp_swapchain_image right,
uint32_t  right_layer 
)

#include <compositor/main/comp_renderer.h>

Render a distorted stereo frame.

◆ comp_settings_init()

void comp_settings_init ( struct comp_settings s,
struct xrt_device xdev 
)

#include <compositor/main/comp_settings.h>

Initialize the settings struct with either defaults or loaded setting.

◆ comp_swapchain_create()

struct xrt_swapchain* comp_swapchain_create ( struct xrt_compositor xc,
enum xrt_swapchain_create_flags  create,
enum xrt_swapchain_usage_bits  bits,
int64_t  format,
uint32_t  sample_count,
uint32_t  width,
uint32_t  height,
uint32_t  face_count,
uint32_t  array_size,
uint32_t  mip_count 
)

#include <compositor/main/comp_compositor.h>

A compositor function that is implemented in the swapchain code.

Todo:
memory leak of image fds and swapchain

Referenced by xrt_gfx_provider_create_fd().

◆ comp_swapchain_image_cleanup()

void comp_swapchain_image_cleanup ( struct vk_bundle vk,
uint32_t  array_size,
struct comp_swapchain_image image 
)

#include <compositor/main/comp_compositor.h>

Free and destroy any initialized fields on the given image, safe to pass in images that has one or all fields set to NULL.

References comp_swapchain_image::image, comp_swapchain_image::memory, comp_swapchain_image::sampler, and comp_swapchain_image::views.

◆ comp_window_direct_create()

struct comp_window* comp_window_direct_create ( struct comp_compositor c)

#include <compositor/main/comp_window.h>

Create a direct surface to a HMD.

References comp_window::name.

◆ comp_window_wayland_create()

struct comp_window* comp_window_wayland_create ( struct comp_compositor c)

#include <compositor/main/comp_window.h>

Create a wayland window.

References comp_window::name, and U_TYPED_CALLOC.

◆ comp_window_xcb_create()

struct comp_window* comp_window_xcb_create ( struct comp_compositor c)

#include <compositor/main/comp_window.h>

Create a xcb window.

References comp_window::name.

◆ vk_swapchain_acquire_next_image()

VkResult vk_swapchain_acquire_next_image ( struct vk_swapchain sc,
VkSemaphore  semaphore,
uint32_t *  index 
)

#include <compositor/main/comp_vk_swapchain.h>

Acquire a image index from the given vk_swapchain for rendering.

◆ vk_swapchain_cleanup()

void vk_swapchain_cleanup ( struct vk_swapchain sc)

#include <compositor/main/comp_vk_swapchain.h>

Free all managed resources on the given vk_swapchain, does not free the struct itself.

◆ vk_swapchain_create()

void vk_swapchain_create ( struct vk_swapchain sc,
uint32_t  width,
uint32_t  height,
VkFormat  color_format,
VkColorSpaceKHR  color_space,
VkPresentModeKHR  present_mode 
)

#include <compositor/main/comp_vk_swapchain.h>

Initialize the given vk_swapchain, does not allocate.

◆ vk_swapchain_init()

void vk_swapchain_init ( struct vk_swapchain sc,
struct vk_bundle vk,
vk_swapchain_cb  dimension_cb,
void *  priv 
)

#include <compositor/main/comp_vk_swapchain.h>

Wraps and manage VkSwapchainKHR and VkSurfaceKHR, used by Compositor code.

◆ vk_swapchain_present()

VkResult vk_swapchain_present ( struct vk_swapchain sc,
VkQueue  queue,
uint32_t  index,
VkSemaphore  semaphore 
)

#include <compositor/main/comp_vk_swapchain.h>

Make the given vk_swapchain present the next acquired image.