diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c index a906bc03a..f7f51397e 100644 --- a/src/backends/native/meta-backend-native.c +++ b/src/backends/native/meta-backend-native.c @@ -95,6 +95,10 @@ struct _MetaBackendNative GHashTable *startup_render_devices; MetaBackendNativeMode mode; + +#ifdef HAVE_EGL_DEVICE + MetaRenderDeviceEglStream *render_device_egl_stream; +#endif }; static GInitableIface *initable_parent_iface; @@ -472,7 +476,6 @@ create_render_device (MetaBackendNative *backend_native, g_autoptr (MetaRenderDeviceGbm) render_device_gbm = NULL; g_autoptr (GError) gbm_error = NULL; #ifdef HAVE_EGL_DEVICE - g_autoptr (MetaRenderDeviceEglStream) render_device_egl_stream = NULL; g_autoptr (GError) egl_stream_error = NULL; #endif @@ -544,12 +547,27 @@ create_render_device (MetaBackendNative *backend_native, #endif #ifdef HAVE_EGL_DEVICE - render_device_egl_stream = - meta_render_device_egl_stream_new (backend, - device_file, - &egl_stream_error); - if (render_device_egl_stream) - return META_RENDER_DEVICE (g_steal_pointer (&render_device_egl_stream)); + if (!backend_native->render_device_egl_stream) + { + MetaRenderDeviceEglStream *device; + + device = meta_render_device_egl_stream_new (backend, + device_file, + &egl_stream_error); + if (device) + { + g_object_add_weak_pointer (G_OBJECT (device), + (gpointer *) &backend_native->render_device_egl_stream); + return META_RENDER_DEVICE (device); + } + } + else if (!render_device_gbm) + { + g_set_error (&egl_stream_error, + G_IO_ERROR, + G_IO_ERROR_FAILED, + "it's not GBM-compatible and one EGLDevice was already found"); + } #endif if (render_device_gbm) diff --git a/src/backends/native/meta-render-device-egl-stream.c b/src/backends/native/meta-render-device-egl-stream.c index 607800ff1..d3eb29d56 100644 --- a/src/backends/native/meta-render-device-egl-stream.c +++ b/src/backends/native/meta-render-device-egl-stream.c @@ -64,12 +64,6 @@ get_egl_device_display (MetaRenderDevice *render_device, error); } -static int -count_mode_setting_devices (MetaBackend *backend) -{ - return g_list_length (meta_backend_get_gpus (backend)); -} - static const char * get_drm_device_file (MetaEgl *egl, EGLDeviceEXT device, @@ -175,14 +169,6 @@ meta_render_device_egl_stream_initable_init (GInitable *initable, EGLDeviceEXT egl_device; EGLDisplay egl_display; - if (count_mode_setting_devices (backend) != 1) - { - g_set_error (error, G_IO_ERROR, - G_IO_ERROR_FAILED, - "EGLDevice currently only works with single GPU systems"); - return FALSE; - } - egl_device = find_egl_device (render_device, error); if (egl_device == EGL_NO_DEVICE_EXT) return FALSE;