tests/wayland-test-clients: Try simple dma-buf alloc first and fall back

to the complex one. If a driver supports allocating linear YCbCr formats
we can use that instead of constructing our own compatible buffer.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3371>
This commit is contained in:
Sebastian Wick 2023-12-13 16:21:34 +01:00 committed by Marge Bot
parent ff3b8197fd
commit 628f12a48b

View File

@ -1097,7 +1097,7 @@ alloc_dmabuf_simple (WaylandBuffer *buffer,
} }
static gboolean static gboolean
alloc_dmabuf_ycbcr (WaylandBuffer *buffer, alloc_dmabuf_complex (WaylandBuffer *buffer,
uint32_t bo_flags) uint32_t bo_flags)
{ {
WaylandBufferDmabuf *dmabuf = WAYLAND_BUFFER_DMABUF (buffer); WaylandBufferDmabuf *dmabuf = WAYLAND_BUFFER_DMABUF (buffer);
@ -1151,6 +1151,8 @@ alloc_dmabuf_ycbcr (WaylandBuffer *buffer,
vsub[1] = 2; vsub[1] = 2;
hsub[2] = 2; hsub[2] = 2;
break; break;
default:
return FALSE;
} }
wl_params = zwp_linux_dmabuf_v1_create_params (wl_dmabuf); wl_params = zwp_linux_dmabuf_v1_create_params (wl_dmabuf);
@ -1240,6 +1242,9 @@ wayland_buffer_dmabuf_allocate (WaylandBuffer *buffer,
GUINT_TO_POINTER (priv->format)); GUINT_TO_POINTER (priv->format));
g_assert_nonnull (dma_buf_format); g_assert_nonnull (dma_buf_format);
if (alloc_dmabuf_simple (buffer, n_modifiers, modifiers, bo_flags))
return TRUE;
may_alloc_linear = !modifiers; may_alloc_linear = !modifiers;
for (i = 0; i < n_modifiers; i++) for (i = 0; i < n_modifiers; i++)
{ {
@ -1251,23 +1256,10 @@ wayland_buffer_dmabuf_allocate (WaylandBuffer *buffer,
} }
} }
switch (priv->format)
{
case DRM_FORMAT_ARGB8888:
case DRM_FORMAT_XRGB8888:
return alloc_dmabuf_simple (buffer, n_modifiers, modifiers, bo_flags);
case DRM_FORMAT_YUYV:
case DRM_FORMAT_NV12:
case DRM_FORMAT_P010:
case DRM_FORMAT_YUV420:
if (!may_alloc_linear) if (!may_alloc_linear)
return FALSE; return FALSE;
return alloc_dmabuf_ycbcr (buffer, bo_flags);
default:
g_assert_not_reached ();
}
return FALSE; return alloc_dmabuf_complex (buffer, bo_flags);
} }
static void * static void *