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_frame.h |
Small helper functions to manage frames. | |
file | comp_main_interface.h |
Header for the main compositor interface. | |
file | comp_mirror_to_debug_gui.c |
Compositor mirroring code. | |
file | comp_mirror_to_debug_gui.h |
Compositor mirroring code. | |
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_target.h |
Abstracted compositor rendering target. | |
file | comp_target_swapchain.c |
Target Vulkan swapchain code. | |
file | comp_target_swapchain.h |
Target Vulkan swapchain code header. | |
file | comp_window.h |
Compositor window header. | |
file | comp_window_android.c |
Android window code. | |
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_mswin.c |
Microsoft Windows window code. | |
file | comp_window_peek.c |
Displays the content of one or both eye onto a desktop window. | |
file | comp_window_peek.h |
Displays the content of one or both eye onto a desktop window. | |
file | comp_window_vk_display.c |
Direct mode on PLATFORM_DISPLAY_KHR code. | |
file | comp_window_wayland.c |
Wayland window code. | |
file | comp_window_xcb.c |
XCB window code. | |
file | comp_multi_interface.h |
Interface for the multi-client layer code. | |
file | comp_render_cs.c |
Compositor rendering code. | |
Data Structures | |
struct | comp_compositor |
Main compositor struct tying everything in the compositor together. More... | |
struct | comp_mirror_to_debug_gui |
Helper struct for mirroring the compositors rendering to the debug ui, which also enables recording. 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 | comp_target_image |
Image and view pair for comp_target. More... | |
struct | comp_target_create_images_info |
Information given in when creating the swapchain images, argument to comp_target_create_images. More... | |
struct | comp_target_semaphores |
Collection of semaphores needed for a target. More... | |
struct | comp_target |
A compositor target: where the compositor renders to. More... | |
struct | comp_target_factory |
A factory of targets. More... | |
struct | comp_target_swapchain |
Wraps and manage VkSwapchainKHR and VkSurfaceKHR, used by Compositor code. More... | |
Enumerations | |
enum | comp_target_timing_point { COMP_TARGET_TIMING_POINT_WAKE_UP , COMP_TARGET_TIMING_POINT_BEGIN , COMP_TARGET_TIMING_POINT_SUBMIT_BEGIN , COMP_TARGET_TIMING_POINT_SUBMIT_END } |
For marking timepoints on a frame's lifetime, not a async event. More... | |
enum | comp_target_display_timing_usage { COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING = 0 , COMP_TARGET_USE_DISPLAY_IF_AVAILABLE = 1 } |
If the target should use the display timing information. More... | |
Functions | |
void | comp_settings_init (struct comp_settings *s, struct xrt_device *xdev) |
Initialize the settings struct with either defaults or loaded setting. More... | |
xrt_result_t | comp_main_create_system_compositor (struct xrt_device *xdev, const struct comp_target_factory *ctf, struct xrt_system_compositor **out_xsysc) |
Creates the main compositor, it doesn't return itself but instead wraps itself with a system compositor. More... | |
struct comp_renderer * | comp_renderer::comp_renderer_create (struct comp_compositor *c, VkExtent2D scratch_extent) |
Called by the main compositor code to create the renderer. More... | |
void | comp_renderer::comp_renderer_destroy (struct comp_renderer **ptr_r) |
Clean up and free the renderer. More... | |
XRT_CHECK_RESULT xrt_result_t | comp_renderer::comp_renderer_draw (struct comp_renderer *r) |
Render frame. More... | |
static bool | comp_target::comp_target_init_pre_vulkan (struct comp_target *ct) |
Do any initialization that is required to happen before Vulkan has been loaded. More... | |
static bool | comp_target::comp_target_init_post_vulkan (struct comp_target *ct, uint32_t preferred_width, uint32_t preferred_height) |
Do any initialization that requires Vulkan to be loaded, you need to call create_images after calling this function. More... | |
static bool | comp_target::comp_target_check_ready (struct comp_target *ct) |
Is this target ready for image creation? More... | |
static void | comp_target::comp_target_create_images (struct comp_target *ct, const struct comp_target_create_images_info *create_info) |
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the swapchain. More... | |
static bool | comp_target::comp_target_has_images (struct comp_target *ct) |
Has this target successfully had images created? More... | |
static VkResult | comp_target::comp_target_acquire (struct comp_target *ct, uint32_t *out_index) |
Acquire the next image for rendering. More... | |
static VkResult | comp_target::comp_target_present (struct comp_target *ct, VkQueue queue, uint32_t index, uint64_t timeline_semaphore_value, int64_t desired_present_time_ns, int64_t present_slop_ns) |
Present the image at index to the screen. More... | |
static void | comp_target::comp_target_flush (struct comp_target *ct) |
Flush any WSI state before rendering. More... | |
static void | comp_target::comp_target_calc_frame_pacing (struct comp_target *ct, int64_t *out_frame_id, int64_t *out_wake_up_time_ns, int64_t *out_desired_present_time_ns, int64_t *out_present_slop_ns, int64_t *out_predicted_display_time_ns) |
Predict when the next frame should be started and when it will be turned into photons by the hardware. More... | |
static void | comp_target::comp_target_mark_wake_up (struct comp_target *ct, int64_t frame_id, int64_t when_woke_ns) |
Quick helper for marking wake up. More... | |
static void | comp_target::comp_target_mark_begin (struct comp_target *ct, int64_t frame_id, int64_t when_began_ns) |
Quick helper for marking begin. More... | |
static void | comp_target::comp_target_mark_submit_begin (struct comp_target *ct, int64_t frame_id, int64_t when_submit_began_ns) |
Quick helper for marking submit began. More... | |
static void | comp_target::comp_target_mark_submit_end (struct comp_target *ct, int64_t frame_id, int64_t when_submit_end_ns) |
Quick helper for marking submit end. More... | |
static VkResult | comp_target::comp_target_update_timings (struct comp_target *ct) |
Update timing information for this target, this function should be lightweight and is called multiple times during a frame to make sure that we get the timing data as soon as possible. More... | |
static void | comp_target::comp_target_info_gpu (struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns) |
Provide frame timing information about GPU start and stop time. More... | |
static void | comp_target::comp_target_set_title (struct comp_target *ct, const char *title) |
If the target can show a title (like a window) set the title. More... | |
static void | comp_target::comp_target_destroy (struct comp_target **ct_ptr) |
Destroys this target. More... | |
static bool | comp_target_factory::comp_target_factory_detect (const struct comp_target_factory *ctf, struct comp_compositor *c) |
Checks if this target can be detected, is the preferred target or some other special consideration that this target should be used over all other targets. More... | |
static bool | comp_target_factory::comp_target_factory_create_target (const struct comp_target_factory *ctf, struct comp_compositor *c, struct comp_target **out_ct) |
Create a target from this factory, some targets requires Vulkan to have been initialised, see requires_vulkan_for_create. More... | |
void | comp_target_swapchain::comp_target_swapchain_init_and_set_fnptrs (struct comp_target_swapchain *cts, enum comp_target_display_timing_usage timing_usage) |
Pre Vulkan initialisation, sets function pointers. More... | |
void | comp_target_swapchain::comp_target_swapchain_override_extents (struct comp_target_swapchain *cts, VkExtent2D extent) |
Set that any size from the compositor should be ignored and that given size must be used for the VkSwapchain the helper code creates. More... | |
void | comp_target_swapchain::comp_target_swapchain_cleanup (struct comp_target_swapchain *cts) |
Free all managed resources on the given comp_target_swapchain, does not free the struct itself. More... | |
struct comp_target * | comp_window_xcb::comp_window_xcb_create (struct comp_compositor *c) |
Create a xcb window. More... | |
struct comp_target * | comp_window_wayland::comp_window_wayland_create (struct comp_compositor *c) |
Create a wayland window. More... | |
struct comp_target * | comp_window_direct_randr::comp_window_direct_randr_create (struct comp_compositor *c) |
Create a direct surface to an HMD over RandR. More... | |
struct comp_target * | comp_window_direct_nvidia::comp_window_direct_nvidia_create (struct comp_compositor *c) |
Create a direct surface to an HMD on NVIDIA. More... | |
bool | render_resources::render_resources_init (struct render_resources *r, struct render_shaders *shaders, struct vk_bundle *vk, struct xrt_device *xdev) |
Allocate pools and static resources. More... | |
Main compositor code.
#include <compositor/main/comp_target.h>
If the target should use the display timing information.
#include <compositor/main/comp_target.h>
For marking timepoints on a frame's lifetime, not a async event.
|
related |
Creates the main compositor, it doesn't return itself but instead wraps itself with a system compositor.
The main compositor is a native compositor.
xdev | The head device |
ctf | A compositor target factory to force the output device, must remain valid for the lifetime of the compositor. If NULL, factory is automatically selected |
out_xsysc | The output compositor |
struct comp_renderer * comp_renderer_create | ( | struct comp_compositor * | c, |
VkExtent2D | scratch_extent | ||
) |
Called by the main compositor code to create the renderer.
c | Owning compositor. |
scratch_extent | Size for scratch image used when squashing layers. |
References comp_renderer::c, renderer_init(), and U_TYPED_CALLOC.
void comp_renderer_destroy | ( | struct comp_renderer ** | ptr_r | ) |
Clean up and free the renderer.
Does null checking and sets to null after freeing.
XRT_CHECK_RESULT xrt_result_t comp_renderer_draw | ( | struct comp_renderer * | r | ) |
Render 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 xrt_device::hmd, xrt_hmd_parts::nominal_frame_interval_ns, and xrt_hmd_parts::screens.
|
inlinestatic |
Acquire the next image for rendering.
If comp_target_semaphores::present_complete is not null, your use of this image should wait on it..
|
inlinestatic |
Predict when the next frame should be started and when it will be turned into photons by the hardware.
|
inlinestatic |
Is this target ready for image creation?
Call before calling create_images
|
inlinestatic |
Create or recreate the image(s) of the target, for swapchain based targets this will (re)create the swapchain.
|
inlinestatic |
Destroys this target.
Helper for calling through the function pointer: does a null check and sets ct_ptr to null if freed.
References comp_target::destroy.
|
inlinestatic |
Create a target from this factory, some targets requires Vulkan to have been initialised, see requires_vulkan_for_create.
|
inlinestatic |
Checks if this target can be detected, is the preferred target or some other special consideration that this target should be used over all other targets.
This is needed for NVIDIA direct mode which window must be created after vulkan has initialized.
|
inlinestatic |
Flush any WSI state before rendering.
|
inlinestatic |
Has this target successfully had images created?
Call before calling acquire - if false but check_ready is true, you'll need to call create_images.
|
inlinestatic |
Provide frame timing information about GPU start and stop time.
Depend on when the information is delivered this can be called at any point of the following frames.
[in] | ct | The compositor target. |
[in] | frame_id | The frame ID to record for. |
[in] | gpu_start_ns | When the GPU work startred. |
[in] | gpu_end_ns | When the GPU work stopped. |
[in] | when_ns | When the informatioon collected, nominally from os_monotonic_get_ns. |
|
inlinestatic |
Do any initialization that requires Vulkan to be loaded, you need to call create_images after calling this function.
|
inlinestatic |
Do any initialization that is required to happen before Vulkan has been loaded.
|
inlinestatic |
Quick helper for marking begin.
The compositor tells the target a timing information about a single timing point on the frames lifecycle.
|
inlinestatic |
Quick helper for marking submit began.
The compositor tells the target a timing information about a single timing point on the frames lifecycle.
|
inlinestatic |
Quick helper for marking submit end.
The compositor tells the target a timing information about a single timing point on the frames lifecycle.
|
inlinestatic |
Quick helper for marking wake up.
The compositor tells the target a timing information about a single timing point on the frames lifecycle.
|
inlinestatic |
Present the image at index to the screen.
semaphore
and index
you are passingct | self |
queue | The Vulkan queue being used |
index | The swapchain image index to present |
timeline_semaphore_value | The value to await on comp_target_semaphores::render_complete if comp_target_semaphores::render_complete_is_timeline is true. |
desired_present_time_ns | The timestamp to present at, ideally. |
present_slop_ns | TODO |
|
inlinestatic |
If the target can show a title (like a window) set the title.
|
protected |
Free all managed resources on the given comp_target_swapchain, does not free the struct itself.
Referenced by comp_window_mswin_destroy().
|
protected |
Pre Vulkan initialisation, sets function pointers.
Call from the creation function for your "subclass", after allocating.
Initializes these function pointers, all other methods of comp_target are the responsibility of the caller (the "subclass"):
Also sets comp_target_swapchain::timing_usage to the provided value.
References comp_target_swapchain::base, comp_target::check_ready, and comp_target_swapchain::timing_usage.
Referenced by comp_window_direct_nvidia::comp_window_direct_nvidia_create(), comp_window_direct_randr::comp_window_direct_randr_create(), comp_window_direct_wayland_create(), comp_window_wayland::comp_window_wayland_create(), and comp_window_xcb::comp_window_xcb_create().
|
protected |
Set that any size from the compositor should be ignored and that given size must be used for the VkSwapchain
the helper code creates.
References comp_target_swapchain::base, comp_target::c, comp_compositor::COMP_INFO, comp_target_swapchain::compositor_extent, comp_target_swapchain::extent, and comp_target::name.
|
inlinestatic |
Update timing information for this target, this function should be lightweight and is called multiple times during a frame to make sure that we get the timing data as soon as possible.
struct comp_target * comp_window_direct_nvidia_create | ( | struct comp_compositor * | c | ) |
Create a direct surface to an HMD on NVIDIA.
References comp_target_swapchain::comp_target_swapchain_init_and_set_fnptrs(), and U_TYPED_CALLOC.
struct comp_target * comp_window_direct_randr_create | ( | struct comp_compositor * | c | ) |
Create a direct surface to an HMD over RandR.
References comp_target_swapchain::comp_target_swapchain_init_and_set_fnptrs(), and U_TYPED_CALLOC.
struct comp_target * comp_window_wayland_create | ( | struct comp_compositor * | c | ) |
Create a wayland window.
References comp_target_swapchain::comp_target_swapchain_init_and_set_fnptrs(), and U_TYPED_CALLOC.
struct comp_target * comp_window_xcb_create | ( | struct comp_compositor * | c | ) |
Create a xcb window.
References comp_target_swapchain::comp_target_swapchain_init_and_set_fnptrs(), and U_TYPED_CALLOC.
bool render_resources_init | ( | struct render_resources * | r, |
struct render_shaders * | shaders, | ||
struct vk_bundle * | vk, | ||
struct xrt_device * | xdev | ||
) |
Allocate pools and static resources.
References xrt_hmd_parts::distortion, render_resources::distortion_binding, xrt_device::hmd, render_resources::image_array_size, xrt_hmd_parts::index_count_total, xrt_hmd_parts::index_counts, xrt_hmd_parts::index_offsets, vk_bundle::max_per_stage_descriptor_sampled_images, render_resources::shaders, render_resources::src_binding, xrt_hmd_parts::stride, render_resources::target_binding, render_resources::ubo_binding, xrt_hmd_parts::vertex_count, render_resources::view_count, and render_resources::vk.