diff --git a/src/config.c b/src/config.c index 316438e..2299039 100644 --- a/src/config.c +++ b/src/config.c @@ -623,11 +623,13 @@ struct debug_options_entry { size_t offset; }; +// clang-format off +static const char *vblank_scheduler_choices[] = { "present", "sgi_video_sync", NULL }; static const struct debug_options_entry debug_options_entries[] = { - "smart_frame_pacing", - NULL, - offsetof(struct debug_options, smart_frame_pacing), + {"smart_frame_pacing", NULL, offsetof(struct debug_options, smart_frame_pacing)}, + {"force_vblank_sched", vblank_scheduler_choices, offsetof(struct debug_options, force_vblank_scheduler)}, }; +// clang-format on void parse_debug_option_single(char *setting, struct debug_options *debug_options) { char *equal = strchr(setting, '='); @@ -667,7 +669,9 @@ void parse_debug_option_single(char *setting, struct debug_options *debug_option /// Parse debug options from environment variable `PICOM_DEBUG`. void parse_debug_options(struct debug_options *debug_options) { const char *debug = getenv("PICOM_DEBUG"); - const struct debug_options default_debug_options = {}; + const struct debug_options default_debug_options = { + .force_vblank_scheduler = LAST_VBLANK_SCHEDULER, + }; *debug_options = default_debug_options; if (!debug) { diff --git a/src/config.h b/src/config.h index b414b9a..760088c 100644 --- a/src/config.h +++ b/src/config.h @@ -88,6 +88,8 @@ struct debug_options { /// Try to reduce frame latency by using vblank interval and render time /// estimates. Right now it's not working well across drivers. int smart_frame_pacing; + /// Override the vblank scheduler chosen by the compositor. + int force_vblank_scheduler; }; /// Structure representing all options. diff --git a/src/picom.c b/src/picom.c index 9ca6c96..819a924 100644 --- a/src/picom.c +++ b/src/picom.c @@ -1489,9 +1489,13 @@ static bool redirect_start(session_t *ps) { ps->last_msc = 0; ps->last_schedule_delay = 0; render_statistics_reset(&ps->render_stats); - ps->vblank_scheduler = - vblank_scheduler_new(ps->loop, &ps->c, session_get_target_window(ps), - PRESENT_VBLANK_SCHEDULER); + enum vblank_scheduler_type scheduler_type = PRESENT_VBLANK_SCHEDULER; + if (ps->o.debug_options.force_vblank_scheduler != LAST_VBLANK_SCHEDULER) { + scheduler_type = + (enum vblank_scheduler_type)ps->o.debug_options.force_vblank_scheduler; + } + ps->vblank_scheduler = vblank_scheduler_new( + ps->loop, &ps->c, session_get_target_window(ps), scheduler_type); if (!ps->vblank_scheduler) { return false; }