mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-11-19 14:45:29 +00:00
Wayland: Limit rendering to 120 FPS soon after a resize
For a second after a resize, render frames are not used, so that the resized buffer is filled immediately. This meant that continuous output was rendered as fast as possible, about 900 FPS, during that second. Now only the first render after the resize is immediate, subsequent renders are limited to 120 FPS, unless a render frame arrives sooner.
This commit is contained in:
parent
2e207a2f3c
commit
2eb1418d74
1 changed files with 12 additions and 1 deletions
|
|
@ -130,6 +130,9 @@ set_maximum_wait(monotonic_t val) {
|
|||
}
|
||||
|
||||
// Frame pacing {{{
|
||||
// The minimum interval between renders of an OS Window that are not paced by
|
||||
// render frames, as happens soon after a resize on Wayland (120 FPS)
|
||||
#define POST_RESIZE_MIN_RENDER_INTERVAL (MONOTONIC_T_1e9 / 120)
|
||||
// How often to retry rendering an OS Window whose buffers could not be swapped
|
||||
#define SWAP_RETRY_INTERVAL (10 * MONOTONIC_T_1e6)
|
||||
// The minimum interval between redraws used when syncing to the monitor
|
||||
|
|
@ -251,7 +254,15 @@ is_render_deferred_by_frame_pacing(OSWindow *w, monotonic_t now) {
|
|||
if (is_thumbnail) return false;
|
||||
// dont respect render frames soon after a resize on Wayland as they cause flicker because
|
||||
// we want to fill the newly resized buffer ASAP, not at compositors convenience
|
||||
if (global_state.is_wayland && (now - w->viewport_resized_at) <= s_double_to_monotonic_t(1)) return false;
|
||||
if (global_state.is_wayland && (now - w->viewport_resized_at) <= s_double_to_monotonic_t(1)) {
|
||||
// The first render after the resize is immediate, subsequent ones
|
||||
// are limited to a reasonable rate, otherwise continuous output
|
||||
// would be rendered as fast as possible during this period.
|
||||
if (w->last_rendered_at <= w->viewport_resized_at) return false;
|
||||
const monotonic_t since_last_render = now - w->last_rendered_at;
|
||||
if (since_last_render >= POST_RESIZE_MIN_RENDER_INTERVAL) return false;
|
||||
set_maximum_wait(POST_RESIZE_MIN_RENDER_INTERVAL - since_last_render);
|
||||
}
|
||||
w->tick_on_render_frame = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue