Skip to content

Commit

Permalink
Merge remote-tracking branch 'yshui/pacing-fixes' into pacing-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FT-Labs committed Dec 19, 2023
2 parents cd20347 + a5b2ceb commit 7b2fa9d
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion src/backend/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void apply_driver_workarounds(struct session *ps, enum driver driver) {
}

enum vblank_scheduler_type choose_vblank_scheduler(enum driver driver) {
if (driver & DRIVER_INTEL) {
if (driver & DRIVER_NVIDIA) {
return VBLANK_SCHEDULER_SGI_VIDEO_SYNC;
}
return VBLANK_SCHEDULER_PRESENT;
Expand Down
11 changes: 0 additions & 11 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,6 @@ struct shader_info {
UT_hash_handle hh;
};

enum render_progress {
/// Render is finished and presented to the screen.
RENDER_IDLE = 0,
/// Rendering is queued, but not started yet.
RENDER_QUEUED,
/// Backend has been called, render commands have been issued.
RENDER_STARTED,
/// Backend reported render commands have been finished. (not actually used).
RENDER_FINISHED,
};

/// Structure containing all necessary data for a session.
typedef struct session {
// === Event handlers ===
Expand Down
19 changes: 13 additions & 6 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,10 +624,14 @@ struct debug_options_entry {
};

// clang-format off
static const char *vblank_scheduler_choices[] = { "present", "sgi_video_sync", NULL };
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_choices, offsetof(struct debug_options, force_vblank_scheduler)},
{"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

Expand Down Expand Up @@ -655,11 +659,14 @@ void parse_debug_option_single(char *setting, struct debug_options *debug_option
}
if (!parse_int(arg, value)) {
log_error("Invalid value for debug option %s: %s, it "
"will be ignored",
setting, arg);
"will be ignored.",
debug_options_entries[i].name, arg);
}
} else {
} else if (debug_options_entries[i].choices == NULL) {
*value = 1;
} else {
log_error(
"Missing value for debug option %s, it will be ignored.", setting);
}
return;
}
Expand Down
8 changes: 1 addition & 7 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,7 @@ enum vblank_scheduler_type {
LAST_VBLANK_SCHEDULER,
};

static inline const char *vblank_scheduler_type_str(enum vblank_scheduler_type type) {
switch (type) {
case VBLANK_SCHEDULER_PRESENT: return "present";
case VBLANK_SCHEDULER_SGI_VIDEO_SYNC: return "sgi_video_sync";
default: return "invalid";
}
}
extern const char *vblank_scheduler_str[];

/// Internal, private options for debugging and development use.
struct debug_options {
Expand Down
7 changes: 3 additions & 4 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,9 @@ void collect_vblank_interval_statistics(struct vblank_event *e, void *ud) {

void schedule_render(session_t *ps, bool triggered_by_vblank);

/// vblank callback scheduled by schedule_render.
/// vblank callback scheduled by schedule_render, when a render is ongoing.
///
/// Check if previously queued render has finished, and record the time it took.
/// Check if previously queued render has finished, and reschedule render if it has.
void reschedule_render_at_vblank(struct vblank_event *e, void *ud) {
auto ps = (session_t *)ud;
assert(ps->frame_pacing);
Expand Down Expand Up @@ -1675,8 +1675,7 @@ static bool redirect_start(session_t *ps) {
scheduler_type =
(enum vblank_scheduler_type)ps->o.debug_options.force_vblank_scheduler;
}
log_info("Using vblank scheduler: %s.",
vblank_scheduler_type_str(scheduler_type));
log_info("Using vblank scheduler: %s.", vblank_scheduler_str[scheduler_type]);
ps->vblank_scheduler = vblank_scheduler_new(
ps->loop, &ps->c, session_get_target_window(ps), scheduler_type);
if (!ps->vblank_scheduler) {
Expand Down
3 changes: 2 additions & 1 deletion src/vblank.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <time.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
#include "config.h"

#ifdef CONFIG_OPENGL
// Enable sgi_video_sync_vblank_scheduler
Expand Down Expand Up @@ -526,4 +527,4 @@ bool vblank_handle_x_events(struct vblank_scheduler *self) {
return fn(self);
}
return true;
}
}

0 comments on commit 7b2fa9d

Please sign in to comment.