screen / framebuffer widths which are not a multiple of 64 + Present extension + using modifiers is causing present-flip errors
The root-cause of this is likely a mesa issue and I've also filed a mesa bug for this, see: https://bugs.freedesktop.org/show_bug.cgi?id=111306
I'm still filing an xserver bug for this because:
- This is a regression compared to 1.20, triggered by enabling modifier support in glamor
- This may require some work on the xserver side too
- This can be worked around on the xserver side
The problem is that when the user ends up with a screen / framebuffer width which is not a multiple of 64 and Present flipping is used, the drmModeAddFB2WithModifiers calls done to create a drmfb to flip fail and the log fills with these errors:
[ 28843.414] (WW) modeset(0): Page flip failed: Invalid argument
[ 28843.414] (EE) modeset(0): present flip failed
[ 28843.595] (WW) modeset(0): Page flip failed: Invalid argument
[ 28843.595] (EE) modeset(0): present flip failed
Reproduction instructions:
- Take a Skylake iGPU (in my case with 2 1920x1080 monitors attached)
- Run Xorg master with the modesetting driver (master is necessary because glamor has support for modifiers enabled only in master)
- Run a recent gnome-shell on top of Xorg
- Run xrandr --fb x changing the width to be 32 pixels larger then necessary (or any other value not a multiple of 64)
- Watch Xorg.log filling with errors like these:
A quick and dirty xserver side workaround is this:
diff --git a/hw/xfree
86/modes/xf86RandR12.c b/hw/xfree86/modes/xf86RandR12.c
index b476c07ce..846a2325a 100644
--- a/hw/xfree86/modes/xf86RandR12.c
+++ b/hw/xfree86/modes/xf86RandR12.c
@@ -693,6 +693,12 @@ xf86RandR12ScreenSetSize(ScreenPtr pScreen,
if (pRoot && pScrn->vtSema)
(*pScrn->EnableDisableFBAccess) (pScrn, FALSE);
+ /*
+ * Present flipping with modifiers may fail if our screen width is not
+ * a multiple of 64.
+ */
+ width = (width + 63) & ~63;
+
/* Let the driver update virtualX and virtualY */
if (!(*config->funcs->resize) (pScrn, width, height))
goto finish;
Which works surprisingly well, so we may even consider actually going with this as a workaround.