c/main: Be even more paranoid about display timing code

This commit is contained in:
Jakob Bornecrantz 2021-03-10 17:48:38 +00:00
parent dac5bc0ea5
commit 8992f79257
10 changed files with 44 additions and 17 deletions

View file

@ -32,6 +32,15 @@ enum comp_target_timing_point
COMP_TARGET_TIMING_POINT_SUBMIT, //<! Submitted work to the GPU.
};
/*!
* If the target should use the display timing information.
*/
enum comp_target_display_timing_usage
{
COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING = 0,
COMP_TARGET_USE_DISPLAY_IF_AVAILABLE = 1,
};
/*!
* Image and view pair for @ref comp_target.
*
@ -218,8 +227,13 @@ comp_target_create_images(struct comp_target *ct,
{
COMP_TRACE_MARKER();
ct->create_images(ct, preferred_width, preferred_height, preferred_color_format, preferred_color_space,
present_mode);
ct->create_images( //
ct, //
preferred_width, //
preferred_height, //
preferred_color_format, //
preferred_color_space, //
present_mode); //
}
/*!

View file

@ -95,16 +95,13 @@ comp_target_swapchain_create_images(struct comp_target *ct,
VkBool32 supported;
VkResult ret;
#ifndef XRT_OS_ANDROID
if (cts->uft == NULL && vk->has_GOOGLE_display_timing) {
// Some platforms really don't like the display_timing code.
bool use_display_timing_if_available = cts->timing_usage == COMP_TARGET_USE_DISPLAY_IF_AVAILABLE;
if (cts->uft == NULL && use_display_timing_if_available && vk->has_GOOGLE_display_timing) {
u_frame_timing_display_timing_create(ct->c->settings.nominal_frame_interval_ns, &cts->uft);
} else if (cts->uft == NULL) {
u_frame_timing_fake_create(ct->c->settings.nominal_frame_interval_ns, &cts->uft);
}
#else
COMP_INFO(ct->c, "Always using the fake timing code on Android.");
u_frame_timing_fake_create(ct->c->settings.nominal_frame_interval_ns, &cts->uft);
#endif
// Free old image views.
comp_target_swapchain_destroy_image_views(cts);
@ -645,8 +642,10 @@ comp_target_swapchain_cleanup(struct comp_target_swapchain *cts)
}
void
comp_target_swapchain_init_set_fnptrs(struct comp_target_swapchain *cts)
comp_target_swapchain_init_and_set_fnptrs(struct comp_target_swapchain *cts,
enum comp_target_display_timing_usage timing_usage)
{
cts->timing_usage = timing_usage;
cts->base.create_images = comp_target_swapchain_create_images;
cts->base.acquire = comp_target_swapchain_acquire_next_image;
cts->base.present = comp_target_swapchain_present;

View file

@ -41,6 +41,9 @@ struct comp_target_swapchain
//! Frame timing tracker.
struct u_frame_timing *uft;
//! If we should use display timing.
enum comp_target_display_timing_usage timing_usage;
//! Also works as a frame index.
int64_t current_frame_id;
@ -78,7 +81,8 @@ struct comp_target_swapchain
* @ingroup comp_main
*/
void
comp_target_swapchain_init_set_fnptrs(struct comp_target_swapchain *cts);
comp_target_swapchain_init_and_set_fnptrs(struct comp_target_swapchain *cts,
enum comp_target_display_timing_usage timing_usage);
/*!
* Free all managed resources on the given @ref comp_target_swapchain,

View file

@ -167,7 +167,8 @@ comp_window_android_create(struct comp_compositor *c)
{
struct comp_window_android *w = U_TYPED_CALLOC(struct comp_window_android);
comp_target_swapchain_init_set_fnptrs(&w->base);
// The display timing code hasn't been tested on Android and may be broken.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "Android";
w->base.base.destroy = comp_window_android_destroy;

View file

@ -86,7 +86,8 @@ comp_window_direct_nvidia_create(struct comp_compositor *c)
{
struct comp_window_direct_nvidia *w = U_TYPED_CALLOC(struct comp_window_direct_nvidia);
comp_target_swapchain_init_set_fnptrs(&w->base);
// The display timing code hasn't been tested on nVidia and may be broken.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "direct";
w->base.base.destroy = comp_window_direct_nvidia_destroy;

View file

@ -113,7 +113,8 @@ comp_window_direct_randr_create(struct comp_compositor *c)
{
struct comp_window_direct_randr *w = U_TYPED_CALLOC(struct comp_window_direct_randr);
comp_target_swapchain_init_set_fnptrs(&w->base);
// Display timing is tested and know working.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_USE_DISPLAY_IF_AVAILABLE);
w->base.base.name = "direct";
w->base.base.destroy = comp_window_direct_randr_destroy;

View file

@ -189,7 +189,8 @@ comp_window_mswin_create(struct comp_compositor *c)
{
struct comp_window_mswin *w = U_TYPED_CALLOC(struct comp_window_mswin);
comp_target_swapchain_init_set_fnptrs(&w->base);
// The display timing code hasn't been tested on Windows and may be broken.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "MS Windows";
w->base.base.destroy = comp_window_mswin_destroy;

View file

@ -84,7 +84,8 @@ comp_window_vk_display_create(struct comp_compositor *c)
{
struct comp_window_vk_display *w = U_TYPED_CALLOC(struct comp_window_vk_display);
comp_target_swapchain_init_set_fnptrs(&w->base);
// The display timing code hasn't been tested on vk display and may be broken.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "VkDisplayKHR";
w->base.base.destroy = comp_window_vk_display_destroy;

View file

@ -102,7 +102,8 @@ comp_window_wayland_create(struct comp_compositor *c)
{
struct comp_window_wayland *w = U_TYPED_CALLOC(struct comp_window_wayland);
comp_target_swapchain_init_set_fnptrs(&w->base);
// The display timing code hasn't been tested on Wayland and may be broken.
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "wayland";
w->base.base.destroy = comp_window_wayland_destroy;

View file

@ -128,7 +128,11 @@ comp_window_xcb_create(struct comp_compositor *c)
{
struct comp_window_xcb *w = U_TYPED_CALLOC(struct comp_window_xcb);
comp_target_swapchain_init_set_fnptrs(&w->base);
/*
* The display timing code has been tested on XCB,
* and is know to be broken when using VK_PRESENT_MODE_IMMEDIATE_KHR.
*/
comp_target_swapchain_init_and_set_fnptrs(&w->base, COMP_TARGET_FORCE_FAKE_DISPLAY_TIMING);
w->base.base.name = "xcb";
w->base.base.destroy = comp_window_xcb_destroy;