[Mesa-dev] [PATCH] egl/wayland: Don't use DRM format codes for SHM
Daniel Stone
daniels at collabora.com
Mon Feb 13 14:06:10 UTC 2017
The wl_drm interface (akin to X11's DRI2) uses the standard set of DRM
FourCC format codes. wl_shm copies this, except for ARGB8888/XRGB8888,
which use their own definitions.
Make sure we only use wl_shm format codes when we're working with
wl_shm. Otherwise, using swrast with 32bpp formats would fail with an
error.
Signed-off-by: Daniel Stone <daniels at collabora.com>
Cc: Emil Velikov <emil.velikov at collabora.com>
Cc: mesa-stable at lists.freedesktop.org
Fixes: cb5e799448 ("egl/wayland: unify dri2_wl_create_surface implementations")
---
src/egl/drivers/dri2/platform_wayland.c | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index 37360c7..0bc4e87 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -1402,15 +1402,30 @@ os_create_anonymous_file(off_t size)
static EGLBoolean
dri2_wl_swrast_allocate_buffer(struct dri2_egl_display *dri2_dpy,
- int format, int w, int h,
+ int drm_format, int w, int h,
void **data, int *size,
struct wl_buffer **buffer)
{
struct wl_shm_pool *pool;
+ uint32_t shm_format;
int fd, stride, size_map;
void *data_map;
- stride = dri2_wl_swrast_get_stride_for_format(format, w);
+ switch (drm_format) {
+ case WL_DRM_FORMAT_RGB565:
+ shm_format = WL_SHM_FORMAT_RGB565;
+ break;
+ case WL_DRM_FORMAT_ARGB8888:
+ shm_format = WL_SHM_FORMAT_ARGB8888;
+ break;
+ case WL_DRM_FORMAT_XRGB8888:
+ shm_format = WL_SHM_FORMAT_XRGB8888;
+ break;
+ default:
+ return EGL_FALSE;
+ }
+
+ stride = dri2_wl_swrast_get_stride_for_format(drm_format, w);
size_map = h * stride;
/* Create a sharable buffer */
@@ -1426,7 +1441,7 @@ dri2_wl_swrast_allocate_buffer(struct dri2_egl_display *dri2_dpy,
/* Share it in a wl_buffer */
pool = wl_shm_create_pool(dri2_dpy->wl_shm, fd, size_map);
- *buffer = wl_shm_pool_create_buffer(pool, 0, w, h, stride, format);
+ *buffer = wl_shm_pool_create_buffer(pool, 0, w, h, stride, shm_format);
wl_shm_pool_destroy(pool);
close(fd);
--
2.9.3
More information about the mesa-dev
mailing list