Add support for max_render_time auto

Output max_render_time allows configuring how many milliseconds before
the next pageflip that composition should start, which differs from the
normal strategy of just rendering right after the previous pageflip.

max_render_time auto tracks render timings per output and adjusts
max_render_time at runtime, balancing latency and headroom based on the
currently observed performance.

The algorithm and numbers chosen in this commit are mostly arbitrary,
intended to later be optimized and tuned.
This commit is contained in:
Kenny Levinsen 2026-03-07 13:51:36 +01:00
parent c57daaf0d1
commit fda1a81cf0
7 changed files with 141 additions and 44 deletions

View file

@ -291,7 +291,7 @@ struct output_config {
enum scale_filter_mode scale_filter;
int32_t transform;
enum wl_output_subpixel subpixel;
int max_render_time; // In milliseconds
int max_render_time; // In milliseconds, -2 means auto
int adaptive_sync;
enum render_bit_depth render_bit_depth;
enum color_profile color_profile;

View file

@ -5,6 +5,7 @@
#include <wayland-server-core.h>
#include <wlr/types/wlr_damage_ring.h>
#include <wlr/types/wlr_output.h>
#include <wlr/render/drm_syncobj.h>
#include <wlr/types/wlr_scene.h>
#include "config.h"
#include "sway/tree/node.h"
@ -66,9 +67,15 @@ struct sway_output {
struct timespec last_presentation;
uint32_t refresh_nsec;
int max_render_time; // In milliseconds
int64_t max_render_time_ns;
struct wl_event_source *repaint_timer;
bool adaptive_render_time;
struct timespec render_start;
struct wlr_drm_syncobj_timeline_waiter render_waiter;
bool render_waiter_active;
int64_t render_ema_ns;
bool allow_tearing;
bool hdr;
};