diff options
author | Daniel van Vugt <daniel.van.vugt@canonical.com> | 2020-10-12 16:57:45 +0800 |
---|---|---|
committer | Jonas Ã…dahl <jadahl@gmail.com> | 2020-10-15 07:45:06 +0000 |
commit | df76d3deece5623e271a4fcaf3519159413bf981 (patch) | |
tree | 63e5ff8d45aaeb4ea6aab5cd1c3a2b3489eef03c /src/backends | |
parent | ae0d48b6fd3aed3e75a25ef1f749c4620e2e3e57 (diff) | |
download | mutter-df76d3deece5623e271a4fcaf3519159413bf981.tar.gz |
renderer-native: Get the GBM buffer format from EGL to match the framebuffer
This eliminates two locations where the format was hardcoded.
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1491
Diffstat (limited to 'src/backends')
-rw-r--r-- | src/backends/native/meta-renderer-native.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 75bbe3e25..87a690532 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -444,6 +444,27 @@ get_supported_kms_formats (CoglOnscreen *onscreen) return meta_crtc_kms_copy_drm_format_list (crtc_kms); } +static uint32_t +get_gbm_format_from_egl (MetaEgl *egl, + EGLDisplay egl_display, + EGLConfig egl_config) +{ + uint32_t gbm_format; + EGLint native_visual_id; + + if (meta_egl_get_config_attrib (egl, + egl_display, + egl_config, + EGL_NATIVE_VISUAL_ID, + &native_visual_id, + NULL)) + gbm_format = (uint32_t) native_visual_id; + else + g_assert_not_reached (); + + return gbm_format; +} + static gboolean init_secondary_gpu_state_gpu_copy_mode (MetaRendererNative *renderer_native, CoglOnscreen *onscreen, @@ -460,13 +481,17 @@ init_secondary_gpu_state_gpu_copy_mode (MetaRendererNative *renderer_nat EGLSurface egl_surface; MetaOnscreenNativeSecondaryGpuState *secondary_gpu_state; MetaGpuKms *gpu_kms; + uint32_t format; width = cogl_framebuffer_get_width (framebuffer); height = cogl_framebuffer_get_height (framebuffer); + format = get_gbm_format_from_egl (egl, + renderer_gpu_data->egl_display, + renderer_gpu_data->secondary.egl_config); gbm_surface = gbm_surface_create (renderer_gpu_data->gbm.device, width, height, - GBM_FORMAT_XRGB8888, + format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); if (!gbm_surface) { @@ -2201,13 +2226,17 @@ meta_renderer_native_create_surface_gbm (CoglOnscreen *onscreen, struct gbm_surface *new_gbm_surface = NULL; EGLNativeWindowType egl_native_window; EGLSurface new_egl_surface; - uint32_t format = GBM_FORMAT_XRGB8888; + uint32_t format; GArray *modifiers; renderer_gpu_data = meta_renderer_native_get_gpu_data (renderer_native, onscreen_native->render_gpu); + format = get_gbm_format_from_egl (egl, + cogl_renderer_egl->edpy, + cogl_display_egl->egl_config); + if (renderer_native->use_modifiers) modifiers = get_supported_modifiers (onscreen, format); else |