xserver/hw/xfree86
Mario Kleiner 8f8ebf870b modesetting: Allow Present flips with mismatched stride on atomic drivers.
When using DRI3+Present with PRIME render offload, sometimes there is
a mismatch between the stride of the to-be-presented Pixmap and the
frontbuffer. The current code would reject a pageflip present in this
case if atomic modesetting is not enabled, ie. always, as atomic
modesetting is disabled by default due to brokeness in the current
modesetting-ddx.

Fullscreen presents without page flipping however trigger the copy
path as fallback, which causes not only unreliable presentation timing
and degraded performance, but also massive tearing artifacts due to
rendering to the framebuffer without any hardware sync to vblank.
Tearing is extra awful on modesetting-ddx because glamor afaics seems
to use drawing of a textured triangle strip for the copy implementation,
not a dedicated blitter engine. The rasterization pattern creates extra
awful tearing artifacts.

We can do better: According to a tip from Michel Daenzer (thanks!),
at least atomic modesetting capable kms drivers should be able to
reliably change scanout stride during a pageflip, even if atomic
modesetting is not actually enabled for the modesetting client.

This commit adds detection logic to find out if the underlying kms
driver is atomic_modeset_capable, and if so, it no longer rejects
page flip presents on mismatched stride between new Pixmap and
frontbuffer.

We (ab)use a call to drmSetClientCap(ms->fd, DRM_CLIENT_CAP_ATOMIC, 0);
for this purpose. The call itself has no practical effect, as it
requests disabling atomic mode, although atomic mode is disabled by
default. However, the return value of drmSetClientCap() tells us if the
underlying kms driver is atomic modesetting capable: An atomic driver
will return 0 for success. A legacy non-atomic driver will return a
non-zero error code, either -EINVAL for early atomic Linux versions
4.0 - 4.19 (or for non-atomic Linux 3.x and earlier), or -EOPNOTSUPP
for Linux 4.20 and later.

Testing on a MacBookPro 2017 with Intel Kabylake display server gpu +
AMD Polaris11 as prime renderoffload gpu, X-Server master + Mesa 21.0.3
show improvement from unbearable tearing to perfect, despite a stride
mismatch between display gpu and Pixmap of 11776 Bytes vs. 11520
Bytes. That this is correct behaviour was also confirmed by comparing the
behaviour and .check_flip implementation of the patched modesetting-ddx
against the current intel-ddx SNA Present implementation.

Please consider merging this patch before the server-1.21 branch point.
This patch could also be cherry-picked into the server 1.20 branch to
fix the same limitation.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2021-09-07 09:21:39 +00:00
..
common xf86: Assign GPUs to screens according to configuration 2021-07-30 00:27:39 +00:00
ddc xfree86: fix gtf support detection for EDID 1.4 2021-04-06 11:25:42 +00:00
dixmods mi: List extensions in usage message 2021-01-29 12:52:09 +00:00
doc meson: Implement developer documentation build 2021-08-20 10:26:07 +00:00
dri Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
dri2 dri2: Sync i965_pci_ids.h from mesa iris_pci_ids.h 2021-04-24 19:21:41 +00:00
drivers modesetting: Allow Present flips with mismatched stride on atomic drivers. 2021-09-07 09:21:39 +00:00
exa meson: Install man pages 2018-03-27 10:28:33 -04:00
fbdevhw Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
glamor_egl glamor: Make Xv extension initialize at depth 30. 2018-02-27 10:18:06 -05:00
i2c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
int10 int10: wrap entire V_ADDR_R* macros in parens for safer expansion 2020-11-17 18:43:39 -08:00
loader loader: strdup const string assigned to local variable name 2020-01-28 20:35:06 +00:00
man Update URL's in man pages 2020-05-10 17:46:33 -07:00
modes xfree86: Move xf86CVTMode() function 2021-08-06 11:29:29 +00:00
os-support xfree86: Fix potentially NULL reference to platform device's PCI device 2021-06-23 14:29:10 +03:00
parser Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
ramdac xfree86: Take second reference for SavedCursor in xf86CursorSetCursor 2020-08-31 12:10:43 +02:00
shadowfb meson: Fix linkage of loadable modules for PE/COFF 2017-10-12 15:22:04 -04:00
utils xfree86/cvt: Drop cvt utility 2021-08-06 11:29:29 +00:00
vgahw Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
x86emu Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
xkb XKB: Add debug key actions for grabs & window tree 2020-07-31 05:25:50 +00:00
.gitignore Xorg: Add Xorg.wrap to hw/xfree86/.gitignore 2014-04-18 11:39:16 +02:00
Makefile.am xfree86: Merge vbe into int10 2019-10-02 10:03:26 -04:00
Xorg.sh.in xfree86: rename Xorg.bin to Xorg 2015-01-05 09:53:58 +10:00
meson.build meson: Implement developer documentation build 2021-08-20 10:26:07 +00:00
sdksyms.sh Consolidate fourcc.h 2020-09-15 11:43:16 +02:00
xorg-wrapper.c Fix various spelling errors 2019-10-01 17:05:28 +00:00
xorgconf.cpp Fix spelling/wording issues 2020-07-05 13:07:33 -07:00