mesa: add xbgr support adjacent to xrgb
authorIlia Mirkin <imirkin@alum.mit.edu>
Sun, 31 Dec 2017 06:05:06 +0000 (01:05 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 20 Feb 2018 03:33:58 +0000 (22:33 -0500)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Acked-by: Daniel Stone <daniels@collabora.com>
include/GL/internal/dri_interface.h
src/gallium/state_trackers/dri/dri2.c
src/gallium/state_trackers/dri/dri_drawable.c
src/gallium/state_trackers/dri/dri_screen.c
src/loader/loader_dri3_helper.c
src/mesa/drivers/dri/common/utils.c
src/mesa/main/framebuffer.c
src/mesa/state_tracker/st_cb_fbo.c

index a0c11f184c8a54883b89b2e6cd2e67cdbbd848bc..4f4795c7ae3017ae1c7107f3c51b6b016a5b1707 100644 (file)
@@ -1251,6 +1251,8 @@ struct __DRIdri2ExtensionRec {
 #define __DRI_IMAGE_FORMAT_R16          0x100d
 #define __DRI_IMAGE_FORMAT_GR1616       0x100e
 #define __DRI_IMAGE_FORMAT_YUYV         0x100f
+#define __DRI_IMAGE_FORMAT_XBGR2101010  0x1010
+#define __DRI_IMAGE_FORMAT_ABGR2101010  0x1011
 
 #define __DRI_IMAGE_USE_SHARE          0x0001
 #define __DRI_IMAGE_USE_SCANOUT                0x0002
index 415002d2cd0020d31a9edfe321814cbadd8129ea..2a3a2a805b45dc88e221ea0a1dc4be53b80e0bf5 100644 (file)
@@ -57,6 +57,8 @@
 static const int fourcc_formats[] = {
    __DRI_IMAGE_FOURCC_ARGB2101010,
    __DRI_IMAGE_FOURCC_XRGB2101010,
+   __DRI_IMAGE_FOURCC_ABGR2101010,
+   __DRI_IMAGE_FOURCC_XBGR2101010,
    __DRI_IMAGE_FOURCC_ARGB8888,
    __DRI_IMAGE_FOURCC_ABGR8888,
    __DRI_IMAGE_FOURCC_SARGB8888,
@@ -115,6 +117,14 @@ static int convert_fourcc(int format, int *dri_components_p)
       format = __DRI_IMAGE_FORMAT_XRGB2101010;
       dri_components = __DRI_IMAGE_COMPONENTS_RGB;
       break;
+   case __DRI_IMAGE_FOURCC_ABGR2101010:
+      format = __DRI_IMAGE_FORMAT_ABGR2101010;
+      dri_components = __DRI_IMAGE_COMPONENTS_RGBA;
+      break;
+   case __DRI_IMAGE_FOURCC_XBGR2101010:
+      format = __DRI_IMAGE_FORMAT_XBGR2101010;
+      dri_components = __DRI_IMAGE_COMPONENTS_RGB;
+      break;
    case __DRI_IMAGE_FOURCC_R8:
       format = __DRI_IMAGE_FORMAT_R8;
       dri_components = __DRI_IMAGE_COMPONENTS_R;
@@ -186,6 +196,12 @@ static int convert_to_fourcc(int format)
    case __DRI_IMAGE_FORMAT_XRGB2101010:
       format = __DRI_IMAGE_FOURCC_XRGB2101010;
       break;
+   case __DRI_IMAGE_FORMAT_ABGR2101010:
+      format = __DRI_IMAGE_FOURCC_ABGR2101010;
+      break;
+   case __DRI_IMAGE_FORMAT_XBGR2101010:
+      format = __DRI_IMAGE_FOURCC_XBGR2101010;
+      break;
    case __DRI_IMAGE_FORMAT_R8:
       format = __DRI_IMAGE_FOURCC_R8;
       break;
@@ -224,6 +240,12 @@ static enum pipe_format dri2_format_to_pipe_format (int format)
    case __DRI_IMAGE_FORMAT_ARGB2101010:
       pf = PIPE_FORMAT_B10G10R10A2_UNORM;
       break;
+   case __DRI_IMAGE_FORMAT_XBGR2101010:
+      pf = PIPE_FORMAT_R10G10B10X2_UNORM;
+      break;
+   case __DRI_IMAGE_FORMAT_ABGR2101010:
+      pf = PIPE_FORMAT_R10G10B10A2_UNORM;
+      break;
    case __DRI_IMAGE_FORMAT_R8:
       pf = PIPE_FORMAT_R8_UNORM;
       break;
@@ -288,6 +310,12 @@ static enum pipe_format fourcc_to_pipe_format(int fourcc)
    case __DRI_IMAGE_FOURCC_XRGB2101010:
       pf = PIPE_FORMAT_B10G10R10X2_UNORM;
       break;
+   case __DRI_IMAGE_FOURCC_ABGR2101010:
+      pf = PIPE_FORMAT_R10G10B10A2_UNORM;
+      break;
+   case __DRI_IMAGE_FOURCC_XBGR2101010:
+      pf = PIPE_FORMAT_R10G10B10X2_UNORM;
+      break;
 
    case __DRI_IMAGE_FOURCC_NV12:
       pf = PIPE_FORMAT_NV12;
@@ -406,10 +434,12 @@ dri2_drawable_get_buffers(struct dri_drawable *drawable,
        */
       switch(format) {
       case PIPE_FORMAT_B10G10R10A2_UNORM:
+      case PIPE_FORMAT_R10G10B10A2_UNORM:
       case PIPE_FORMAT_BGRA8888_UNORM:
       case PIPE_FORMAT_RGBA8888_UNORM:
         depth = 32;
         break;
+      case PIPE_FORMAT_R10G10B10X2_UNORM:
       case PIPE_FORMAT_B10G10R10X2_UNORM:
          depth = 30;
          break;
@@ -502,6 +532,12 @@ dri_image_drawable_get_buffers(struct dri_drawable *drawable,
       case PIPE_FORMAT_B10G10R10A2_UNORM:
          image_format = __DRI_IMAGE_FORMAT_ARGB2101010;
          break;
+      case PIPE_FORMAT_R10G10B10X2_UNORM:
+         image_format = __DRI_IMAGE_FORMAT_XBGR2101010;
+         break;
+      case PIPE_FORMAT_R10G10B10A2_UNORM:
+         image_format = __DRI_IMAGE_FORMAT_ABGR2101010;
+         break;
       default:
          image_format = __DRI_IMAGE_FORMAT_NONE;
          break;
index a5999be574ae65b5baa6ab6953257316f27b725e..e5a7537e4731184920ab86ab2a46b00fcac20739 100644 (file)
@@ -263,6 +263,9 @@ dri_set_tex_buffer2(__DRIcontext *pDRICtx, GLint target,
          case PIPE_FORMAT_B10G10R10A2_UNORM:
             internal_format = PIPE_FORMAT_B10G10R10X2_UNORM;
             break;
+         case PIPE_FORMAT_R10G10B10A2_UNORM:
+            internal_format = PIPE_FORMAT_R10G10B10X2_UNORM;
+            break;
          case PIPE_FORMAT_BGRA8888_UNORM:
             internal_format = PIPE_FORMAT_BGRX8888_UNORM;
             break;
index adce2ff36dbb1a8b7cfef7991dbd9ff9ce4bf440..bd0925b905518c60b608fe2698dcd173709b320e 100644 (file)
@@ -110,6 +110,8 @@ dri_fill_in_modes(struct dri_screen *screen)
    static const mesa_format mesa_formats[] = {
       MESA_FORMAT_B10G10R10A2_UNORM,
       MESA_FORMAT_B10G10R10X2_UNORM,
+      MESA_FORMAT_R10G10B10A2_UNORM,
+      MESA_FORMAT_R10G10B10X2_UNORM,
       MESA_FORMAT_B8G8R8A8_UNORM,
       MESA_FORMAT_B8G8R8X8_UNORM,
       MESA_FORMAT_B8G8R8A8_SRGB,
@@ -140,6 +142,8 @@ dri_fill_in_modes(struct dri_screen *screen)
    static const enum pipe_format pipe_formats[] = {
       PIPE_FORMAT_B10G10R10A2_UNORM,
       PIPE_FORMAT_B10G10R10X2_UNORM,
+      PIPE_FORMAT_R10G10B10A2_UNORM,
+      PIPE_FORMAT_R10G10B10X2_UNORM,
       PIPE_FORMAT_BGRA8888_UNORM,
       PIPE_FORMAT_BGRX8888_UNORM,
       PIPE_FORMAT_BGRA8888_SRGB,
@@ -238,7 +242,9 @@ dri_fill_in_modes(struct dri_screen *screen)
 
       if (!allow_rgb10 &&
           (mesa_formats[format] == MESA_FORMAT_B10G10R10A2_UNORM ||
-           mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM))
+           mesa_formats[format] == MESA_FORMAT_B10G10R10X2_UNORM ||
+           mesa_formats[format] == MESA_FORMAT_R10G10B10A2_UNORM ||
+           mesa_formats[format] == MESA_FORMAT_R10G10B10X2_UNORM))
          continue;
 
       if (!p_screen->is_format_supported(p_screen, pipe_formats[format],
@@ -310,6 +316,15 @@ dri_fill_st_visual(struct st_visual *stvis, struct dri_screen *screen,
       }
       break;
 
+   case 0x000003FF:
+      if (mode->alphaMask) {
+         assert(mode->alphaMask == 0xC0000000);
+         stvis->color_format = PIPE_FORMAT_R10G10B10A2_UNORM;
+      } else {
+         stvis->color_format = PIPE_FORMAT_R10G10B10X2_UNORM;
+      }
+      break;
+
    case 0x00FF0000:
       if (mode->alphaMask) {
          assert(mode->alphaMask == 0xFF000000);
index 2912bb6749b76a916da40af616cf5eb1643d67e4..0cd0dffa69e27a667eb562668eb7447d1f4d9537 100644 (file)
@@ -993,6 +993,8 @@ dri3_cpp_for_format(uint32_t format) {
    case  __DRI_IMAGE_FORMAT_XBGR8888:
    case  __DRI_IMAGE_FORMAT_XRGB2101010:
    case  __DRI_IMAGE_FORMAT_ARGB2101010:
+   case  __DRI_IMAGE_FORMAT_XBGR2101010:
+   case  __DRI_IMAGE_FORMAT_ABGR2101010:
    case  __DRI_IMAGE_FORMAT_SARGB8:
       return 4;
    case  __DRI_IMAGE_FORMAT_NONE:
@@ -1020,6 +1022,8 @@ image_format_to_fourcc(int format)
    case __DRI_IMAGE_FORMAT_XBGR8888: return __DRI_IMAGE_FOURCC_XBGR8888;
    case __DRI_IMAGE_FORMAT_XRGB2101010: return __DRI_IMAGE_FOURCC_XRGB2101010;
    case __DRI_IMAGE_FORMAT_ARGB2101010: return __DRI_IMAGE_FOURCC_ARGB2101010;
+   case __DRI_IMAGE_FORMAT_XBGR2101010: return __DRI_IMAGE_FOURCC_XBGR2101010;
+   case __DRI_IMAGE_FORMAT_ABGR2101010: return __DRI_IMAGE_FOURCC_ABGR2101010;
    }
    return 0;
 }
index e944754a424d2241e80aebbd92d5c9414e19eb25..1cffd3ad08eeafab0080ea739fa16039281eab45 100644 (file)
@@ -177,6 +177,10 @@ driCreateConfigs(mesa_format format,
       { 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000 },
       /* MESA_FORMAT_R8G8B8X8_UNORM */
       { 0x000000FF, 0x0000FF00, 0x00FF0000, 0x00000000 },
+      /* MESA_FORMAT_R10G10B10X2_UNORM */
+      { 0x000003FF, 0x000FFC00, 0x3FF00000, 0x00000000 },
+      /* MESA_FORMAT_R10G10B10A2_UNORM */
+      { 0x000003FF, 0x000FFC00, 0x3FF00000, 0xC0000000 },
    };
 
    const uint32_t * masks;
@@ -215,6 +219,12 @@ driCreateConfigs(mesa_format format,
    case MESA_FORMAT_B10G10R10A2_UNORM:
       masks = masks_table[4];
       break;
+   case MESA_FORMAT_R10G10B10X2_UNORM:
+      masks = masks_table[7];
+      break;
+   case MESA_FORMAT_R10G10B10A2_UNORM:
+      masks = masks_table[8];
+      break;
    default:
       fprintf(stderr, "[%s:%u] Unknown framebuffer type %s (%d).\n",
               __func__, __LINE__,
index e103f313e45910b9ffeb4bde747f43855c85e36f..249e775f8cba21993b97ca8e7e532bc74114427e 100644 (file)
@@ -890,7 +890,9 @@ _mesa_get_color_read_type(struct gl_context *ctx,
          return GL_UNSIGNED_SHORT_5_6_5;
 
       if (format == MESA_FORMAT_B10G10R10A2_UNORM ||
-          format == MESA_FORMAT_B10G10R10X2_UNORM)
+          format == MESA_FORMAT_B10G10R10X2_UNORM ||
+          format == MESA_FORMAT_R10G10B10A2_UNORM ||
+          format == MESA_FORMAT_R10G10B10X2_UNORM)
          return GL_UNSIGNED_INT_2_10_10_10_REV;
 
       switch (data_type) {
index 0800f5b3d295ee040230d22a8aa540e3388df15f..02ae8e1380e3fed7cd1652993d097fd76cff2fae 100644 (file)
@@ -288,8 +288,10 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, boolean sw)
 
    switch (format) {
    case PIPE_FORMAT_B10G10R10A2_UNORM:
+   case PIPE_FORMAT_R10G10B10A2_UNORM:
       strb->Base.InternalFormat = GL_RGB10_A2;
       break;
+   case PIPE_FORMAT_R10G10B10X2_UNORM:
    case PIPE_FORMAT_B10G10R10X2_UNORM:
       strb->Base.InternalFormat = GL_RGB10;
       break;