From 3a9357cd3fad3885cd78bc00f97f30ff87b56dd4 Mon Sep 17 00:00:00 2001 From: Daniel van Vugt Date: Fri, 14 Aug 2020 15:02:00 +0800 Subject: [PATCH] renderer-native: Remove hard-coded selection of GBM_FORMAT_XRGB8888 And choose the first format matching our EGL requirements according to regular `eglChooseConfig` semantics. Which means choosing the highest color depth. The reason why it was hard-coded to GBM_FORMAT_XRGB8888 originates from commit 712ec30cd9 to fix https://gitlab.gnome.org/GNOME/mutter/issues/2 However the entire problem was later removed by commit 14c706e51b. So we don't need to limit the GBM format any more. In practice this means most systems should now get 30-bit color instead of 24-bit. **Performance considerations** For most drivers we would expect no change in memory bandwidth requirements since both the old and new formats are 4 bytes per pixel. Compositing of native Wayland GL clients is made slightly faster and more efficient using 30-bit because they already default to XR30 or AR30 formats when possible. Only legacy Xwayland clients and most SHM clients still using 24-bit color will see slightly slower compositing. --- src/backends/native/meta-renderer-native.c | 87 ++-------------------- 1 file changed, 8 insertions(+), 79 deletions(-) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index f48db9ab8bb..9d90c689e7c 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -262,53 +262,6 @@ meta_renderer_native_add_egl_config_attributes (CoglDisplay *cog return i; } -static gboolean -choose_egl_config_from_gbm_format (MetaEgl *egl, - EGLDisplay egl_display, - const EGLint *attributes, - uint32_t gbm_format, - EGLConfig *out_config, - GError **error) -{ - EGLConfig *egl_configs; - EGLint n_configs; - EGLint i; - - egl_configs = meta_egl_choose_all_configs (egl, egl_display, - attributes, - &n_configs, - error); - if (!egl_configs) - return FALSE; - - for (i = 0; i < n_configs; i++) - { - EGLint visual_id; - - if (!meta_egl_get_config_attrib (egl, egl_display, - egl_configs[i], - EGL_NATIVE_VISUAL_ID, - &visual_id, - error)) - { - g_free (egl_configs); - return FALSE; - } - - if ((uint32_t) visual_id == gbm_format) - { - *out_config = egl_configs[i]; - g_free (egl_configs); - return TRUE; - } - } - - g_free (egl_configs); - g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, - "No EGL config matching supported GBM format found"); - return FALSE; -} - static gboolean meta_renderer_native_choose_egl_config (CoglDisplay *cogl_display, EGLint *attributes, @@ -324,24 +277,18 @@ meta_renderer_native_choose_egl_config (CoglDisplay *cogl_display, switch (renderer_gpu_data->mode) { - case META_RENDERER_NATIVE_MODE_GBM: - return choose_egl_config_from_gbm_format (egl, - egl_display, - attributes, - GBM_FORMAT_XRGB8888, - out_config, - error); case META_RENDERER_NATIVE_MODE_SURFACELESS: *out_config = EGL_NO_CONFIG_KHR; return TRUE; + case META_RENDERER_NATIVE_MODE_GBM: #ifdef HAVE_EGL_DEVICE case META_RENDERER_NATIVE_MODE_EGL_DEVICE: +#endif return meta_egl_choose_first_config (egl, egl_display, attributes, out_config, error); -#endif } return FALSE; @@ -1225,7 +1172,6 @@ meta_renderer_native_finish_frame (MetaRendererNative *renderer_native, static gboolean create_secondary_egl_config (MetaEgl *egl, - MetaRendererNativeMode mode, EGLDisplay egl_display, EGLConfig *egl_config, GError **error) @@ -1241,27 +1187,11 @@ create_secondary_egl_config (MetaEgl *egl, EGL_NONE }; - switch (mode) - { - case META_RENDERER_NATIVE_MODE_GBM: - case META_RENDERER_NATIVE_MODE_SURFACELESS: - return choose_egl_config_from_gbm_format (egl, - egl_display, - attributes, - GBM_FORMAT_XRGB8888, - egl_config, - error); -#ifdef HAVE_EGL_DEVICE - case META_RENDERER_NATIVE_MODE_EGL_DEVICE: - return meta_egl_choose_first_config (egl, - egl_display, - attributes, - egl_config, - error); -#endif - } - - return FALSE; + return meta_egl_choose_first_config (egl, + egl_display, + attributes, + egl_config, + error); } static EGLContext @@ -1306,8 +1236,7 @@ init_secondary_gpu_data_gpu (MetaRendererNativeGpuData *renderer_gpu_data, const char **missing_gl_extensions; const char *renderer_str; - if (!create_secondary_egl_config (egl, renderer_gpu_data->mode, egl_display, - &egl_config, error)) + if (!create_secondary_egl_config (egl, egl_display, &egl_config, error)) return FALSE; egl_context = create_secondary_egl_context (egl, egl_display, egl_config, error); -- GitLab