xserver/glamor
Mario Kleiner 7c63c582a1 Revert "glamor: Enable modifier support for xfree86 too"
This reverts commit 9b89994110.

Turns out that defaulting glamor_egl->dmabuf_capable = TRUE
breaks kms page-flipping on various Mesa+Linux/DRM-KMS+hardware
combos, resulting in broken presentation timing, degraded performance
and awful tearing. E.g., my testing shows that X-Server master +
Mesa 21.2 + Linux 5.3 on Intel Kabylake has broken pageflipping.
Similar behaviour was observed in the past on RaspberryPi 4/400
with VideoCore-6 by myself and others, and iirc by myself on some
AMD gpu's, although my memories of the latter are a bit dim.

Cfe. https://gitlab.freedesktop.org/mesa/mesa/-/issues/3601 and
possibly https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/254
for related problems.

The reason for pageflip failure on the modesetting-ddx under
DRI3/Present seems to be the following sequence:

1. Atomic modesetting for the modesetting-ddx is broken and therefore
   both disabled by default in the modesetting-ddx itself and also
   force-disabled by the Linux kernel since quite a while. If the kernel
   detects drmSetClientCap(fd, DRM_CLIENT_CAP_ATOMIC, 1); from the
   X-Server, it will reject the request, as a countermeasure to all the
   past and current brokeness.

2. Without DRM_CLIENT_CAP_ATOMIC we don't get the implied universal
   planes support (DRM_CLIENT_CAP_UNIVERSAL_PLANES).

3. Without DRM_CLIENT_CAP_UNIVERSAL_PLANES, drmModeGetPlaneResources()
   will only return overlay planes, but not primary- or cursor planes.

4. As modesetting-ddx drmmode_crtc_create_planes() function can only
   operate on primary planes, but can't get any from drmModeGetPlaneResources(),
   the drmmode_crtc_create_planes() mostly turns into a no-op, never
   executes populate_format_modifiers() and therefore the Linux kernels
   DRM-KMS driver is not ever queried for the list of scanout/pageflip
   capable DRM format modifiers. Iow. the drmmode_crtc->formats[i].modifiers
   list stays empty with zero drmmode_crtc->formats[i].num_modifiers.

5. The list from step 4 provides the format+modifiers for intersection
   which would get returned by the X-Servers DRI3 backend as response to
   a xcb_dri3_get_supported_modifiers_window_modifiers() request. Given
   an empty list was returned in step 4, this will lead to return of an
   empty modifiers list by xcb_dri3_get_supported_modifiers_window_modifiers().

6. Both Mesa's DRI3/Present OpenGL backbuffer allocation logic and iirc
   Mesa/Vulkan/WSI/X11's swapchain image allocation logic use the list
   from xcb_dri3_get_supported_modifiers_window_modifiers() for format+
   modifier selection for scanout/pageflip capable buffers. Cfe. Mesa's
   dri3_alloc_render_buffer() function.

   Due to the empty list, the Mesa code falls back to the format+modifiers
   reported by xcb_dri3_get_supported_modifiers_screen_modifiers()
   instead. This list contains all modifiers reported by GLAMOR as
   result of glamor_get_formats() and glamor_get_modifiers(), which
   in turn are query results from Mesa eglQueryDmaBufFormatsEXT()
   and eglQueryDmaBufModifiersEXT(). Iow. all format+modifiers which
   are supported for rendering are considered for the OpenGL backbuffers
   and Vulkan swapchain buffers.

7. Depending on kms driver + gpu combo and Mesa version, such buffers
   are often not direct-scanout / pageflip capable, and so pageflipping
   can't be used for DRI3/Present of fullscreen windows. Whenever the
   system has to fallback to copies instead of pageflips, the results
   are broken presentation timing, degraded performance and quite
   horrible tearing, as the current DRI3/Present implementation does not
   perform any hardware synchronization of copy presents to the start
   of vblank or similar.

By defaulting glamor_egl->dmabuf_capable = FALSE instead, as the server
1.20 branch does, we avoid this failure:

1. glamor_get_modifiers() turns into a no-op and returns false, not
   reporting any supported dmabuf modifiers to the servers DRI3 code,
   ie. the servers cache_formats_and_modifiers() function can't retrieve
   and cache any format+modifiers. Therefore the servers DRI3 code now
   also reports an empty format+modifiers list when Mesa does a
   xcb_dri3_get_supported_modifiers_screen_modifiers() query.

2. Mesa's buffer allocation code therefore falls back to using the old
   DRI image extensions createImage() function to allocate buffers
   with use flags __DRI_IMAGE_USE_SCANOUT | __DRI_IMAGE_USE_BACKBUFFER
   and our OpenGL backbuffers / Vulkan swapchain images get allocated
   in a direct-scanout / pageflip capable format. Pageflipping works,
   timing and performance is good, presentation is tear-free.

Please consider merging this for branching the X-Server 1.21 branch.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
2021-09-01 18:51:02 +00:00
..
Makefile.am glamor: Implement PixmapFromBuffers and BuffersFromPixmap 2018-03-05 13:27:49 -05:00
glamor.c glamor: add EXT_gpu_shader4 support 2021-07-07 08:42:09 +10:00
glamor.h Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
glamor_addtraps.c glamor: Remove _nf rendering functions 2015-03-24 12:01:39 -07:00
glamor_composite_glyphs.c glamor: add glamor_glsl_has_ints wrapper 2021-07-07 08:41:50 +10:00
glamor_compositerects.c glamor: fix wrong offset on composite rectangles 2016-04-15 16:31:36 -04:00
glamor_context.h glamor: Replace glamor_get/put_context() with just glamor_make_current(). 2014-04-23 10:32:23 -07:00
glamor_copy.c glamor: Propagate glamor_prepare_access failures in copy helpers 2019-03-08 14:29:40 +01:00
glamor_core.c glamor: Stop tracking the screen_fbo. 2017-06-02 17:46:45 -07:00
glamor_dash.c glamor: Fix dashed line rendering. 2017-03-16 11:30:58 -07:00
glamor_debug.h glamor: Remove the "delayed fallback" code. 2017-06-02 17:46:48 -07:00
glamor_egl.c Revert "glamor: Enable modifier support for xfree86 too" 2021-09-01 18:51:02 +00:00
glamor_egl.h glamor/xwayland: Define EGL_NO_X11 2019-11-04 20:49:33 +01:00
glamor_egl_ext.h glamor: Implement PixmapFromBuffers and BuffersFromPixmap 2018-03-05 13:27:49 -05:00
glamor_egl_stubs.c glamor: Unbreak glamor_fd_from_pixmap() 2018-06-27 15:07:56 -04:00
glamor_eglmodule.c glamor: Bump version to 1.0.1 to signal depth 30 support. 2018-02-27 10:18:07 -05:00
glamor_fbo.c glamor: make sure the correct FBO is cleared 2019-11-22 17:12:03 +01:00
glamor_font.c glamor: add glamor_glsl_has_ints wrapper 2021-07-07 08:41:50 +10:00
glamor_font.h glamor: store old fonts in double width textures. 2016-01-13 11:21:02 +10:00
glamor_glx.c glamor: Do the same MakeCurrent(None) for GLX as we do for EGL. 2014-04-23 10:32:32 -07:00
glamor_glyphblt.c glamor: Check glamor_set_destination_drawable() return value 2017-03-15 15:41:13 -04:00
glamor_gradient.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
glamor_image.c glamor: Avoid software fallback for planemasked ZPixmap GetImage 2017-03-20 13:48:40 -04:00
glamor_largepixmap.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
glamor_lines.c glamor: Check glamor_set_destination_drawable() return value 2017-03-15 15:41:13 -04:00
glamor_picture.c glamor: Introduce a central place for our pixmap format/type handling. 2019-04-17 19:34:48 +00:00
glamor_pixmap.c glamor: Switch the gl_flavor to a boolean is_gles. 2019-04-17 19:34:48 +00:00
glamor_points.c glamor: Check glamor_set_destination_drawable() return value 2017-03-15 15:41:13 -04:00
glamor_prepare.c glamor: Fix a compiler warning since the recent OOM fixes. 2019-03-28 13:55:22 -07:00
glamor_prepare.h glamor: Replace fallback preparation code 2014-06-15 22:02:40 +01:00
glamor_priv.h glamor: add EXT_gpu_shader4 support 2021-07-07 08:42:09 +10:00
glamor_program.c glamor: add EXT_gpu_shader4 support 2021-07-07 08:42:09 +10:00
glamor_program.h glamor: Add support for CA rendering in a single pass. 2016-01-26 12:02:42 -08:00
glamor_rects.c glamor: add glamor_glsl_has_ints wrapper 2021-07-07 08:41:50 +10:00
glamor_render.c glamor: Introduce a central place for our pixmap format/type handling. 2019-04-17 19:34:48 +00:00
glamor_segs.c glamor: Check glamor_set_destination_drawable() return value 2017-03-15 15:41:13 -04:00
glamor_spans.c glamor: add glamor_glsl_has_ints wrapper 2021-07-07 08:41:50 +10:00
glamor_sync.c glamor: Make glamor_sync_init work with --disable-xshmfence 2016-09-25 11:00:24 -07:00
glamor_text.c glamor: Translate solid text background region after clipping 2016-07-15 12:59:43 -04:00
glamor_transfer.c glamor: Introduce a central place for our pixmap format/type handling. 2019-04-17 19:34:48 +00:00
glamor_transfer.h glamor: Introduce a central place for our pixmap format/type handling. 2019-04-17 19:34:48 +00:00
glamor_transform.c glamor: Fix more fallback paths with non-GXcopy rop with GLES 2019-05-28 18:10:56 +00:00
glamor_transform.h glamor: glamor_set_destination_drawable() can fail 2017-03-15 15:41:12 -04:00
glamor_trapezoid.c glamor: Remove _nf rendering functions 2015-03-24 12:01:39 -07:00
glamor_triangles.c glamor: Remove _nf rendering functions 2015-03-24 12:01:39 -07:00
glamor_utils.c Convert glamor & glx to new *allocarray functions 2015-04-21 16:58:08 -07:00
glamor_utils.h glamor: add EXT_gpu_shader4 support 2021-07-07 08:42:09 +10:00
glamor_vbo.c Fix spelling/wording issues 2020-07-05 13:07:33 -07:00
glamor_window.c glamor: Drop tracking of the last picture attached to pixmaps. 2015-07-10 09:42:58 -07:00
glamor_xv.c Consolidate fourcc.h 2020-09-15 11:43:16 +02:00
meson.build glamor: Implement GetSupportedModifiers 2018-03-05 13:27:55 -05:00