[Mesa-dev] [PATCH 5/5] Fix handling of LA and RG formats for big-endian

Richard Sandiford rsandifo at linux.vnet.ibm.com
Mon Jul 21 08:43:21 PDT 2014


MESA_FORMAT_LnAn puts the luminance in the least significant part of
the containing integer, which is equivalent to PIPE_FORMAT_LAnn.
PIPE_FORMAT_LnAn puts the luminance first in memory.

This patch fixes up the mesa<->gallium mapping accordingly.
---
 src/mesa/state_tracker/st_format.c | 64 ++++++++++++++++++++++++++++----------
 1 file changed, 48 insertions(+), 16 deletions(-)

diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 409079b..59cde2e 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -88,9 +88,13 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat)
    case MESA_FORMAT_L4A4_UNORM:
       return PIPE_FORMAT_L4A4_UNORM;
    case MESA_FORMAT_L8A8_UNORM:
-      return PIPE_FORMAT_L8A8_UNORM;
+      return PIPE_FORMAT_LA88_UNORM;
+   case MESA_FORMAT_A8L8_UNORM:
+      return PIPE_FORMAT_AL88_UNORM;
    case MESA_FORMAT_L16A16_UNORM:
-      return PIPE_FORMAT_L16A16_UNORM;
+      return PIPE_FORMAT_LA1616_UNORM;
+   case MESA_FORMAT_A16L16_UNORM:
+      return PIPE_FORMAT_AL1616_UNORM;
    case MESA_FORMAT_A_UNORM8:
       return PIPE_FORMAT_A8_UNORM;
    case MESA_FORMAT_A_UNORM16:
@@ -142,7 +146,9 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat)
    case MESA_FORMAT_SRGBA_DXT5:
       return PIPE_FORMAT_DXT5_SRGBA;
    case MESA_FORMAT_L8A8_SRGB:
-      return PIPE_FORMAT_L8A8_SRGB;
+      return PIPE_FORMAT_LA88_SRGB;
+   case MESA_FORMAT_A8L8_SRGB:
+      return PIPE_FORMAT_AL88_SRGB;
    case MESA_FORMAT_L_SRGB8:
       return PIPE_FORMAT_L8_SRGB;
    case MESA_FORMAT_BGR_SRGB8:
@@ -191,9 +197,13 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat)
    case MESA_FORMAT_R_UNORM16:
       return PIPE_FORMAT_R16_UNORM;
    case MESA_FORMAT_R8G8_UNORM:
-      return PIPE_FORMAT_R8G8_UNORM;
+      return PIPE_FORMAT_RG88_UNORM;
+   case MESA_FORMAT_G8R8_UNORM:
+      return PIPE_FORMAT_GR88_UNORM;
    case MESA_FORMAT_R16G16_UNORM:
-      return PIPE_FORMAT_R16G16_UNORM;
+      return PIPE_FORMAT_RG1616_UNORM;
+   case MESA_FORMAT_G16R16_UNORM:
+      return PIPE_FORMAT_GR1616_UNORM;
    case MESA_FORMAT_RGBA_UNORM16:
       return PIPE_FORMAT_R16G16B16A16_UNORM;
 
@@ -330,7 +340,9 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat)
    case MESA_FORMAT_R_SNORM8:
       return PIPE_FORMAT_R8_SNORM;
    case MESA_FORMAT_R8G8_SNORM:
-      return PIPE_FORMAT_R8G8_SNORM;
+      return PIPE_FORMAT_RG88_SNORM;
+   case MESA_FORMAT_G8R8_SNORM:
+      return PIPE_FORMAT_GR88_SNORM;
    case MESA_FORMAT_R8G8B8A8_SNORM:
       return PIPE_FORMAT_R8G8B8A8_SNORM;
 
@@ -339,14 +351,18 @@ st_mesa_format_to_pipe_format(mesa_format mesaFormat)
    case MESA_FORMAT_L_SNORM8:
       return PIPE_FORMAT_L8_SNORM;
    case MESA_FORMAT_L8A8_SNORM:
-      return PIPE_FORMAT_L8A8_SNORM;
+      return PIPE_FORMAT_LA88_SNORM;
+   case MESA_FORMAT_A8L8_SNORM:
+      return PIPE_FORMAT_AL88_SNORM;
    case MESA_FORMAT_I_SNORM8:
       return PIPE_FORMAT_I8_SNORM;
 
    case MESA_FORMAT_R_SNORM16:
       return PIPE_FORMAT_R16_SNORM;
    case MESA_FORMAT_R16G16_SNORM:
-      return PIPE_FORMAT_R16G16_SNORM;
+      return PIPE_FORMAT_RG1616_SNORM;
+   case MESA_FORMAT_G16R16_SNORM:
+      return PIPE_FORMAT_GR1616_SNORM;
    case MESA_FORMAT_RGBA_SNORM16:
       return PIPE_FORMAT_R16G16B16A16_SNORM;
 
@@ -445,10 +461,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_R10G10B10A2_UNORM;
    case PIPE_FORMAT_L4A4_UNORM:
       return MESA_FORMAT_L4A4_UNORM;
-   case PIPE_FORMAT_L8A8_UNORM:
+   case PIPE_FORMAT_LA88_UNORM:
       return MESA_FORMAT_L8A8_UNORM;
-   case PIPE_FORMAT_L16A16_UNORM:
+   case PIPE_FORMAT_AL88_UNORM:
+      return MESA_FORMAT_A8L8_UNORM;
+   case PIPE_FORMAT_LA1616_UNORM:
       return MESA_FORMAT_L16A16_UNORM;
+   case PIPE_FORMAT_AL1616_UNORM:
+      return MESA_FORMAT_A16L16_UNORM;
    case PIPE_FORMAT_A8_UNORM:
       return MESA_FORMAT_A_UNORM8;
    case PIPE_FORMAT_A16_UNORM:
@@ -505,8 +525,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_SRGBA_DXT3;
    case PIPE_FORMAT_DXT5_SRGBA:
       return MESA_FORMAT_SRGBA_DXT5;
-   case PIPE_FORMAT_L8A8_SRGB:
+   case PIPE_FORMAT_LA88_SRGB:
       return MESA_FORMAT_L8A8_SRGB;
+   case PIPE_FORMAT_AL88_SRGB:
+      return MESA_FORMAT_A8L8_SRGB;
    case PIPE_FORMAT_L8_SRGB:
       return MESA_FORMAT_L_SRGB8;
    case PIPE_FORMAT_R8G8B8_SRGB:
@@ -552,10 +574,14 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_R_UNORM8;
    case PIPE_FORMAT_R16_UNORM:
       return MESA_FORMAT_R_UNORM16;
-   case PIPE_FORMAT_R8G8_UNORM:
+   case PIPE_FORMAT_RG88_UNORM:
       return MESA_FORMAT_R8G8_UNORM;
-   case PIPE_FORMAT_R16G16_UNORM:
+   case PIPE_FORMAT_GR88_UNORM:
+      return MESA_FORMAT_G8R8_UNORM;
+   case PIPE_FORMAT_RG1616_UNORM:
       return MESA_FORMAT_R16G16_UNORM;
+   case PIPE_FORMAT_GR1616_UNORM:
+      return MESA_FORMAT_G16R16_UNORM;
 
    case PIPE_FORMAT_A8_UINT:
       return MESA_FORMAT_A_UINT8;
@@ -688,8 +714,10 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
    /* signed normalized formats */
    case PIPE_FORMAT_R8_SNORM:
       return MESA_FORMAT_R_SNORM8;
-   case PIPE_FORMAT_R8G8_SNORM:
+   case PIPE_FORMAT_RG88_SNORM:
       return MESA_FORMAT_R8G8_SNORM;
+   case PIPE_FORMAT_GR88_SNORM:
+      return MESA_FORMAT_G8R8_SNORM;
    case PIPE_FORMAT_R8G8B8A8_SNORM:
       return MESA_FORMAT_R8G8B8A8_SNORM;
 
@@ -697,15 +725,19 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
       return MESA_FORMAT_A_SNORM8;
    case PIPE_FORMAT_L8_SNORM:
       return MESA_FORMAT_L_SNORM8;
-   case PIPE_FORMAT_L8A8_SNORM:
+   case PIPE_FORMAT_LA88_SNORM:
       return MESA_FORMAT_L8A8_SNORM;
+   case PIPE_FORMAT_AL88_SNORM:
+      return MESA_FORMAT_A8L8_SNORM;
    case PIPE_FORMAT_I8_SNORM:
       return MESA_FORMAT_I_SNORM8;
 
    case PIPE_FORMAT_R16_SNORM:
       return MESA_FORMAT_R_SNORM16;
-   case PIPE_FORMAT_R16G16_SNORM:
+   case PIPE_FORMAT_RG1616_SNORM:
       return MESA_FORMAT_R16G16_SNORM;
+   case PIPE_FORMAT_GR1616_SNORM:
+      return MESA_FORMAT_G16R16_SNORM;
    case PIPE_FORMAT_R16G16B16A16_SNORM:
       return MESA_FORMAT_RGBA_SNORM16;
 
-- 
1.8.3.1



More information about the mesa-dev mailing list