wayland: Use new KMS update test API to try acquiring scanout

This significantly increases the chance of a fullscreen surface buffer
being scanned out instead of being painted via composition. This is
assuming the client supports the DMA buffer feedback Wayland protocol.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2146>
This commit is contained in:
Jonas Ådahl
2021-12-08 21:23:54 +01:00
committed by Marge Bot
parent a14923e993
commit 8a2fcf3be0
4 changed files with 38 additions and 72 deletions

View File

@@ -691,11 +691,8 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
MetaDeviceFile *device_file;
struct gbm_device *gbm_device;
struct gbm_bo *gbm_bo;
uint32_t drm_format;
uint64_t drm_modifier;
uint32_t stride;
MetaDrmBufferFlags flags;
MetaDrmBufferGbm *fb;
g_autoptr (MetaDrmBufferGbm) fb = NULL;
g_autoptr (GError) error = NULL;
gpu_kms = meta_renderer_native_get_primary_gpu (renderer_native);
@@ -708,20 +705,8 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
if (!gbm_bo)
return NULL;
drm_format = gbm_bo_get_format (gbm_bo);
drm_modifier = gbm_bo_get_modifier (gbm_bo);
stride = gbm_bo_get_stride (gbm_bo);
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen,
drm_format,
drm_modifier,
stride))
{
gbm_bo_destroy (gbm_bo);
return NULL;
}
flags = META_DRM_BUFFER_FLAG_NONE;
if (drm_modifier == DRM_FORMAT_MOD_INVALID)
if (gbm_bo_get_modifier (gbm_bo) == DRM_FORMAT_MOD_INVALID)
flags |= META_DRM_BUFFER_FLAG_DISABLE_MODIFIERS;
fb = meta_drm_buffer_gbm_new_take (device_file, gbm_bo, flags, &error);
@@ -732,7 +717,11 @@ try_acquire_egl_image_scanout (MetaWaylandBuffer *buffer,
return NULL;
}
return COGL_SCANOUT (fb);
if (!meta_onscreen_native_is_buffer_scanout_compatible (onscreen,
META_DRM_BUFFER (fb)))
return NULL;
return COGL_SCANOUT (g_steal_pointer (&fb));
#else
return NULL;
#endif
@@ -742,6 +731,9 @@ CoglScanout *
meta_wayland_buffer_try_acquire_scanout (MetaWaylandBuffer *buffer,
CoglOnscreen *onscreen)
{
COGL_TRACE_BEGIN_SCOPED (MetaWaylandBufferTryScanout,
"WaylandBuffer (try scanout)");
switch (buffer->type)
{
case META_WAYLAND_BUFFER_TYPE_SHM: