From 09b140abb532dede5de6b03b1cc3c03852c1c9e9 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Thu, 5 Jan 2017 16:58:56 +0100 Subject: [PATCH] dri: allow 16bit R/GR images to be exported via drm buffers This allows eglCreateImageKHR to access P010 surfaces created by vaapi Signed-off-by: Rainer Hochecker Acked-by: Ben Widawky --- include/GL/internal/dri_interface.h | 4 ++++ src/egl/drivers/dri2/egl_dri2.c | 10 ++++++++++ src/mesa/drivers/dri/common/dri_util.c | 4 ++++ src/mesa/drivers/dri/i965/intel_screen.c | 6 ++++++ 4 files changed, 24 insertions(+) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 89223569908..598d111f33a 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -1164,6 +1164,8 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a #define __DRI_IMAGE_FORMAT_SARGB8 0x100b #define __DRI_IMAGE_FORMAT_ARGB1555 0x100c +#define __DRI_IMAGE_FORMAT_R16 0x100d +#define __DRI_IMAGE_FORMAT_GR1616 0x100e #define __DRI_IMAGE_USE_SHARE 0x0001 #define __DRI_IMAGE_USE_SCANOUT 0x0002 @@ -1192,6 +1194,8 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_FOURCC_R8 0x20203852 #define __DRI_IMAGE_FOURCC_GR88 0x38385247 #define __DRI_IMAGE_FOURCC_ARGB1555 0x35315241 +#define __DRI_IMAGE_FOURCC_R16 0x20363152 +#define __DRI_IMAGE_FOURCC_GR1616 0x32335247 #define __DRI_IMAGE_FOURCC_RGB565 0x36314752 #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241 #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258 diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 63e29fc48c4..94b7c201707 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -75,6 +75,14 @@ #define DRM_FORMAT_GR88 fourcc_code('G', 'R', '8', '8') /* [15:0] G:R 8:8 little endian */ #endif +#ifndef DRM_FORMAT_R16 +#define DRM_FORMAT_R16 fourcc_code('R', '1', '6', ' ') /* [15:0] R 16 little endian */ +#endif + +#ifndef DRM_FORMAT_GR1616 +#define DRM_FORMAT_GR1616 fourcc_code('G', 'R', '3', '2') /* [31:0] R:G 16:16 little endian */ +#endif + const __DRIuseInvalidateExtension use_invalidate = { .base = { __DRI_USE_INVALIDATE, 1 } }; @@ -1957,6 +1965,8 @@ dri2_check_dma_buf_format(const _EGLImageAttribs *attrs) case DRM_FORMAT_R8: case DRM_FORMAT_RG88: case DRM_FORMAT_GR88: + case DRM_FORMAT_R16: + case DRM_FORMAT_GR1616: case DRM_FORMAT_RGB332: case DRM_FORMAT_BGR233: case DRM_FORMAT_XRGB4444: diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 209a42ab243..f92eee9081d 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -881,8 +881,12 @@ driImageFormatToGLFormat(uint32_t image_format) return MESA_FORMAT_R8G8B8X8_UNORM; case __DRI_IMAGE_FORMAT_R8: return MESA_FORMAT_R_UNORM8; + case __DRI_IMAGE_FORMAT_R16: + return MESA_FORMAT_R_UNORM16; case __DRI_IMAGE_FORMAT_GR88: return MESA_FORMAT_R8G8_UNORM; + case __DRI_IMAGE_FORMAT_GR1616: + return MESA_FORMAT_R16G16_UNORM; case __DRI_IMAGE_FORMAT_SARGB8: return MESA_FORMAT_B8G8R8A8_SRGB; case __DRI_IMAGE_FORMAT_NONE: diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 6ae211da3a1..5f800008c17 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -239,9 +239,15 @@ static struct intel_image_format intel_image_formats[] = { { __DRI_IMAGE_FOURCC_R8, __DRI_IMAGE_COMPONENTS_R, 1, { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 }, } }, + { __DRI_IMAGE_FOURCC_R16, __DRI_IMAGE_COMPONENTS_R, 1, + { { 0, 0, 0, __DRI_IMAGE_FORMAT_R16, 1 }, } }, + { __DRI_IMAGE_FOURCC_GR88, __DRI_IMAGE_COMPONENTS_RG, 1, { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR88, 2 }, } }, + { __DRI_IMAGE_FOURCC_GR1616, __DRI_IMAGE_COMPONENTS_RG, 1, + { { 0, 0, 0, __DRI_IMAGE_FORMAT_GR1616, 2 }, } }, + { __DRI_IMAGE_FOURCC_YUV410, __DRI_IMAGE_COMPONENTS_Y_U_V, 3, { { 0, 0, 0, __DRI_IMAGE_FORMAT_R8, 1 }, { 1, 2, 2, __DRI_IMAGE_FORMAT_R8, 1 }, -- 2.30.2