screen-cast: Test allocate DMA buffer with implicit API

DMA buffers might be allocatable, but it doesn't mean the driver doesn't
fail when we try to allocate a buffer with an implicit modifier. Using
the proprietary NVIDIA driver for example, it will fail. Lets catch this
up front and avoid advertising DMA buffer support when we know it won't
work.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2383>
This commit is contained in:
Jonas Ådahl 2022-04-22 11:23:07 +02:00 committed by Marge Bot
parent f5f49dfa46
commit 2b4a24132b
2 changed files with 19 additions and 0 deletions

View File

@ -141,4 +141,6 @@ cogl_dma_buf_handle_get_offset (CoglDmaBufHandle *dmabuf_handle);
COGL_EXPORT int
cogl_dma_buf_handle_get_bpp (CoglDmaBufHandle *dmabuf_handle);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CoglDmaBufHandle, cogl_dma_buf_handle_free)
#endif /* __COGL_DMA_BUF_HANDLE_H__ */

View File

@ -160,6 +160,13 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
MetaBackend *backend = META_BACKEND (native);
MetaRenderer *renderer = meta_backend_get_renderer (backend);
MetaScreenCast *screen_cast = meta_backend_get_screen_cast (backend);
ClutterBackend *clutter_backend =
meta_backend_get_clutter_backend (backend);
CoglContext *cogl_context =
clutter_backend_get_cogl_context (clutter_backend);
CoglRenderer *cogl_renderer = cogl_context_get_renderer (cogl_context);
g_autoptr (GError) error = NULL;
g_autoptr (CoglDmaBufHandle) dmabuf_handle = NULL;
if (!meta_renderer_is_hardware_accelerated (renderer))
{
@ -167,6 +174,16 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
"(not hardware accelerated)");
meta_screen_cast_disable_dma_bufs (screen_cast);
}
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
1, 1,
&error);
if (!dmabuf_handle)
{
g_message ("Disabling DMA buffer screen sharing "
"(implicit modifiers not supported)");
meta_screen_cast_disable_dma_bufs (screen_cast);
}
}
#endif /* HAVE_REMOTE_DESKTOP */