[Mesa-dev] [PATCH 9/9] st/mesa: use new RGBX formats

Marek Olšák maraeo at gmail.com
Sun Jan 27 12:52:57 PST 2013


---
 src/mesa/state_tracker/st_format.c |  128 +++++++++++++++++++++++++++++++-----
 1 file changed, 111 insertions(+), 17 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 4abfb3c..27a29f0 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -357,6 +357,38 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
       return PIPE_FORMAT_R11G11B10_FLOAT;
    case MESA_FORMAT_ARGB2101010_UINT:
       return PIPE_FORMAT_B10G10R10A2_UINT;
+
+   case MESA_FORMAT_XRGB4444_UNORM:
+      return PIPE_FORMAT_B4G4R4X4_UNORM;
+   case MESA_FORMAT_XRGB1555_UNORM:
+      return PIPE_FORMAT_B5G5R5X1_UNORM;
+   case MESA_FORMAT_XBGR8888_SNORM:
+      return PIPE_FORMAT_R8G8B8X8_SNORM;
+   case MESA_FORMAT_XBGR8888_SRGB:
+      return PIPE_FORMAT_R8G8B8X8_SRGB;
+   case MESA_FORMAT_XBGR8888_UINT:
+      return PIPE_FORMAT_R8G8B8X8_UINT;
+   case MESA_FORMAT_XBGR8888_SINT:
+      return PIPE_FORMAT_R8G8B8X8_SINT;
+   case MESA_FORMAT_XRGB2101010_UNORM:
+      return PIPE_FORMAT_B10G10R10X2_UNORM;
+   case MESA_FORMAT_XBGR16161616_UNORM:
+      return PIPE_FORMAT_R16G16B16X16_UNORM;
+   case MESA_FORMAT_XBGR16161616_SNORM:
+      return PIPE_FORMAT_R16G16B16X16_SNORM;
+   case MESA_FORMAT_XBGR16161616_FLOAT:
+      return PIPE_FORMAT_R16G16B16X16_FLOAT;
+   case MESA_FORMAT_XBGR16161616_UINT:
+      return PIPE_FORMAT_R16G16B16X16_UINT;
+   case MESA_FORMAT_XBGR16161616_SINT:
+      return PIPE_FORMAT_R16G16B16X16_SINT;
+   case MESA_FORMAT_XBGR32323232_FLOAT:
+      return PIPE_FORMAT_R32G32B32X32_FLOAT;
+   case MESA_FORMAT_XBGR32323232_UINT:
+      return PIPE_FORMAT_R32G32B32X32_UINT;
+   case MESA_FORMAT_XBGR32323232_SINT:
+      return PIPE_FORMAT_R32G32B32X32_SINT;
+
    default:
       assert(0);
       return PIPE_FORMAT_NONE;
@@ -679,6 +711,38 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
 
    case PIPE_FORMAT_B10G10R10A2_UINT:
       return MESA_FORMAT_ARGB2101010_UINT;
+
+   case PIPE_FORMAT_B4G4R4X4_UNORM:
+      return MESA_FORMAT_XRGB4444_UNORM;
+   case PIPE_FORMAT_B5G5R5X1_UNORM:
+      return MESA_FORMAT_XRGB1555_UNORM;
+   case PIPE_FORMAT_R8G8B8X8_SNORM:
+      return MESA_FORMAT_XBGR8888_SNORM;
+   case PIPE_FORMAT_R8G8B8X8_SRGB:
+      return MESA_FORMAT_XBGR8888_SRGB;
+   case PIPE_FORMAT_R8G8B8X8_UINT:
+      return MESA_FORMAT_XBGR8888_UINT;
+   case PIPE_FORMAT_R8G8B8X8_SINT:
+      return MESA_FORMAT_XBGR8888_SINT;
+   case PIPE_FORMAT_B10G10R10X2_UNORM:
+      return MESA_FORMAT_XRGB2101010_UNORM;
+   case PIPE_FORMAT_R16G16B16X16_UNORM:
+      return MESA_FORMAT_XBGR16161616_UNORM;
+   case PIPE_FORMAT_R16G16B16X16_SNORM:
+      return MESA_FORMAT_XBGR16161616_SNORM;
+   case PIPE_FORMAT_R16G16B16X16_FLOAT:
+      return MESA_FORMAT_XBGR16161616_FLOAT;
+   case PIPE_FORMAT_R16G16B16X16_UINT:
+      return MESA_FORMAT_XBGR16161616_UINT;
+   case PIPE_FORMAT_R16G16B16X16_SINT:
+      return MESA_FORMAT_XBGR16161616_SINT;
+   case PIPE_FORMAT_R32G32B32X32_FLOAT:
+      return MESA_FORMAT_XBGR32323232_FLOAT;
+   case PIPE_FORMAT_R32G32B32X32_UINT:
+      return MESA_FORMAT_XBGR32323232_UINT;
+   case PIPE_FORMAT_R32G32B32X32_SINT:
+      return MESA_FORMAT_XBGR32323232_SINT;
+
    default:
       assert(0);
       return MESA_FORMAT_NONE;
@@ -742,7 +806,12 @@ struct format_mapping
 static const struct format_mapping format_map[] = {
    /* Basic RGB, RGBA formats */
    {
-      { GL_RGB10, GL_RGB10_A2, 0 },
+      { GL_RGB10, 0 },
+      { PIPE_FORMAT_B10G10R10X2_UNORM, PIPE_FORMAT_B10G10R10A2_UNORM,
+        DEFAULT_RGB_FORMATS }
+   },
+   {
+      { GL_RGB10_A2, 0 },
       { PIPE_FORMAT_B10G10R10A2_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
@@ -758,7 +827,12 @@ static const struct format_mapping format_map[] = {
       { DEFAULT_RGB_FORMATS }
    },
    {
-      { GL_RGB12, GL_RGB16, GL_RGBA12, GL_RGBA16, 0 },
+      { GL_RGB12, GL_RGB16, 0 },
+      { PIPE_FORMAT_R16G16B16X16_UNORM, PIPE_FORMAT_R16G16B16A16_UNORM,
+        DEFAULT_RGB_FORMATS }
+   },
+   {
+      { GL_RGBA12, GL_RGBA16, 0 },
       { PIPE_FORMAT_R16G16B16A16_UNORM, DEFAULT_RGBA_FORMATS }
    },
    {
@@ -775,8 +849,13 @@ static const struct format_mapping format_map[] = {
         PIPE_FORMAT_B5G5R5A1_UNORM, DEFAULT_RGB_FORMATS }
    },
    {
-      { GL_RGB5, GL_RGB4 },
-      { PIPE_FORMAT_B5G6R5_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM,
+      { GL_RGB4 },
+      { PIPE_FORMAT_B4G4R4X4_UNORM, PIPE_FORMAT_B4G4R4A4_UNORM,
+        DEFAULT_RGB_FORMATS }
+   },
+   {
+      { GL_RGB5 },
+      { PIPE_FORMAT_B5G5R5X1_UNORM, PIPE_FORMAT_B5G5R5A1_UNORM,
         DEFAULT_RGB_FORMATS }
    },
    {
@@ -921,12 +1000,17 @@ static const struct format_mapping format_map[] = {
 
    /* sRGB formats */
    {
-      { GL_SRGB_EXT, GL_SRGB8_EXT, GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 },
+      { GL_SRGB_EXT, GL_SRGB8_EXT, 0 },
+      { PIPE_FORMAT_R8G8B8X8_SRGB, DEFAULT_SRGBA_FORMATS }
+   },
+   {
+      { GL_SRGB_ALPHA_EXT, GL_SRGB8_ALPHA8_EXT, 0 },
       { DEFAULT_SRGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SRGB_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, 0 },
-      { PIPE_FORMAT_DXT1_SRGB, DEFAULT_SRGBA_FORMATS }
+      { PIPE_FORMAT_DXT1_SRGB, PIPE_FORMAT_R8G8B8X8_SRGB,
+        DEFAULT_SRGBA_FORMATS }
    },
    {
       { GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0 },
@@ -959,7 +1043,8 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB16F_ARB, 0 },
-      { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT,
+      { PIPE_FORMAT_R16G16B16_FLOAT, PIPE_FORMAT_R16G16B16X16_FLOAT,
+        PIPE_FORMAT_R16G16B16A16_FLOAT,
         PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT, 0 }
    },
    {
@@ -1004,8 +1089,8 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB32F_ARB, 0 },
-      { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32A32_FLOAT,
-        PIPE_FORMAT_R16G16B16A16_FLOAT, 0 }
+      { PIPE_FORMAT_R32G32B32_FLOAT, PIPE_FORMAT_R32G32B32X32_FLOAT,
+        PIPE_FORMAT_R32G32B32A32_FLOAT, PIPE_FORMAT_R16G16B16A16_FLOAT, 0 }
    },
    {
       { GL_LUMINANCE_ALPHA32F_ARB, 0 },
@@ -1115,7 +1200,7 @@ static const struct format_mapping format_map[] = {
         GL_BGR_INTEGER_EXT,
         GL_RGB8I_EXT,
         GL_BLUE_INTEGER_EXT, 0 },
-      { PIPE_FORMAT_R8G8B8_SINT,
+      { PIPE_FORMAT_R8G8B8_SINT, PIPE_FORMAT_R8G8B8X8_SINT,
         PIPE_FORMAT_R8G8B8A8_SINT, 0 }
    },
    {
@@ -1219,7 +1304,7 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB16I_EXT, 0 },
-      { PIPE_FORMAT_R16G16B16_SINT,
+      { PIPE_FORMAT_R16G16B16_SINT, PIPE_FORMAT_R16G16B16X16_SINT,
         PIPE_FORMAT_R16G16B16A16_SINT, 0 },
    },
    {
@@ -1228,7 +1313,7 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB32I_EXT, 0 },
-      { PIPE_FORMAT_R32G32B32_SINT,
+      { PIPE_FORMAT_R32G32B32_SINT, PIPE_FORMAT_R32G32B32X32_SINT,
         PIPE_FORMAT_R32G32B32A32_SINT, 0 },
    },
    {
@@ -1241,12 +1326,12 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB8UI_EXT, 0 },
-      { PIPE_FORMAT_R8G8B8_UINT,
+      { PIPE_FORMAT_R8G8B8_UINT, PIPE_FORMAT_R8G8B8X8_UINT,
         PIPE_FORMAT_R8G8B8A8_UINT, 0 }
    },
    {
       { GL_RGB16UI_EXT, 0 },
-      { PIPE_FORMAT_R16G16B16_UINT,
+      { PIPE_FORMAT_R16G16B16_UINT, PIPE_FORMAT_R16G16B16X16_UINT,
         PIPE_FORMAT_R16G16B16A16_UINT, 0 }
    },
    {
@@ -1255,7 +1340,7 @@ static const struct format_mapping format_map[] = {
    },
    {
       { GL_RGB32UI_EXT, 0},
-      { PIPE_FORMAT_R32G32B32_UINT,
+      { PIPE_FORMAT_R32G32B32_UINT, PIPE_FORMAT_R32G32B32X32_UINT,
         PIPE_FORMAT_R32G32B32A32_UINT, 0 }
    },
    {
@@ -1335,11 +1420,20 @@ static const struct format_mapping format_map[] = {
         PIPE_FORMAT_R8G8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
    },
    {
-      { GL_RGB_SNORM, GL_RGB8_SNORM, GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 },
+      { GL_RGB_SNORM, GL_RGB8_SNORM, 0 },
+      { PIPE_FORMAT_R8G8B8X8_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
+   },
+   {
+      { GL_RGBA_SNORM, GL_RGBA8_SNORM, 0 },
       { PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
    },
    {
-      { GL_RGB16_SNORM, GL_RGBA16_SNORM, 0 },
+      { GL_RGB16_SNORM, 0 },
+      { PIPE_FORMAT_R16G16B16X16_SNORM, PIPE_FORMAT_R16G16B16A16_SNORM,
+        PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
+   },
+   {
+      { GL_RGBA16_SNORM, 0 },
       { PIPE_FORMAT_R16G16B16A16_SNORM, PIPE_FORMAT_R8G8B8A8_SNORM, 0 }
    },
    {
-- 
1.7.10.4



More information about the mesa-dev mailing list