[Mesa-dev] [PATCH 10/10] egl/dri2: Add Wayland+EGL support for RGB10 winsys buffers.
Mario Kleiner
mario.kleiner.de at gmail.com
Tue Sep 5 05:01:14 UTC 2017
Successfully tested under Weston 3.0, both with the new
(experimental) dmabuf+modifiers path, and the old buffer
import path. Photometer confirms 10 rgb bits from rendering
to display.
Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
---
src/egl/drivers/dri2/egl_dri2.c | 3 ++
src/egl/drivers/dri2/egl_dri2.h | 2 +
src/egl/drivers/dri2/platform_wayland.c | 65 ++++++++++++++++++++++++++++---
src/egl/wayland/wayland-drm/wayland-drm.c | 6 +++
4 files changed, 70 insertions(+), 6 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2667aa5..b044716 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -986,6 +986,9 @@ dri2_display_destroy(_EGLDisplay *disp)
wl_event_queue_destroy(dri2_dpy->wl_queue);
if (dri2_dpy->wl_dpy_wrapper)
wl_proxy_wrapper_destroy(dri2_dpy->wl_dpy_wrapper);
+
+ u_vector_finish(&dri2_dpy->wl_modifiers.argb2101010);
+ u_vector_finish(&dri2_dpy->wl_modifiers.xrgb2101010);
u_vector_finish(&dri2_dpy->wl_modifiers.argb8888);
u_vector_finish(&dri2_dpy->wl_modifiers.xrgb8888);
u_vector_finish(&dri2_dpy->wl_modifiers.rgb565);
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 4a52b49..2353a0f 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -220,6 +220,8 @@ struct dri2_egl_display
struct wl_event_queue *wl_queue;
struct zwp_linux_dmabuf_v1 *wl_dmabuf;
struct {
+ struct u_vector xrgb2101010;
+ struct u_vector argb2101010;
struct u_vector xrgb8888;
struct u_vector argb8888;
struct u_vector rgb565;
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index bf2adbf..3d46723 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -61,6 +61,8 @@ enum wl_drm_format_flags {
HAS_ARGB8888 = 1,
HAS_XRGB8888 = 2,
HAS_RGB565 = 4,
+ HAS_ARGB2101010 = 8,
+ HAS_XRGB2101010 = 16,
};
static int
@@ -148,18 +150,26 @@ dri2_wl_create_window_surface(_EGLDriver *drv, _EGLDisplay *disp,
if (dri2_dpy->wl_dmabuf || dri2_dpy->wl_drm) {
if (conf->RedSize == 5)
dri2_surf->format = WL_DRM_FORMAT_RGB565;
- else if (conf->AlphaSize == 0)
+ else if (conf->RedSize == 8 && conf->AlphaSize == 0)
dri2_surf->format = WL_DRM_FORMAT_XRGB8888;
- else
+ else if (conf->RedSize == 8)
dri2_surf->format = WL_DRM_FORMAT_ARGB8888;
+ else if (conf->RedSize == 10 && conf->AlphaSize == 0)
+ dri2_surf->format = WL_DRM_FORMAT_XRGB2101010;
+ else if (conf->RedSize == 10)
+ dri2_surf->format = WL_DRM_FORMAT_ARGB2101010;
} else {
assert(dri2_dpy->wl_shm);
if (conf->RedSize == 5)
dri2_surf->format = WL_SHM_FORMAT_RGB565;
- else if (conf->AlphaSize == 0)
+ else if (conf->RedSize == 8 && conf->AlphaSize == 0)
dri2_surf->format = WL_SHM_FORMAT_XRGB8888;
- else
+ else if (conf->RedSize == 8)
dri2_surf->format = WL_SHM_FORMAT_ARGB8888;
+ else if (conf->RedSize == 10 && conf->AlphaSize == 0)
+ dri2_surf->format = WL_SHM_FORMAT_XRGB2101010;
+ else if (conf->RedSize == 10)
+ dri2_surf->format = WL_SHM_FORMAT_ARGB2101010;
}
dri2_surf->wl_queue = wl_display_create_queue(dri2_dpy->wl_dpy);
@@ -339,8 +349,9 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
uint64_t *modifiers;
int num_modifiers;
- /* currently supports three WL DRM formats,
+ /* currently supports five WL DRM formats,
* WL_DRM_FORMAT_ARGB8888, WL_DRM_FORMAT_XRGB8888,
+ * WL_DRM_FORMAT_ARGB2101010, WL_DRM_FORMAT_XRGB2101010,
* and WL_DRM_FORMAT_RGB565
*/
switch (dri2_surf->format) {
@@ -359,6 +370,16 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.rgb565);
num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.rgb565);
break;
+ case WL_DRM_FORMAT_ARGB2101010:
+ dri_image_format = __DRI_IMAGE_FORMAT_ARGB2101010;
+ modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.argb2101010);
+ num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.argb2101010);
+ break;
+ case WL_DRM_FORMAT_XRGB2101010:
+ dri_image_format = __DRI_IMAGE_FORMAT_XRGB2101010;
+ modifiers = u_vector_tail(&dri2_dpy->wl_modifiers.xrgb2101010);
+ num_modifiers = u_vector_length(&dri2_dpy->wl_modifiers.xrgb2101010);
+ break;
default:
/* format is not supported */
return -1;
@@ -582,6 +603,8 @@ dri2_wl_get_buffers(__DRIdrawable * driDrawable,
switch (dri2_surf->format) {
case WL_DRM_FORMAT_ARGB8888:
case WL_DRM_FORMAT_XRGB8888:
+ case WL_DRM_FORMAT_ARGB2101010:
+ case WL_DRM_FORMAT_XRGB2101010:
bpp = 32;
break;
case WL_DRM_FORMAT_RGB565:
@@ -921,6 +944,14 @@ dri2_wl_create_wayland_buffer_from_image(_EGLDriver *drv,
if (!(dri2_dpy->formats & HAS_XRGB8888))
goto bad_format;
break;
+ case __DRI_IMAGE_FORMAT_ARGB2101010:
+ if (!(dri2_dpy->formats & HAS_ARGB2101010))
+ goto bad_format;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB2101010:
+ if (!(dri2_dpy->formats & HAS_XRGB2101010))
+ goto bad_format;
+ break;
default:
goto bad_format;
}
@@ -1000,6 +1031,12 @@ drm_handle_format(void *data, struct wl_drm *drm, uint32_t format)
struct dri2_egl_display *dri2_dpy = data;
switch (format) {
+ case WL_DRM_FORMAT_ARGB2101010:
+ dri2_dpy->formats |= HAS_ARGB2101010;
+ break;
+ case WL_DRM_FORMAT_XRGB2101010:
+ dri2_dpy->formats |= HAS_XRGB2101010;
+ break;
case WL_DRM_FORMAT_ARGB8888:
dri2_dpy->formats |= HAS_ARGB8888;
break;
@@ -1055,6 +1092,12 @@ dmabuf_handle_modifier(void *data, struct zwp_linux_dmabuf_v1 *dmabuf,
return;
switch (format) {
+ case WL_DRM_FORMAT_ARGB2101010:
+ mod = u_vector_add(&dri2_dpy->wl_modifiers.argb2101010);
+ break;
+ case WL_DRM_FORMAT_XRGB2101010:
+ mod = u_vector_add(&dri2_dpy->wl_modifiers.xrgb2101010);
+ break;
case WL_DRM_FORMAT_ARGB8888:
mod = u_vector_add(&dri2_dpy->wl_modifiers.argb8888);
dri2_dpy->formats |= HAS_ARGB8888;
@@ -1168,6 +1211,8 @@ dri2_wl_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *disp)
int has_format;
unsigned int rgba_masks[4];
} visuals[] = {
+ { "XRGB2101010", HAS_XRGB2101010, { 0x3ff00000, 0xffc00, 0x3ff, 0 } },
+ { "ARGB2101010", HAS_ARGB2101010, { 0x3ff00000, 0xffc00, 0x3ff, 0xc0000000 } },
{ "XRGB8888", HAS_XRGB8888, { 0xff0000, 0xff00, 0x00ff, 0xff000000 } },
{ "ARGB8888", HAS_ARGB8888, { 0xff0000, 0xff00, 0x00ff, 0 } },
{ "RGB565", HAS_RGB565, { 0x00f800, 0x07e0, 0x001f, 0 } },
@@ -1226,6 +1271,8 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
if (!u_vector_init(&dri2_dpy->wl_modifiers.xrgb8888, sizeof(uint64_t), 32) ||
!u_vector_init(&dri2_dpy->wl_modifiers.argb8888, sizeof(uint64_t), 32) ||
+ !u_vector_init(&dri2_dpy->wl_modifiers.xrgb2101010, sizeof(uint64_t), 32) ||
+ !u_vector_init(&dri2_dpy->wl_modifiers.argb2101010, sizeof(uint64_t), 32) ||
!u_vector_init(&dri2_dpy->wl_modifiers.rgb565, sizeof(uint64_t), 32)) {
goto cleanup;
}
@@ -1365,7 +1412,7 @@ dri2_wl_swrast_get_stride_for_format(int format, int w)
{
if (format == WL_SHM_FORMAT_RGB565)
return 2 * w;
- else /* ARGB8888 || XRGB8888 */
+ else /* ARGB8888 || XRGB8888 || ARGB2101010 || XRGB2101010 */
return 4 * w;
}
@@ -1799,6 +1846,12 @@ shm_handle_format(void *data, struct wl_shm *shm, uint32_t format)
case WL_SHM_FORMAT_RGB565:
dri2_dpy->formats |= HAS_RGB565;
break;
+ case WL_SHM_FORMAT_ARGB2101010:
+ dri2_dpy->formats |= HAS_ARGB2101010;
+ break;
+ case WL_SHM_FORMAT_XRGB2101010:
+ dri2_dpy->formats |= HAS_XRGB2101010;
+ break;
}
}
diff --git a/src/egl/wayland/wayland-drm/wayland-drm.c b/src/egl/wayland/wayland-drm/wayland-drm.c
index 4fc1252..bc3bc14 100644
--- a/src/egl/wayland/wayland-drm/wayland-drm.c
+++ b/src/egl/wayland/wayland-drm/wayland-drm.c
@@ -124,6 +124,8 @@ drm_create_buffer(struct wl_client *client, struct wl_resource *resource,
uint32_t stride, uint32_t format)
{
switch (format) {
+ case WL_DRM_FORMAT_ARGB2101010:
+ case WL_DRM_FORMAT_XRGB2101010:
case WL_DRM_FORMAT_ARGB8888:
case WL_DRM_FORMAT_XRGB8888:
case WL_DRM_FORMAT_YUYV:
@@ -222,6 +224,10 @@ bind_drm(struct wl_client *client, void *data, uint32_t version, uint32_t id)
wl_resource_post_event(resource, WL_DRM_DEVICE, drm->device_name);
wl_resource_post_event(resource, WL_DRM_FORMAT,
+ WL_DRM_FORMAT_ARGB2101010);
+ wl_resource_post_event(resource, WL_DRM_FORMAT,
+ WL_DRM_FORMAT_XRGB2101010);
+ wl_resource_post_event(resource, WL_DRM_FORMAT,
WL_DRM_FORMAT_ARGB8888);
wl_resource_post_event(resource, WL_DRM_FORMAT,
WL_DRM_FORMAT_XRGB8888);
--
2.7.4
More information about the mesa-dev
mailing list