Monado OpenXR Runtime
Loading...
Searching...
No Matches
comp_target_swapchain.c File Reference

Target Vulkan swapchain code. More...

#include "os/os_threading.h"
#include "util/u_misc.h"
#include "util/u_pacing.h"
#include "util/u_debug.h"
#include "util/u_pretty_print.h"
#include "util/u_thread_priority.h"
#include "vk/vk_surface_info.h"
#include "main/comp_compositor.h"
#include "main/comp_target_swapchain.h"
#include <assert.h>
#include <stdlib.h>
Include dependency graph for comp_target_swapchain.c:

Functions

static struct vk_bundle * get_vk (struct comp_target_swapchain *cts)
 
static bool is_shared_present_mode (struct vk_bundle *vk, VkPresentModeKHR present_mode)
 
static bool is_shared_presentable_image (struct comp_target_swapchain *cts)
 
static void destroy_old (struct comp_target_swapchain *cts, VkSwapchainKHR old)
 
static void ensure_pacer (struct comp_target_swapchain *cts, bool use_display_timing_if_available)
 Only the first call creates the pacer, so a failed first swapchain creation locks in a pacer picked without any swapchain properties.
 
static void destroy_image_views (struct comp_target_swapchain *cts)
 
static void create_image_views (struct comp_target_swapchain *cts)
 
static VkExtent2D select_extent (struct comp_target_swapchain *cts, VkSurfaceCapabilitiesKHR caps, VkExtent2D preferred)
 
static uint32_t select_image_count (struct comp_target_swapchain *cts, VkSurfaceCapabilitiesKHR caps, uint32_t preferred_at_least_image_count)
 
static bool check_surface_present_mode (struct comp_target_swapchain *cts, const struct vk_surface_info *info, VkImageUsageFlags image_usage, VkPresentModeKHR present_mode)
 
static bool pick_first_matching_surface_format (const struct comp_target_create_images_info *create_info, VkSurfaceFormatKHR *surface_formats, uint32_t surface_format_count, VkSurfaceFormatKHR *out_surface_format)
 
static bool find_surface_format (struct comp_target_swapchain *cts, const struct comp_target_create_images_info *create_info, const struct vk_surface_info *info, VkSurfaceFormatKHR *out_surface_format)
 
static void do_update_timings_google_display_timing (struct comp_target_swapchain *cts)
 
static void do_update_timings_vblank_thread (struct comp_target_swapchain *cts)
 
static void target_fini_semaphores (struct comp_target_swapchain *cts)
 
static void target_init_semaphores (struct comp_target_swapchain *cts)
 
static void comp_target_swapchain_create_images (struct comp_target *ct, const struct comp_target_create_images_info *create_info, struct vk_bundle_queue *present_queue)
 
static bool comp_target_swapchain_has_images (struct comp_target *ct)
 
static VkResult comp_target_swapchain_acquire_next_image (struct comp_target *ct, uint32_t *out_index)
 
static VkResult comp_target_swapchain_present (struct comp_target *ct, struct vk_bundle_queue *present_queue, uint32_t index, uint64_t timeline_semaphore_value, int64_t desired_present_time_ns, int64_t present_slop_ns)
 
static VkResult comp_target_swapchain_wait_for_present (struct comp_target *ct, time_duration_ns timeout_ns)
 
static bool comp_target_swapchain_check_ready (struct comp_target *ct)
 
static bool comp_target_swapchain_is_shared_presentable_image (struct comp_target *ct)
 
static void comp_target_swapchain_allocate_frame (struct comp_target *ct, int64_t *out_frame_id)
 
static void comp_target_swapchain_update_present_offset (struct comp_target *ct, int64_t frame_id, int64_t present_to_display_offset_ns)
 
static void comp_target_swapchain_calc_frame_pacing (struct comp_target *ct, int64_t 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)
 
static void comp_target_swapchain_mark_timing_point (struct comp_target *ct, enum comp_target_timing_point point, int64_t frame_id, int64_t when_ns)
 
static VkResult comp_target_swapchain_update_timings (struct comp_target *ct)
 
static void comp_target_swapchain_info_gpu (struct comp_target *ct, int64_t frame_id, int64_t gpu_start_ns, int64_t gpu_end_ns, int64_t when_ns)
 
void comp_target_swapchain_override_extents (struct comp_target_swapchain *cts, VkExtent2D extent)
 
void comp_target_swapchain_cleanup (struct comp_target_swapchain *cts)
 
static VkResult comp_target_swapchain_queue_supports_present (struct comp_target *ct, struct vk_bundle_queue *queue, VkBool32 *out_supported)
 
void comp_target_swapchain_init_and_set_fnptrs (struct comp_target_swapchain *cts, enum comp_target_display_timing_usage timing_usage)
 

Detailed Description

Function Documentation

◆ comp_target_swapchain_acquire_next_image()

static VkResult comp_target_swapchain_acquire_next_image ( struct comp_target *  ct,
uint32_t *  out_index 
)
static

◆ ensure_pacer()

static void ensure_pacer ( struct comp_target_swapchain *  cts,
bool  use_display_timing_if_available 
)
static

Only the first call creates the pacer, so a failed first swapchain creation locks in a pacer picked without any swapchain properties.

References comp_target_swapchain::base, comp_target::c, comp_compositor::frame_interval_ns, os_monotonic_get_ns(), u_pc_display_timing_create(), u_pc_display_timing_get_default_config(), u_pc_fake_create(), and comp_target_swapchain::upc.

◆ select_image_count()

static uint32_t select_image_count ( struct comp_target_swapchain *  cts,
VkSurfaceCapabilitiesKHR  caps,
uint32_t  preferred_at_least_image_count 
)
static

Ignore caps.minImageCount as it was observed one android device it's value was still > 1 for non-shared present modes.