dri: allow 16bit R/GR images to be exported via drm buffers
authorRainer Hochecker <fernetmenta@online.de>
Thu, 5 Jan 2017 15:58:56 +0000 (16:58 +0100)
committerBen Widawsky <ben@bwidawsk.net>
Mon, 23 Jan 2017 16:47:15 +0000 (08:47 -0800)
This allows eglCreateImageKHR to access P010 surfaces created by vaapi

Signed-off-by: Rainer Hochecker <fernetmenta@online.de>
Acked-by: Ben Widawky <ben@bwidawsk.net>
include/GL/internal/dri_interface.h
src/egl/drivers/dri2/egl_dri2.c
src/mesa/drivers/dri/common/dri_util.c
src/mesa/drivers/dri/i965/intel_screen.c

index 892235699088d078698d90844d54137c1df5785a..598d111f33a825e4935acf7173c9d3d80e34ee08 100644 (file)
@@ -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
index 63e29fc48c429b121f5a12d62f094e91c0c93d32..94b7c2017072f332e26619490cbcc62b08f9d3ac 100644 (file)
 #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:
index 209a42ab2430d920da19572b5391c1f3f4a513f4..f92eee9081da82a3b74d38dfd441586e4cfeefde 100644 (file)
@@ -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:
index 6ae211da3a1aa68409da11c17de208caef5a6017..5f800008c176eedcff549084034ad8957719888d 100644 (file)
@@ -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 },