Merge pull request #1346 from emersion/fix-schedule-frame-mgpu

backend/drm: fix frame scheduling on secondary GPUs
This commit is contained in:
Drew DeVault 2018-10-30 01:59:25 +01:00 committed by GitHub
commit 70ca7daeb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 11 deletions

View File

@ -735,11 +735,11 @@ static bool drm_connector_move_cursor(struct wlr_output *output,
return ok; return ok;
} }
static void drm_connector_schedule_frame(struct wlr_output *output) { static bool drm_connector_schedule_frame(struct wlr_output *output) {
struct wlr_drm_connector *conn = get_drm_connector_from_output(output); struct wlr_drm_connector *conn = get_drm_connector_from_output(output);
struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend); struct wlr_drm_backend *drm = get_drm_backend_from_backend(output->backend);
if (!drm->session->active) { if (!drm->session->active) {
return; return false;
} }
// We need to figure out where we are in the vblank cycle // We need to figure out where we are in the vblank cycle
@ -747,29 +747,33 @@ static void drm_connector_schedule_frame(struct wlr_output *output) {
struct wlr_drm_crtc *crtc = conn->crtc; struct wlr_drm_crtc *crtc = conn->crtc;
if (!crtc) { if (!crtc) {
return; return false;
} }
struct wlr_drm_plane *plane = crtc->primary; struct wlr_drm_plane *plane = crtc->primary;
struct gbm_bo *bo = plane->surf.back; struct gbm_bo *bo = plane->surf.back;
if (!bo) { if (!bo) {
// We haven't swapped buffers yet -- can't do a pageflip // We haven't swapped buffers yet -- can't do a pageflip
wlr_output_send_frame(output); wlr_output_send_frame(output);
return; return true;
}
if (drm->parent) {
bo = copy_drm_surface_mgpu(&plane->mgpu_surf, bo);
} }
uint32_t fb_id = get_fb_for_bo(bo); uint32_t fb_id = get_fb_for_bo(bo);
if (conn->pageflip_pending) { if (conn->pageflip_pending) {
wlr_log(WLR_ERROR, "Skipping pageflip on output '%s'", wlr_log(WLR_ERROR, "Skipping pageflip on output '%s'",
conn->output.name); conn->output.name);
return; return true;
} }
if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) { if (!drm->iface->crtc_pageflip(drm, conn, crtc, fb_id, NULL)) {
return; return false;
} }
conn->pageflip_pending = true; conn->pageflip_pending = true;
wlr_output_update_enabled(output, true); wlr_output_update_enabled(output, true);
return true;
} }
static void drm_connector_destroy(struct wlr_output *output) { static void drm_connector_destroy(struct wlr_output *output) {

View File

@ -197,17 +197,18 @@ static bool output_move_cursor(struct wlr_output *_output, int x, int y) {
return true; return true;
} }
static void output_schedule_frame(struct wlr_output *wlr_output) { static bool output_schedule_frame(struct wlr_output *wlr_output) {
struct wlr_wl_output *output = get_wl_output_from_output(wlr_output); struct wlr_wl_output *output = get_wl_output_from_output(wlr_output);
if (output->frame_callback != NULL) { if (output->frame_callback != NULL) {
wlr_log(WLR_ERROR, "Skipping frame scheduling"); wlr_log(WLR_ERROR, "Skipping frame scheduling");
return; return true;
} }
output->frame_callback = wl_surface_frame(output->surface); output->frame_callback = wl_surface_frame(output->surface);
wl_callback_add_listener(output->frame_callback, &frame_listener, output); wl_callback_add_listener(output->frame_callback, &frame_listener, output);
wl_surface_commit(output->surface); wl_surface_commit(output->surface);
return true;
} }
static const struct wlr_output_impl output_impl = { static const struct wlr_output_impl output_impl = {

View File

@ -33,7 +33,7 @@ struct wlr_output_impl {
size_t (*get_gamma_size)(struct wlr_output *output); size_t (*get_gamma_size)(struct wlr_output *output);
bool (*export_dmabuf)(struct wlr_output *output, bool (*export_dmabuf)(struct wlr_output *output,
struct wlr_dmabuf_attributes *attribs); struct wlr_dmabuf_attributes *attribs);
void (*schedule_frame)(struct wlr_output *output); bool (*schedule_frame)(struct wlr_output *output);
}; };
void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend, void wlr_output_init(struct wlr_output *output, struct wlr_backend *backend,

View File

@ -547,8 +547,9 @@ static void schedule_frame_handle_idle_timer(void *data) {
output->idle_frame = NULL; output->idle_frame = NULL;
if (!output->frame_pending && output->impl->schedule_frame) { if (!output->frame_pending && output->impl->schedule_frame) {
// Ask the backend to send a frame event when appropriate // Ask the backend to send a frame event when appropriate
if (output->impl->schedule_frame(output)) {
output->frame_pending = true; output->frame_pending = true;
output->impl->schedule_frame(output); }
} }
} }