Skip to content

Commit

Permalink
driver: choose sgi_video_sync scheduler for NVIDIA
Browse files Browse the repository at this point in the history
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
  • Loading branch information
yshui committed Dec 19, 2023
1 parent b582d29 commit a28e221
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 7 additions & 0 deletions src/backend/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ void apply_driver_workarounds(struct session *ps, enum driver driver) {
}
}

enum vblank_scheduler_type choose_vblank_scheduler(enum driver driver) {
if (driver & DRIVER_NVIDIA) {
return VBLANK_SCHEDULER_SGI_VIDEO_SYNC;
}
return VBLANK_SCHEDULER_PRESENT;
}

enum driver detect_driver(xcb_connection_t *c, backend_t *backend_data, xcb_window_t window) {
enum driver ret = 0;
// First we try doing backend agnostic detection using RANDR
Expand Down
3 changes: 3 additions & 0 deletions src/backend/driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <stdio.h>
#include <xcb/xcb.h>

#include "config.h"
#include "utils.h"

struct session;
Expand Down Expand Up @@ -41,6 +42,8 @@ enum driver detect_driver(xcb_connection_t *, struct backend_base *, xcb_window_

/// Apply driver specified global workarounds. It's safe to call this multiple times.
void apply_driver_workarounds(struct session *ps, enum driver);
/// Choose a vblank scheduler based on the driver.
enum vblank_scheduler_type choose_vblank_scheduler(enum driver driver);

// Print driver names to stdout, for diagnostics
static inline void print_drivers(enum driver drivers) {
Expand Down
12 changes: 7 additions & 5 deletions src/picom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,18 +1493,24 @@ static bool redirect_start(session_t *ps) {
ps->frame_pacing = false;
}

// Re-detect driver since we now have a backend
ps->drivers = detect_driver(ps->c.c, ps->backend_data, ps->c.screen_info->root);
apply_driver_workarounds(ps, ps->drivers);

if (ps->present_exists && ps->frame_pacing) {
// Initialize rendering and frame timing statistics, and frame pacing
// states.
ps->last_msc_instant = 0;
ps->last_msc = 0;
ps->last_schedule_delay = 0;
render_statistics_reset(&ps->render_stats);
enum vblank_scheduler_type scheduler_type = VBLANK_SCHEDULER_PRESENT;
enum vblank_scheduler_type scheduler_type =
choose_vblank_scheduler(ps->drivers);
if (ps->o.debug_options.force_vblank_scheduler != LAST_VBLANK_SCHEDULER) {
scheduler_type =
(enum vblank_scheduler_type)ps->o.debug_options.force_vblank_scheduler;
}
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 All @@ -1523,10 +1529,6 @@ static bool redirect_start(session_t *ps) {
ps->redirected = true;
ps->first_frame = true;

// Re-detect driver since we now have a backend
ps->drivers = detect_driver(ps->c.c, ps->backend_data, ps->c.screen_info->root);
apply_driver_workarounds(ps, ps->drivers);

root_damaged(ps);

// Repaint the whole screen
Expand Down

0 comments on commit a28e221

Please sign in to comment.