present: Check that we can get a KMS FB for flipping

This can legitimately fail if the pixmap's storage is shared from
another device, e.g. when using PRIME render offloading.
This commit is contained in:
Michel Dänzer
2019-05-09 17:39:49 +02:00
committed by Michel Dänzer
parent ea19a52070
commit 7d3fef72e0
2 changed files with 19 additions and 0 deletions

View File

@@ -36,6 +36,7 @@ struct amdgpu_pixmap {
struct amdgpu_buffer *bo;
struct drmmode_fb *fb;
Bool fb_failed;
/* GEM handle for pixmaps shared via DRI2/3 */
Bool handle_valid;

View File

@@ -255,6 +255,7 @@ amdgpu_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap,
xf86CrtcPtr xf86_crtc = crtc->devPrivate;
ScreenPtr screen = window->drawable.pScreen;
ScrnInfoPtr scrn = xf86_crtc->scrn;
struct amdgpu_pixmap *priv = amdgpu_get_pixmap_private(pixmap);
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(scrn);
AMDGPUInfoPtr info = AMDGPUPTR(scrn);
@@ -278,6 +279,23 @@ amdgpu_present_check_flip(RRCrtcPtr crtc, WindowPtr window, PixmapPtr pixmap,
return FALSE;
#endif
if (priv && priv->fb_failed)
return FALSE;
if (!amdgpu_pixmap_get_fb(pixmap)) {
if (!priv)
priv = amdgpu_get_pixmap_private(pixmap);
if (priv && !priv->fb_failed) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"Cannot get FB for Present flip (may be "
"normal if using PRIME render offloading)\n");
priv->fb_failed = TRUE;
}
return FALSE;
}
/* Only DC supports advanced color management features, so we can use
* drmmode_cm_enabled as a proxy for "Is DC enabled?"
*/