Monado OpenXR Runtime
|
Main compositor code. More...
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.c |
Common direct mode window code. | |
file | comp_window_direct.h |
Common direct mode window code header. | |
file | comp_window_direct_nvidia.c |
Direct mode window code. | |
file | comp_window_direct_randr.c |
Direct mode window code. | |
file | comp_window_wayland.c |
Wayland window code. | |
file | comp_window_xcb.c |
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 | |
void | comp_compositor_garbage_collect (struct comp_compositor *c) |
Do garbage collection, destroying any resources that has been scheduled for destruction from other threads. More... | |
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) |
A compositor function that is implemented in the swapchain code. More... | |
void | comp_swapchain_really_destroy (struct comp_swapchain *sc) |
Swapchain destruct is delayed until it is safe to destroy them, this function does the actual destruction and is called from comp_compositor_garbage_collect. 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_renderer * | comp_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_window * | comp_window_xcb_create (struct comp_compositor *c) |
Create a xcb window. More... | |
struct comp_window * | comp_window_wayland_create (struct comp_compositor *c) |
Create a wayland window. More... | |
struct comp_window * | comp_window_direct_randr_create (struct comp_compositor *c) |
Create a direct surface to a HMD over RandR. More... | |
struct comp_window * | comp_window_direct_nvidia_create (struct comp_compositor *c) |
Create a direct surface to a HMD on NVIDIA. More... | |
Main compositor code.
#define COMP_DEBUG | ( | c, | |
... | |||
) |
#include <compositor/main/comp_compositor.h>
Debug level logging.
Referenced by comp_window_direct_create_surface(), and comp_window_direct_get_primary_display_mode().
#define COMP_ERROR | ( | c, | |
... | |||
) |
#include <compositor/main/comp_compositor.h>
Error level logging.
Referenced by comp_window_direct_acquire_xlib_display(), comp_window_direct_connect(), comp_window_direct_create_surface(), comp_window_direct_get_primary_display_mode(), and comp_window_direct_init_swapchain().
#define COMP_PRINT_MODE | ( | c, | |
... | |||
) |
#include <compositor/main/comp_compositor.h>
Mode printing.
#define COMP_SPEW | ( | c, | |
... | |||
) |
#include <compositor/main/comp_compositor.h>
Spew level logging.
Referenced by comp_swapchain_really_destroy().
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.
enum window_type |
#include <compositor/main/comp_settings.h>
Window type to use.
Enumerator | |
---|---|
WINDOW_NONE | |
WINDOW_AUTO | |
WINDOW_XCB | |
WINDOW_WAYLAND | |
WINDOW_DIRECT_RANDR | |
WINDOW_DIRECT_NVIDIA |
void comp_compositor_garbage_collect | ( | struct comp_compositor * | c | ) |
#include <compositor/main/comp_compositor.h>
Do garbage collection, destroying any resources that has been scheduled for destruction from other threads.
void comp_compositor_print | ( | struct comp_compositor * | c, |
const char * | func, | ||
const char * | fmt, | ||
... | |||
) |
#include <compositor/main/comp_compositor.h>
Printer helper.
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.
References comp_distortion::descriptor_set_layout, vk_bundle::device, comp_distortion::vk, and vk_bundle::vkDestroyDescriptorSetLayout.
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.
References comp_distortion::descriptor_sets, comp_distortion::pipeline, comp_distortion::pipeline_layout, comp_distortion::vk, vk_bundle::vkCmdBindDescriptorSets, vk_bundle::vkCmdBindPipeline, and vk_bundle::vkCmdDraw.
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 comp_settings::debug, xrt_hmd_parts::distortion, comp_distortion::distortion_model, comp_distortion::flip_y, comp_distortion::indices, comp_distortion::mesh, xrt_hmd_parts::mesh, comp_distortion::num_indices, comp_distortion::num_vertices, comp_distortion::offset_indices, comp_distortion::quirk_draw_lines, comp_compositor::settings, comp_distortion::stride, comp_distortion::total_num_indices, comp_distortion::ubo_vp_data, comp_distortion::vertices, comp_distortion::vk, comp_compositor::vk, and comp_settings::wireframe.
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.
References comp_distortion::vk.
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.
void comp_renderer_destroy | ( | struct comp_renderer * | r | ) |
#include <compositor/main/comp_renderer.h>
Clean up and free the renderer.
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.
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.
References WINDOW_AUTO, WINDOW_DIRECT_NVIDIA, WINDOW_DIRECT_RANDR, WINDOW_WAYLAND, and WINDOW_XCB.
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.
Referenced by xrt_gfx_provider_create_fd().
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 vk_bundle::device, comp_swapchain_image::image, comp_swapchain_image::memory, comp_swapchain_image::sampler, comp_swapchain_image::views, vk_bundle::vkDestroyImage, vk_bundle::vkDestroyImageView, vk_bundle::vkDestroySampler, vk_bundle::vkDeviceWaitIdle, and vk_bundle::vkFreeMemory.
Referenced by comp_swapchain_really_destroy().
void comp_swapchain_really_destroy | ( | struct comp_swapchain * | sc | ) |
#include <compositor/main/comp_compositor.h>
Swapchain destruct is delayed until it is safe to destroy them, this function does the actual destruction and is called from comp_compositor_garbage_collect.
References xrt_swapchain::array_size, comp_swapchain::base, xrt_swapchain_fd::base, comp_swapchain::c, COMP_SPEW, comp_swapchain_image_cleanup(), comp_swapchain::images, xrt_swapchain::num_images, and comp_compositor::vk.
struct comp_window* comp_window_direct_nvidia_create | ( | struct comp_compositor * | c | ) |
#include <compositor/main/comp_window.h>
Create a direct surface to a HMD on NVIDIA.
References comp_window_direct_nvidia::base, comp_window::destroy, comp_window::name, and U_TYPED_CALLOC.
struct comp_window* comp_window_direct_randr_create | ( | struct comp_compositor * | c | ) |
#include <compositor/main/comp_window.h>
Create a direct surface to a HMD over RandR.
References comp_window_direct_randr::base, comp_window::destroy, comp_window::name, and U_TYPED_CALLOC.
struct comp_window* comp_window_wayland_create | ( | struct comp_compositor * | c | ) |
#include <compositor/main/comp_window.h>
Create a wayland window.
References comp_window_wayland::base, comp_window::destroy, comp_window::name, and U_TYPED_CALLOC.
struct comp_window* comp_window_xcb_create | ( | struct comp_compositor * | c | ) |
#include <compositor/main/comp_window.h>
Create a xcb window.
References comp_window_xcb::base, comp_window::destroy, comp_window::name, and U_TYPED_CALLOC.
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.
References vk_bundle::device, vk_swapchain::swap_chain, vk_swapchain::vk, and vk_bundle::vkAcquireNextImageKHR.
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.
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.
Referenced by comp_window_direct_init_swapchain().
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.
References vk_swapchain::cb_priv, vk_swapchain::dimension_cb, and vk_swapchain::vk.
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.
References vk_swapchain::swap_chain, vk_swapchain::vk, and vk_bundle::vkQueuePresentKHR.