From b8488580d9d7e034aa39426f6ef161035e56915d Mon Sep 17 00:00:00 2001 From: Luigi Santivetti Date: Mon, 25 Jan 2021 11:05:49 +0000 Subject: [PATCH 50/50] egl/null: expose EXT_yuv_surface support --- src/egl/drivers/dri2/platform_null.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c index 4969121bf37..9830b73d704 100644 --- a/src/egl/drivers/dri2/platform_null.c +++ b/src/egl/drivers/dri2/platform_null.c @@ -106,6 +106,12 @@ static const struct dri2_null_format { .rgba_shifts = { 11, 5, 0, -1 }, .rgba_sizes = { 5, 6, 5, 0 }, }, + { + .drm_format = DRM_FORMAT_YUYV, + .dri_image_format = __DRI_IMAGE_FORMAT_YUYV, + .rgba_shifts = { -1, -1, -1, -1 }, + .rgba_sizes = { 0, 0, 0, 0 }, + }, }; @@ -1595,6 +1601,17 @@ dri2_null_image_get_buffers(__DRIdrawable *driDrawable, unsigned int format, return 1; } +static unsigned +dri2_null_get_capability(void *loaderPrivate, enum dri_loader_cap cap) +{ + switch (cap) { + case DRI_LOADER_CAP_YUV_SURFACE_IMG: + return 1; + default: + return 0; + } +} + static void dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) { @@ -1603,10 +1620,11 @@ dri2_null_flush_front_buffer(__DRIdrawable * driDrawable, void *loaderPrivate) } static const __DRIimageLoaderExtension image_loader_extension = { - .base = { __DRI_IMAGE_LOADER, 1 }, + .base = { __DRI_IMAGE_LOADER, 2 }, .getBuffers = dri2_null_image_get_buffers, .flushFrontBuffer = dri2_null_flush_front_buffer, + .getCapability = dri2_null_get_capability, }; static const __DRIextension *image_loader_extensions[] = { @@ -1688,6 +1706,7 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) for (unsigned i = 0; dri2_dpy->driver_configs[i]; i++) { struct dri2_egl_config *dri2_conf; + EGLint surface_type; int format_idx; format_idx = format_idx_get_from_config(dri2_dpy, @@ -1698,10 +1717,13 @@ dri2_null_add_configs_for_formats(_EGLDisplay *disp) if (!(dri2_dpy->output.formats & (1 << format_idx))) continue; + surface_type = EGL_WINDOW_BIT; + if (dri2_null_formats[format_idx].drm_format != DRM_FORMAT_YUYV) + surface_type |= EGL_PBUFFER_BIT; + dri2_conf = dri2_add_config(disp, dri2_dpy->driver_configs[i], count + 1, - EGL_WINDOW_BIT | EGL_PBUFFER_BIT, - NULL, NULL, NULL); + surface_type, NULL, NULL, NULL); if (dri2_conf) count++; } -- 2.17.1