native: Add headless mode using surfaceless EGL context

This eliminates the need for any render node or device nodes, thus can
be used without any graphics hardware available at all, or with a
graphics driver without any render node available.

The surfaceless mode currently requires EGL_KHR_no_config_context to
configure the initial EGL display.

This also means we can enable the native backend tests in CI, as it
should work without any additional privileges.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1698>
This commit is contained in:
Jonas Ådahl
2021-02-09 14:32:55 +01:00
committed by Marge Bot
parent ee4a0dae7c
commit 634c948fc6
5 changed files with 130 additions and 40 deletions

View File

@ -144,6 +144,12 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
};
primary_gpu = meta_renderer_native_get_primary_gpu (renderer_native);
if (!primary_gpu)
{
g_message ("Disabling DMA buffer screen sharing (surfaceless)");
goto disable_dma_bufs;
}
kms_device = meta_gpu_kms_get_kms_device (primary_gpu);
driver_name = meta_kms_device_get_driver_name (kms_device);
@ -157,6 +163,7 @@ maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
g_message ("Disabling DMA buffer screen sharing for driver '%s'.",
driver_name);
disable_dma_bufs:
meta_screen_cast_disable_dma_bufs (screen_cast);
}
#endif /* HAVE_REMOTE_DESKTOP */
@ -473,7 +480,7 @@ init_gpus (MetaBackendNative *native,
GList *l;
devices = meta_udev_list_drm_devices (udev, error);
if (!devices)
if (*error)
return FALSE;
for (l = devices; l; l = l->next)
@ -498,7 +505,8 @@ init_gpus (MetaBackendNative *native,
g_list_free_full (devices, g_object_unref);
if (g_list_length (meta_backend_get_gpus (backend)) == 0)
if (!native->is_headless &&
g_list_length (meta_backend_get_gpus (backend)) == 0)
{
g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND,
"No GPUs found");