core: add debug options to override the vblank scheduler

Useful for debugging.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui
2023-12-19 10:29:31 +00:00
parent 5ee7b09542
commit 4080a8d254
3 changed files with 24 additions and 8 deletions

View File

@@ -623,11 +623,17 @@ struct debug_options_entry {
size_t offset;
};
static const struct debug_options_entry debug_options_entries[] = {
"smart_frame_pacing",
NULL,
offsetof(struct debug_options, smart_frame_pacing),
// clang-format off
const char *vblank_scheduler_str[] = {
[VBLANK_SCHEDULER_PRESENT] = "present",
[VBLANK_SCHEDULER_SGI_VIDEO_SYNC] = "sgi_video_sync",
[LAST_VBLANK_SCHEDULER] = NULL
};
static const struct debug_options_entry debug_options_entries[] = {
{"smart_frame_pacing", NULL, offsetof(struct debug_options, smart_frame_pacing)},
{"force_vblank_sched", vblank_scheduler_str, 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, '=');
@@ -670,7 +676,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) {

View File

@@ -83,11 +83,15 @@ enum vblank_scheduler_type {
LAST_VBLANK_SCHEDULER,
};
extern const char *vblank_scheduler_str[];
/// Internal, private options for debugging and development use.
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.

View File

@@ -1492,9 +1492,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),
VBLANK_SCHEDULER_PRESENT);
enum vblank_scheduler_type scheduler_type = VBLANK_SCHEDULER_PRESENT;
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;
}