From c3ea26c02d953e5d5c4046d03edd297d69a0797b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Kristian=20H=C3=B8gsberg?= Date: Wed, 25 Sep 2013 15:46:42 -0700 Subject: [PATCH] compositor-drm: Match the EGLConfig native visual ID if it has one We'll add the GBM format code as the native visual ID for EGLConfigs when running on GBM. This patch lets the drm backend pass in the format code it's using with KMS and make sure we get a confing that matches. In the future, mesa will add support for 10 bpc configs which will match the "at least 8 color bits" requirement. By also matching the native visual ID, we avoid rendering XRGB2101010 into a XRGB8888 KMS framebuffer. --- src/compositor-drm.c | 12 +++++++----- src/gl-renderer.c | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compositor-drm.c b/src/compositor-drm.c index ef92531..2770c85 100644 --- a/src/compositor-drm.c +++ b/src/compositor-drm.c @@ -85,6 +85,7 @@ struct drm_compositor { uint32_t crtc_allocator; uint32_t connector_allocator; struct wl_listener session_listener; + uint32_t format; /* we need these parameters in order to not fail drmModeAddFB2() * due to out of bounds dimensions, and then mistakenly set @@ -495,7 +496,7 @@ drm_output_render_gl(struct drm_output *output, pixman_region32_t *damage) return; } - output->next = drm_fb_get_from_bo(bo, c, GBM_FORMAT_XRGB8888); + output->next = drm_fb_get_from_bo(bo, c, c->format); if (!output->next) { weston_log("failed to get drm_fb for bo\n"); gbm_surface_release_buffer(output->surface, bo); @@ -1246,8 +1247,9 @@ init_egl(struct drm_compositor *ec) if (!ec->gbm) return -1; - if (gl_renderer_create(&ec->base, ec->gbm, gl_renderer_opaque_attribs, - NULL) < 0) { + if (gl_renderer_create(&ec->base, ec->gbm, + gl_renderer_opaque_attribs, + &ec->format) < 0) { gbm_device_destroy(ec->gbm); return -1; } @@ -1441,7 +1443,7 @@ drm_output_init_egl(struct drm_output *output, struct drm_compositor *ec) output->surface = gbm_surface_create(ec->gbm, output->base.current_mode->width, output->base.current_mode->height, - GBM_FORMAT_XRGB8888, + ec->format, GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING); if (!output->surface) { @@ -2552,7 +2554,7 @@ drm_compositor_create(struct wl_display *display, /* KMS support for sprites is not complete yet, so disable the * functionality for now. */ ec->sprites_are_broken = 1; - + ec->format = GBM_FORMAT_XRGB8888; ec->use_pixman = pixman; if (weston_compositor_init(&ec->base, display, argc, argv, diff --git a/src/gl-renderer.c b/src/gl-renderer.c index 87162e0..ae69f22 100644 --- a/src/gl-renderer.c +++ b/src/gl-renderer.c @@ -1587,7 +1587,7 @@ egl_choose_config(struct gl_renderer *gr, const EGLint *attribs, &id)) continue; - if (id != *visual_id) + if (id != 0 && id != *visual_id) continue; } -- 2.7.4