xserver: Branch 'master' - 3 commits
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Aug 6 15:35:48 UTC 2019
hw/xfree86/drivers/modesetting/dri2.c | 1
hw/xfree86/drivers/modesetting/driver.c | 24 +++++
hw/xfree86/drivers/modesetting/driver.h | 1
hw/xfree86/drivers/modesetting/drmmode_display.c | 107 ++++++++++++++++++++++-
hw/xfree86/drivers/modesetting/drmmode_display.h | 14 ++-
hw/xfree86/drivers/modesetting/present.c | 33 +++++--
6 files changed, 168 insertions(+), 12 deletions(-)
New commits:
commit 0aaac8d783e78c040a70a55ba8d67809abd7e625
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Jun 24 21:46:26 2019 +0200
modesetting: Disable pageflipping when using a swcursor
The miPointerSpriteFunc swcursor code expects there to only be a single
framebuffer and when the cursor moves it will undo the damage of the
previous draw, potentially overwriting what ever is there in a new
framebuffer installed after a flip.
This leads to all kind of artifacts, so we need to disable pageflipping
when a swcursor is used.
The code for this has shamelessly been copied from the xf86-video-amdgpu
code.
Fixes: https://gitlab.freedesktop.org/xorg/xserver/issues/828
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index 96eaaaaf7..29ffc24da 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -586,6 +586,7 @@ can_flip(ScrnInfoPtr scrn, DrawablePtr draw,
return draw->type == DRAWABLE_WINDOW &&
ms->drmmode.pageflip &&
+ !ms->drmmode.sprites_visible &&
!ms->drmmode.present_flipping &&
scrn->vtSema &&
DRI2CanFlip(draw) && can_exchange(scrn, draw, front, back);
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 8d29b130f..6f9f7c43a 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -41,6 +41,7 @@
#include "compiler.h"
#include "xf86Pci.h"
#include "mipointer.h"
+#include "mipointrst.h"
#include "micmap.h"
#include <X11/extensions/randr.h>
#include "fb.h"
@@ -1648,6 +1649,21 @@ ScreenInit(ScreenPtr pScreen, int argc, char **argv)
xf86SetSilkenMouse(pScreen);
miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+ /* If pageflip is enabled hook the screen's cursor-sprite (swcursor) funcs.
+ * So that we can disabe page-flipping on fallback to a swcursor. */
+ if (ms->drmmode.pageflip) {
+ miPointerScreenPtr PointPriv =
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ if (!dixRegisterScreenPrivateKey(&ms->drmmode.spritePrivateKeyRec,
+ pScreen, PRIVATE_DEVICE,
+ sizeof(msSpritePrivRec)))
+ return FALSE;
+
+ ms->SpriteFuncs = PointPriv->spriteFuncs;
+ PointPriv->spriteFuncs = &drmmode_sprite_funcs;
+ }
+
/* Need to extend HWcursor support to handle mask interleave */
if (!ms->drmmode.sw_cursor)
xf86_cursors_init(pScreen, ms->cursor_width, ms->cursor_height,
@@ -1844,6 +1860,14 @@ CloseScreen(ScreenPtr pScreen)
drmmode_free_bos(pScrn, &ms->drmmode);
+ if (ms->drmmode.pageflip) {
+ miPointerScreenPtr PointPriv =
+ dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey);
+
+ if (PointPriv->spriteFuncs == &drmmode_sprite_funcs)
+ PointPriv->spriteFuncs = ms->SpriteFuncs;
+ }
+
if (pScrn->vtSema) {
LeaveVT(pScrn);
}
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index c8db4b8a4..da25a4c0e 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -96,6 +96,7 @@ typedef struct _modesettingRec {
CreateScreenResourcesProcPtr createScreenResources;
ScreenBlockHandlerProcPtr BlockHandler;
+ miPointerSpriteFuncPtr SpriteFuncs;
void *driver;
drmmode_rec drmmode;
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index 930072f94..e0d7cfb5c 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -34,6 +34,7 @@
#include <sys/mman.h>
#include <unistd.h>
#include "dumb_bo.h"
+#include "inputstr.h"
#include "xf86str.h"
#include "X11/Xatom.h"
#include "micmap.h"
@@ -3911,3 +3912,102 @@ drmmode_get_default_bpp(ScrnInfoPtr pScrn, drmmode_ptr drmmode, int *depth,
drmModeFreeResources(mode_res);
return;
}
+
+/*
+ * We hook the screen's cursor-sprite (swcursor) functions to see if a swcursor
+ * is active. When a swcursor is active we disabe page-flipping.
+ */
+
+static void drmmode_sprite_do_set_cursor(msSpritePrivPtr sprite_priv,
+ ScrnInfoPtr scrn, int x, int y)
+{
+ modesettingPtr ms = modesettingPTR(scrn);
+ CursorPtr cursor = sprite_priv->cursor;
+ Bool sprite_visible = sprite_priv->sprite_visible;
+
+ if (cursor) {
+ x -= cursor->bits->xhot;
+ y -= cursor->bits->yhot;
+
+ sprite_priv->sprite_visible =
+ x < scrn->virtualX && y < scrn->virtualY &&
+ (x + cursor->bits->width > 0) &&
+ (y + cursor->bits->height > 0);
+ } else {
+ sprite_priv->sprite_visible = FALSE;
+ }
+
+ ms->drmmode.sprites_visible += sprite_priv->sprite_visible - sprite_visible;
+}
+
+static void drmmode_sprite_set_cursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ CursorPtr pCursor, int x, int y)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+ msSpritePrivPtr sprite_priv = msGetSpritePriv(pDev, ms, pScreen);
+
+ sprite_priv->cursor = pCursor;
+ drmmode_sprite_do_set_cursor(sprite_priv, scrn, x, y);
+
+ ms->SpriteFuncs->SetCursor(pDev, pScreen, pCursor, x, y);
+}
+
+static void drmmode_sprite_move_cursor(DeviceIntPtr pDev, ScreenPtr pScreen,
+ int x, int y)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+ msSpritePrivPtr sprite_priv = msGetSpritePriv(pDev, ms, pScreen);
+
+ drmmode_sprite_do_set_cursor(sprite_priv, scrn, x, y);
+
+ ms->SpriteFuncs->MoveCursor(pDev, pScreen, x, y);
+}
+
+static Bool drmmode_sprite_realize_realize_cursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ return ms->SpriteFuncs->RealizeCursor(pDev, pScreen, pCursor);
+}
+
+static Bool drmmode_sprite_realize_unrealize_cursor(DeviceIntPtr pDev,
+ ScreenPtr pScreen,
+ CursorPtr pCursor)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ return ms->SpriteFuncs->UnrealizeCursor(pDev, pScreen, pCursor);
+}
+
+static Bool drmmode_sprite_device_cursor_initialize(DeviceIntPtr pDev,
+ ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ return ms->SpriteFuncs->DeviceCursorInitialize(pDev, pScreen);
+}
+
+static void drmmode_sprite_device_cursor_cleanup(DeviceIntPtr pDev,
+ ScreenPtr pScreen)
+{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ ms->SpriteFuncs->DeviceCursorCleanup(pDev, pScreen);
+}
+
+miPointerSpriteFuncRec drmmode_sprite_funcs = {
+ .RealizeCursor = drmmode_sprite_realize_realize_cursor,
+ .UnrealizeCursor = drmmode_sprite_realize_unrealize_cursor,
+ .SetCursor = drmmode_sprite_set_cursor,
+ .MoveCursor = drmmode_sprite_move_cursor,
+ .DeviceCursorInitialize = drmmode_sprite_device_cursor_initialize,
+ .DeviceCursorCleanup = drmmode_sprite_device_cursor_cleanup,
+};
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index f4e5e508e..75c3195e4 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -111,6 +111,9 @@ typedef struct {
void *shadow_fb2;
DevPrivateKeyRec pixmapPrivateKeyRec;
+ DevScreenPrivateKeyRec spritePrivateKeyRec;
+ /* Number of SW cursors currently visible on this screen */
+ int sprites_visible;
Bool reverse_prime_offload_mode;
@@ -238,6 +241,15 @@ typedef struct _msPixmapPriv {
#define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
+typedef struct _msSpritePriv {
+ CursorPtr cursor;
+ Bool sprite_visible;
+} msSpritePrivRec, *msSpritePrivPtr;
+
+#define msGetSpritePriv(dev, ms, screen) dixLookupScreenPrivate(&(dev)->devPrivates, &(ms)->drmmode.spritePrivateKeyRec, screen)
+
+extern miPointerSpriteFuncRec drmmode_sprite_funcs;
+
Bool drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format,
uint64_t modifier);
int drmmode_bo_import(drmmode_ptr drmmode, drmmode_bo *bo,
diff --git a/hw/xfree86/drivers/modesetting/present.c b/hw/xfree86/drivers/modesetting/present.c
index dda7cc064..b87ba265f 100644
--- a/hw/xfree86/drivers/modesetting/present.c
+++ b/hw/xfree86/drivers/modesetting/present.c
@@ -209,13 +209,17 @@ ms_present_flip_abort(modesettingPtr ms, void *data)
/*
* Test to see if page flipping is possible on the target crtc
+ *
+ * We ignore sw-cursors when *disabling* flipping, we may very well be
+ * returning to scanning out the normal framebuffer *because* we just
+ * switched to sw-cursor mode and check_flip just failed because of that.
*/
static Bool
-ms_present_check_flip(RRCrtcPtr crtc,
- WindowPtr window,
- PixmapPtr pixmap,
- Bool sync_flip,
- PresentFlipReason *reason)
+ms_present_check_unflip(RRCrtcPtr crtc,
+ WindowPtr window,
+ PixmapPtr pixmap,
+ Bool sync_flip,
+ PresentFlipReason *reason)
{
ScreenPtr screen = window->drawable.pScreen;
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
@@ -282,6 +286,23 @@ ms_present_check_flip(RRCrtcPtr crtc,
return TRUE;
}
+static Bool
+ms_present_check_flip(RRCrtcPtr crtc,
+ WindowPtr window,
+ PixmapPtr pixmap,
+ Bool sync_flip,
+ PresentFlipReason *reason)
+{
+ ScreenPtr screen = window->drawable.pScreen;
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ modesettingPtr ms = modesettingPTR(scrn);
+
+ if (ms->drmmode.sprites_visible > 0)
+ return FALSE;
+
+ return ms_present_check_unflip(crtc, window, pixmap, sync_flip, reason);
+}
+
/*
* Queue a flip on 'crtc' to 'pixmap' at 'target_msc'. If 'sync_flip' is true,
* then wait for vblank. Otherwise, flip immediately
@@ -344,7 +365,7 @@ ms_present_unflip(ScreenPtr screen, uint64_t event_id)
event->event_id = event_id;
event->unflip = TRUE;
- if (ms_present_check_flip(NULL, screen->root, pixmap, TRUE, NULL) &&
+ if (ms_present_check_unflip(NULL, screen->root, pixmap, TRUE, NULL) &&
ms_do_pageflip(screen, pixmap, event, -1, FALSE,
ms_present_flip_handler, ms_present_flip_abort)) {
return;
commit 0331153b227c1cadf94f912cc02949d7159b02a2
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Jun 24 21:49:59 2019 +0200
modesetting: Fix compiler warning
Fix the following compiler warning:
drmmode_display.c: In function ‘drmmode_create_bo’:
drmmode_display.c:1019:9: warning: ISO C90 forbids mixed declarations and code [
1019 | uint32_t num_modifiers;
| ^~~~~~~~
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.c b/hw/xfree86/drivers/modesetting/drmmode_display.c
index cb48aa46b..930072f94 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.c
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.c
@@ -1008,6 +1008,10 @@ drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
#ifdef GLAMOR_HAS_GBM
if (drmmode->glamor) {
+#ifdef GBM_BO_WITH_MODIFIERS
+ uint32_t num_modifiers;
+ uint64_t *modifiers = NULL;
+#endif
uint32_t format;
if (drmmode->scrn->depth == 30)
@@ -1016,9 +1020,6 @@ drmmode_create_bo(drmmode_ptr drmmode, drmmode_bo *bo,
format = GBM_FORMAT_ARGB8888;
#ifdef GBM_BO_WITH_MODIFIERS
- uint32_t num_modifiers;
- uint64_t *modifiers = NULL;
-
num_modifiers = get_modifiers_set(drmmode->scrn, format, &modifiers,
FALSE, TRUE);
if (num_modifiers > 0 &&
commit 13f359fa838a9b5e855fbbee9c2f79bad84a1ace
Author: Hans de Goede <hdegoede at redhat.com>
Date: Mon Jun 24 21:20:06 2019 +0200
modesetting: Remove obsolete, unused msPixmapPrivate declaration and macro
When the pixmapPrivateKeyRec was moved from a global to being embedded
inside the drmmode_rec these 2 where missed, clean them up.
Reviewed-by: Michel Dänzer <michel.daenzer at amd.com>
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
diff --git a/hw/xfree86/drivers/modesetting/drmmode_display.h b/hw/xfree86/drivers/modesetting/drmmode_display.h
index cde661450..f4e5e508e 100644
--- a/hw/xfree86/drivers/modesetting/drmmode_display.h
+++ b/hw/xfree86/drivers/modesetting/drmmode_display.h
@@ -236,10 +236,6 @@ typedef struct _msPixmapPriv {
Bool notify_on_damage; /* if sink has requested damage notification */
} msPixmapPrivRec, *msPixmapPrivPtr;
-extern DevPrivateKeyRec msPixmapPrivateKeyRec;
-
-#define msPixmapPrivateKey (&msPixmapPrivateKeyRec)
-
#define msGetPixmapPriv(drmmode, p) ((msPixmapPrivPtr)dixGetPrivateAddr(&(p)->devPrivates, &(drmmode)->pixmapPrivateKeyRec))
Bool drmmode_is_format_supported(ScrnInfoPtr scrn, uint32_t format,
More information about the xorg-commit
mailing list