[cogl/cogl-1.20] kms-winsys: try to hobble along if driver doesn't support page flips
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl/cogl-1.20] kms-winsys: try to hobble along if driver doesn't support page flips
- Date: Mon, 23 Mar 2015 14:12:03 +0000 (UTC)
commit 68d9ba3b653a2fe0f0992ea2b6df753b3bfc9d61
Author: Ray Strode <rstrode redhat com>
Date: Wed Mar 11 12:09:51 2015 -0400
kms-winsys: try to hobble along if driver doesn't support page flips
Some drivers ( like mgag200 ) don't yet support drmModePageFlip.
This commit forgoes waiting for vblank and flips right away
in those cases. That prevents the hardware from freezing up the screen,
but does mean there will be some visible tearing.
https://bugzilla.gnome.org/show_bug.cgi?id=746042
cogl/winsys/cogl-winsys-egl-kms.c | 52 +++++++++++++++++++++++++++---------
1 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl-kms.c b/cogl/winsys/cogl-winsys-egl-kms.c
index b06c1da..c5d014a 100644
--- a/cogl/winsys/cogl-winsys-egl-kms.c
+++ b/cogl/winsys/cogl-winsys-egl-kms.c
@@ -72,6 +72,7 @@ typedef struct _CoglRendererKMS
int opened_fd;
struct gbm_device *gbm;
CoglClosure *swap_notify_idle;
+ CoglBool page_flips_not_supported;
} CoglRendererKMS;
typedef struct _CoglOutputKMS
@@ -224,14 +225,8 @@ queue_swap_notify_for_onscreen (CoglOnscreen *onscreen)
}
static void
-page_flip_handler (int fd,
- unsigned int frame,
- unsigned int sec,
- unsigned int usec,
- void *data)
+process_flip (CoglFlipKMS *flip)
{
- CoglFlipKMS *flip = data;
-
/* We're only ready to dispatch a swap notification once all outputs
* have flipped... */
flip->pending--;
@@ -258,10 +253,25 @@ page_flip_handler (int fd,
}
static void
+page_flip_handler (int fd,
+ unsigned int frame,
+ unsigned int sec,
+ unsigned int usec,
+ void *data)
+{
+ CoglFlipKMS *flip = data;
+
+ process_flip (flip);
+}
+
+static void
handle_drm_event (CoglRendererKMS *kms_renderer)
{
drmEventContext evctx;
+ if (kms_renderer->page_flips_not_supported)
+ return;
+
memset (&evctx, 0, sizeof evctx);
evctx.version = DRM_EVENT_CONTEXT_VERSION;
evctx.page_flip_handler = page_flip_handler;
@@ -575,6 +585,7 @@ flip_all_crtcs (CoglDisplay *display, CoglFlipKMS *flip, int fb_id)
CoglRendererEGL *egl_renderer = display->renderer->winsys;
CoglRendererKMS *kms_renderer = egl_renderer->platform;
GList *l;
+ gboolean needs_flip = FALSE;
for (l = kms_display->crtcs; l; l = l->next)
{
@@ -584,18 +595,26 @@ flip_all_crtcs (CoglDisplay *display, CoglFlipKMS *flip, int fb_id)
if (crtc->count == 0 || crtc->ignore)
continue;
- ret = drmModePageFlip (kms_renderer->fd,
- crtc->id, fb_id,
- DRM_MODE_PAGE_FLIP_EVENT, flip);
+ needs_flip = TRUE;
- if (ret)
+ if (!kms_renderer->page_flips_not_supported)
{
- g_warning ("Failed to flip: %m");
- continue;
+ ret = drmModePageFlip (kms_renderer->fd,
+ crtc->id, fb_id,
+ DRM_MODE_PAGE_FLIP_EVENT, flip);
+ if (ret)
+ {
+ g_warning ("Failed to flip: %m");
+ kms_renderer->page_flips_not_supported = TRUE;
+ break;
+ }
}
flip->pending++;
}
+
+ if (kms_renderer->page_flips_not_supported && needs_flip)
+ flip->pending = 1;
}
static void
@@ -945,6 +964,13 @@ _cogl_winsys_onscreen_swap_buffers_with_damage (CoglOnscreen *onscreen,
{
/* Ensure the onscreen remains valid while it has any pending flips... */
cogl_object_ref (flip->onscreen);
+
+ /* Process flip right away if we can't wait for vblank */
+ if (kms_renderer->page_flips_not_supported)
+ {
+ setup_crtc_modes (context->display, kms_onscreen->next_fb_id);
+ process_flip (flip);
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]