Blob Blame History Raw
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_arit.c b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
index 74b4e9f..eb3b2eb 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_arit.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_arit.c
@@ -1640,7 +1640,7 @@ lp_build_trunc(struct lp_build_context *bld,
       const struct lp_type type = bld->type;
       struct lp_type inttype;
       struct lp_build_context intbld;
-      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 2^24);
+      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 1<<24);
       LLVMValueRef trunc, res, anosign, mask;
       LLVMTypeRef int_vec_type = bld->int_vec_type;
       LLVMTypeRef vec_type = bld->vec_type;
@@ -1695,7 +1695,7 @@ lp_build_round(struct lp_build_context *bld,
       const struct lp_type type = bld->type;
       struct lp_type inttype;
       struct lp_build_context intbld;
-      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 2^24);
+      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 1<<24);
       LLVMValueRef res, anosign, mask;
       LLVMTypeRef int_vec_type = bld->int_vec_type;
       LLVMTypeRef vec_type = bld->vec_type;
@@ -1748,7 +1748,7 @@ lp_build_floor(struct lp_build_context *bld,
       const struct lp_type type = bld->type;
       struct lp_type inttype;
       struct lp_build_context intbld;
-      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 2^24);
+      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 1<<24);
       LLVMValueRef trunc, res, anosign, mask;
       LLVMTypeRef int_vec_type = bld->int_vec_type;
       LLVMTypeRef vec_type = bld->vec_type;
@@ -1817,7 +1817,7 @@ lp_build_ceil(struct lp_build_context *bld,
       const struct lp_type type = bld->type;
       struct lp_type inttype;
       struct lp_build_context intbld;
-      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 2^24);
+      LLVMValueRef cmpval = lp_build_const_vec(bld->gallivm, type, 1<<24);
       LLVMValueRef trunc, res, anosign, mask, tmp;
       LLVMTypeRef int_vec_type = bld->int_vec_type;
       LLVMTypeRef vec_type = bld->vec_type;
diff --git a/src/gallium/auxiliary/util/u_format.csv b/src/gallium/auxiliary/util/u_format.csv
index f3925bb..baddc61 100644
--- a/src/gallium/auxiliary/util/u_format.csv
+++ b/src/gallium/auxiliary/util/u_format.csv
@@ -46,6 +46,8 @@
 #   - number of bits
 # - channel swizzle 
 # - color space: rgb, yub, sz
+# - (optional) channel encoding for big-endian targets
+# - (optional) channel swizzle for big-endian targets
 #
 # See also:
 # - http://msdn.microsoft.com/en-us/library/bb172558.aspx (D3D9)
@@ -70,20 +72,20 @@ PIPE_FORMAT_A8B8G8R8_UNORM        , plain, 1, 1, un8 , un8 , un8 , un8 , wzyx, r
 PIPE_FORMAT_X8B8G8R8_UNORM        , plain, 1, 1, x8  , un8 , un8 , un8 , wzy1, rgb
 # PIPE_FORMAT_R8G8B8A8_UNORM is below
 PIPE_FORMAT_R8G8B8X8_UNORM        , plain, 1, 1, un8 , un8 , un8 , x8  , xyz1, rgb
-PIPE_FORMAT_B5G5R5X1_UNORM        , plain, 1, 1, un5 , un5 , un5 , x1  , zyx1, rgb
-PIPE_FORMAT_B5G5R5A1_UNORM        , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb
-PIPE_FORMAT_B4G4R4A4_UNORM        , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb
-PIPE_FORMAT_B4G4R4X4_UNORM        , plain, 1, 1, un4 , un4 , un4 , x4  , zyx1, rgb
-PIPE_FORMAT_B5G6R5_UNORM          , plain, 1, 1, un5 , un6 , un5 ,     , zyx1, rgb
-PIPE_FORMAT_R10G10B10A2_UNORM     , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb
-PIPE_FORMAT_B10G10R10A2_UNORM     , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb
-PIPE_FORMAT_B2G3R3_UNORM          , plain, 1, 1, un2 , un3 , un3 ,     , zyx1, rgb
+PIPE_FORMAT_B5G5R5X1_UNORM        , plain, 1, 1, un5 , un5 , un5 , x1  , zyx1, rgb, x1  , un5 , un5 , un5 , yzw1
+PIPE_FORMAT_B5G5R5A1_UNORM        , plain, 1, 1, un5 , un5 , un5 , un1 , zyxw, rgb, un1 , un5 , un5 , un5 , yzwx
+PIPE_FORMAT_B4G4R4A4_UNORM        , plain, 1, 1, un4 , un4 , un4 , un4 , zyxw, rgb, un4 , un4 , un4 , un4 , yzwx
+PIPE_FORMAT_B4G4R4X4_UNORM        , plain, 1, 1, un4 , un4 , un4 , x4  , zyx1, rgb, x4  , un4 , un4 , un4 , yzw1
+PIPE_FORMAT_B5G6R5_UNORM          , plain, 1, 1, un5 , un6 , un5 ,     , zyx1, rgb, un5 , un6 , un5 ,     , xyz1
+PIPE_FORMAT_R10G10B10A2_UNORM     , plain, 1, 1, un10, un10, un10, un2 , xyzw, rgb, un2 , un10, un10, un10, wzyx
+PIPE_FORMAT_B10G10R10A2_UNORM     , plain, 1, 1, un10, un10, un10, un2 , zyxw, rgb, un2 , un10, un10, un10, yzwx
+PIPE_FORMAT_B2G3R3_UNORM          , plain, 1, 1, un2 , un3 , un3 ,     , zyx1, rgb, un3 , un3 , un2 ,     , xyz1
 
 # Luminance/Intensity/Alpha formats
 PIPE_FORMAT_L8_UNORM              , plain, 1, 1, un8 ,     ,     ,     , xxx1, rgb
 PIPE_FORMAT_A8_UNORM              , plain, 1, 1, un8 ,     ,     ,     , 000x, rgb
 PIPE_FORMAT_I8_UNORM              , plain, 1, 1, un8 ,     ,     ,     , xxxx, rgb
-PIPE_FORMAT_L4A4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , xxxy, rgb
+PIPE_FORMAT_L4A4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , xxxy, rgb, un4 , un4 ,     ,     , yyyx
 PIPE_FORMAT_L8A8_UNORM            , plain, 1, 1, un8 , un8 ,     ,     , xxxy, rgb
 PIPE_FORMAT_L16_UNORM             , plain, 1, 1, un16,     ,     ,     , xxx1, rgb
 PIPE_FORMAT_A16_UNORM             , plain, 1, 1, un16,     ,     ,     , 000x, rgb
@@ -120,22 +122,22 @@ PIPE_FORMAT_X8R8G8B8_SRGB         , plain, 1, 1, x8  , un8 , un8 , un8 , yzw1, s
 
 # Mixed-sign formats (typically used for bump map textures)
 PIPE_FORMAT_R8SG8SB8UX8U_NORM     , plain, 1, 1, sn8 , sn8 , un8 , x8  , xyz1, rgb
-PIPE_FORMAT_R10SG10SB10SA2U_NORM  , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb
-PIPE_FORMAT_R5SG5SB6U_NORM        , plain, 1, 1, sn5 , sn5 , un6 ,     , xyz1, rgb
+PIPE_FORMAT_R10SG10SB10SA2U_NORM  , plain, 1, 1, sn10, sn10, sn10, un2 , xyzw, rgb, un2 , sn10, sn10, sn10, wzyx
+PIPE_FORMAT_R5SG5SB6U_NORM        , plain, 1, 1, sn5 , sn5 , un6 ,     , xyz1, rgb, un6 , sn5 , sn5 ,     , zyx1
 
 # Depth-stencil formats
 PIPE_FORMAT_S8_UINT                 , plain, 1, 1, up8 ,     ,     ,     , _x__, zs
 PIPE_FORMAT_Z16_UNORM               , plain, 1, 1, un16,     ,     ,     , x___, zs
 PIPE_FORMAT_Z32_UNORM               , plain, 1, 1, un32,     ,     ,     , x___, zs
 PIPE_FORMAT_Z32_FLOAT               , plain, 1, 1, f32 ,     ,     ,     , x___, zs
-PIPE_FORMAT_Z24_UNORM_S8_UINT       , plain, 1, 1, un24, up8 ,     ,     , xy__, zs
-PIPE_FORMAT_S8_UINT_Z24_UNORM       , plain, 1, 1, up8 , un24,     ,     , yx__, zs
-PIPE_FORMAT_X24S8_UINT              , plain, 1, 1, x24 , up8 ,     ,     , _y__, zs
-PIPE_FORMAT_S8X24_UINT              , plain, 1, 1, up8 , x24 ,     ,     , _x__, zs
-PIPE_FORMAT_Z24X8_UNORM             , plain, 1, 1, un24, x8  ,     ,     , x___, zs
-PIPE_FORMAT_X8Z24_UNORM             , plain, 1, 1, x8  , un24,     ,     , y___, zs
-PIPE_FORMAT_Z32_FLOAT_S8X24_UINT    , plain, 1, 1, f32 , up8 ,  x24,     , xy__, zs
-PIPE_FORMAT_X32_S8X24_UINT          , plain, 1, 1, x32 , up8 ,  x24,     , _y__, zs
+PIPE_FORMAT_Z24_UNORM_S8_UINT       , plain, 1, 1, un24, up8 ,     ,     , xy__, zs,    up8 , un24,     ,     , yx__
+PIPE_FORMAT_S8_UINT_Z24_UNORM       , plain, 1, 1, up8 , un24,     ,     , yx__, zs,    un24, up8 ,     ,     , xy__
+PIPE_FORMAT_X24S8_UINT              , plain, 1, 1, x24 , up8 ,     ,     , _y__, zs,    up8 , x24 ,     ,     , _x__
+PIPE_FORMAT_S8X24_UINT              , plain, 1, 1, up8 , x24 ,     ,     , _x__, zs,    x24 , up8 ,     ,     , _y__
+PIPE_FORMAT_Z24X8_UNORM             , plain, 1, 1, un24, x8  ,     ,     , x___, zs,    x8  , un24,     ,     , y___
+PIPE_FORMAT_X8Z24_UNORM             , plain, 1, 1, x8  , un24,     ,     , y___, zs,    un24, x8  ,     ,     , x___
+PIPE_FORMAT_Z32_FLOAT_S8X24_UINT    , plain, 1, 1, f32 , up8 ,  x24,     , xy__, zs,    f32 , x24 ,  up8,     , xz__
+PIPE_FORMAT_X32_S8X24_UINT          , plain, 1, 1, x32 , up8 ,  x24,     , _y__, zs,    x32 , x24 ,  up8,     , _z__
 
 # YUV formats
 # http://www.fourcc.org/yuv.php#UYVY
@@ -261,9 +263,9 @@ PIPE_FORMAT_R32G32B32A32_FIXED    , plain, 1, 1, h32 , h32 , h32 , h32 , xyzw, r
 # See also:
 # - http://msdn.microsoft.com/en-us/library/bb172533.aspx
 # A.k.a. D3DDECLTYPE_UDEC3
-PIPE_FORMAT_R10G10B10X2_USCALED   , plain, 1, 1, u10 , u10 , u10  , x2 , xyz1, rgb
+PIPE_FORMAT_R10G10B10X2_USCALED   , plain, 1, 1, u10 , u10 , u10  , x2 , xyz1, rgb, x2  , u10 , u10 , u10 , wzy1
 # A.k.a. D3DDECLTYPE_DEC3N
-PIPE_FORMAT_R10G10B10X2_SNORM     , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb
+PIPE_FORMAT_R10G10B10X2_SNORM     , plain, 1, 1, sn10, sn10, sn10 , x2 , xyz1, rgb, x2  , sn10, sn10, sn10, wzy1
 
 PIPE_FORMAT_YV12                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
 PIPE_FORMAT_YV16                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
@@ -272,18 +274,18 @@ PIPE_FORMAT_NV12                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, y
 PIPE_FORMAT_NV21                  , other, 1, 1, x8  , x8  , x8  , x8  , xyzw, yuv
 
 # Usually used to implement IA44 and AI44 formats in video decoding
-PIPE_FORMAT_R4A4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , y00x, rgb
-PIPE_FORMAT_A4R4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , x00y, rgb
+PIPE_FORMAT_A4R4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , y00x, rgb, un4, un4 ,     ,     , x00y
+PIPE_FORMAT_R4A4_UNORM            , plain, 1, 1, un4 , un4 ,     ,     , x00y, rgb, un4, un4 ,     ,     , y00x
 PIPE_FORMAT_R8A8_UNORM            , plain, 1, 1, un8 , un8 ,     ,     , x00y, rgb
 PIPE_FORMAT_A8R8_UNORM            , plain, 1, 1, un8 , un8 ,     ,     , y00x, rgb
 
 # ARB_vertex_type_10_10_10_2_REV
-PIPE_FORMAT_R10G10B10A2_USCALED     , plain, 1, 1, u10, u10, u10, u2, xyzw, rgb
-PIPE_FORMAT_R10G10B10A2_SSCALED     , plain, 1, 1, s10, s10, s10, s2, xyzw, rgb
-PIPE_FORMAT_R10G10B10A2_SNORM       , plain, 1, 1, sn10, sn10, sn10, sn2, xyzw, rgb
-PIPE_FORMAT_B10G10R10A2_USCALED     , plain, 1, 1, u10, u10, u10, u2, zyxw, rgb
-PIPE_FORMAT_B10G10R10A2_SSCALED     , plain, 1, 1, s10, s10, s10, s2, zyxw, rgb
-PIPE_FORMAT_B10G10R10A2_SNORM       , plain, 1, 1, sn10, sn10, sn10, sn2, zyxw, rgb
+PIPE_FORMAT_R10G10B10A2_USCALED     , plain, 1, 1, u10 , u10 , u10 , u2  , xyzw, rgb, u2  , u10 , u10 , u10 , wzyx
+PIPE_FORMAT_R10G10B10A2_SSCALED     , plain, 1, 1, s10 , s10 , s10 , s2  , xyzw, rgb, s2  , s10 , s10 , s10 , wzyx
+PIPE_FORMAT_R10G10B10A2_SNORM       , plain, 1, 1, sn10, sn10, sn10, sn2 , xyzw, rgb, sn2 , sn10, sn10, sn10, wzyx
+PIPE_FORMAT_B10G10R10A2_USCALED     , plain, 1, 1, u10 , u10 , u10 , u2  , zyxw, rgb, u2  , u10 , u10 , u10 , yzwx
+PIPE_FORMAT_B10G10R10A2_SSCALED     , plain, 1, 1, s10 , s10 , s10 , s2  , zyxw, rgb, s2  , s10 , s10 , s10 , yzwx
+PIPE_FORMAT_B10G10R10A2_SNORM       , plain, 1, 1, sn10, sn10, sn10, sn2 , zyxw, rgb, sn2 , sn10, sn10, sn10, yzwx
 
 PIPE_FORMAT_R8_UINT                 , plain, 1, 1, up8, , , , x001, rgb
 PIPE_FORMAT_R8G8_UINT               , plain, 1, 1, up8, up8, , , xy01, rgb
@@ -345,13 +347,13 @@ PIPE_FORMAT_I32_SINT                , plain, 1, 1, sp32, , , , xxxx, rgb
 PIPE_FORMAT_L32_SINT                , plain, 1, 1, sp32, , , , xxx1, rgb
 PIPE_FORMAT_L32A32_SINT             , plain, 1, 1, sp32, sp32, , , xxxy, rgb
 
-PIPE_FORMAT_B10G10R10A2_UINT        , plain, 1, 1, up10, up10, up10, up2, zyxw, rgb
+PIPE_FORMAT_B10G10R10A2_UINT        , plain, 1, 1, up10, up10, up10, up2, zyxw, rgb, up2 , up10, up10, up10, yzwx
 
 PIPE_FORMAT_R8G8B8X8_SNORM          , plain, 1, 1, sn8,  sn8,  sn8,  x8,  xyz1, rgb
 PIPE_FORMAT_R8G8B8X8_SRGB           , plain, 1, 1, un8,  un8,  un8,  x8,  xyz1, srgb
 PIPE_FORMAT_R8G8B8X8_UINT           , plain, 1, 1, up8,  up8,  up8,  x8,  xyz1, rgb
 PIPE_FORMAT_R8G8B8X8_SINT           , plain, 1, 1, sp8,  sp8,  sp8,  x8,  xyz1, rgb
-PIPE_FORMAT_B10G10R10X2_UNORM       , plain, 1, 1, un10, un10, un10, x2,  zyx1, rgb
+PIPE_FORMAT_B10G10R10X2_UNORM       , plain, 1, 1, un10, un10, un10, x2,  zyx1, rgb, x2  , un10, un10, un10, yzw1
 PIPE_FORMAT_R16G16B16X16_UNORM      , plain, 1, 1, un16, un16, un16, x16, xyz1, rgb
 PIPE_FORMAT_R16G16B16X16_SNORM      , plain, 1, 1, sn16, sn16, sn16, x16, xyz1, rgb
 PIPE_FORMAT_R16G16B16X16_FLOAT      , plain, 1, 1, f16,  f16,  f16,  x16, xyz1, rgb
diff --git a/src/gallium/auxiliary/util/u_format.h b/src/gallium/auxiliary/util/u_format.h
index 28527f5..d24d6ed 100644
--- a/src/gallium/auxiliary/util/u_format.h
+++ b/src/gallium/auxiliary/util/u_format.h
@@ -1022,8 +1022,7 @@ util_format_luminance_to_red(enum pipe_format format)
       return PIPE_FORMAT_RGTC1_SNORM;
 
    case PIPE_FORMAT_L4A4_UNORM:
-      /* XXX A4R4 is defined as x00y in u_format.csv */
-      return PIPE_FORMAT_A4R4_UNORM;
+      return PIPE_FORMAT_R4A4_UNORM;
 
    case PIPE_FORMAT_L8A8_UNORM:
       return PIPE_FORMAT_R8A8_UNORM;
diff --git a/src/gallium/auxiliary/util/u_format_pack.py b/src/gallium/auxiliary/util/u_format_pack.py
index d1f68c8..114c97c 100644
--- a/src/gallium/auxiliary/util/u_format_pack.py
+++ b/src/gallium/auxiliary/util/u_format_pack.py
@@ -40,24 +40,33 @@
 from u_format_parse import *
 
 
+def inv_swizzles(swizzles):
+    '''Return an array[4] of inverse swizzle terms'''
+    '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
+    inv_swizzle = [None]*4
+    for i in range(4):
+        swizzle = swizzles[i]
+        if swizzle < 4 and inv_swizzle[swizzle] == None:
+            inv_swizzle[swizzle] = i
+    return inv_swizzle
+
+def print_channels(format, func):
+    if format.nr_channels() <= 1:
+        func(format.le_channels, format.le_swizzles)
+    else:
+        print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+        func(format.be_channels, format.be_swizzles)
+        print '#else'
+        func(format.le_channels, format.le_swizzles)
+        print '#endif'
+
 def generate_format_type(format):
     '''Generate a structure that describes the format.'''
 
     assert format.layout == PLAIN
     
-    print 'union util_format_%s {' % format.short_name()
-    
-    if format.block_size() in (8, 16, 32, 64):
-        print '   uint%u_t value;' % (format.block_size(),)
-
-    use_bitfields = False
-    for channel in format.channels:
-        if channel.size % 8 or not is_pot(channel.size):
-            use_bitfields = True
-
-    print '   struct {'
-    for channel in format.channels:
-        if use_bitfields:
+    def generate_bitfields(channels, swizzles):
+        for channel in channels:
             if channel.type == VOID:
                 if channel.size:
                     print '      unsigned %s:%u;' % (channel.name, channel.size)
@@ -74,7 +83,9 @@ def generate_format_type(format):
                     print '      unsigned %s:%u;' % (channel.name, channel.size)
             else:
                 assert 0
-        else:
+
+    def generate_full_fields(channels, swizzles):
+        for channel in channels:
             assert channel.size % 8 == 0 and is_pot(channel.size)
             if channel.type == VOID:
                 if channel.size:
@@ -94,6 +105,22 @@ def generate_format_type(format):
                     assert 0
             else:
                 assert 0
+
+    print 'union util_format_%s {' % format.short_name()
+    
+    if format.block_size() in (8, 16, 32, 64):
+        print '   uint%u_t value;' % (format.block_size(),)
+
+    use_bitfields = False
+    for channel in format.le_channels:
+        if channel.size % 8 or not is_pot(channel.size):
+            use_bitfields = True
+
+    print '   struct {'
+    if use_bitfields:
+        print_channels(format, generate_bitfields)
+    else:
+        print_channels(format, generate_full_fields)
     print '   } chan;'
     print '};'
     print
@@ -109,7 +136,7 @@ def is_format_supported(format):
         return False
 
     for i in range(4):
-        channel = format.channels[i]
+        channel = format.le_channels[i]
         if channel.type not in (VOID, UNSIGNED, SIGNED, FLOAT, FIXED):
             return False
         if channel.type == FLOAT and channel.size not in (16, 32, 64):
@@ -117,27 +144,6 @@ def is_format_supported(format):
 
     return True
 
-def is_format_pure_unsigned(format):
-    for i in range(4):
-        channel = format.channels[i]
-        if channel.type not in (VOID, UNSIGNED):
-            return False
-        if channel.type == UNSIGNED and channel.pure == False:
-            return False
-
-    return True
-
-
-def is_format_pure_signed(format):
-    for i in range(4):
-        channel = format.channels[i]
-        if channel.type not in (VOID, SIGNED):
-            return False
-        if channel.type == SIGNED and channel.pure == False:
-            return False
-
-    return True
-
 def native_type(format):
     '''Get the native appropriate for a format.'''
 
@@ -152,7 +158,7 @@ def native_type(format):
             return 'uint%u_t' % format.block_size()
         else:
             # For array pixel formats return the integer type that matches the color channel
-            channel = format.channels[0]
+            channel = format.array_element()
             if channel.type in (UNSIGNED, VOID):
                 return 'uint%u_t' % channel.size
             elif channel.type in (SIGNED, FIXED):
@@ -402,13 +408,13 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
 
     src_native_type = native_type(format)
 
-    if format.is_bitmask():
+    def unpack_from_bitmask(channels, swizzles):
         depth = format.block_size()
         print '         uint%u_t value = *(const uint%u_t *)src;' % (depth, depth) 
 
         # Declare the intermediate variables
         for i in range(format.nr_channels()):
-            src_channel = format.channels[i]
+            src_channel = channels[i]
             if src_channel.type == UNSIGNED:
                 print '         uint%u_t %s;' % (depth, src_channel.name)
             elif src_channel.type == SIGNED:
@@ -416,7 +422,7 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
 
         # Compute the intermediate unshifted values 
         for i in range(format.nr_channels()):
-            src_channel = format.channels[i]
+            src_channel = channels[i]
             value = 'value'
             shift = src_channel.shift
             if src_channel.type == UNSIGNED:
@@ -443,9 +449,9 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
                 
         # Convert, swizzle, and store final values
         for i in range(4):
-            swizzle = format.swizzles[i]
+            swizzle = swizzles[i]
             if swizzle < 4:
-                src_channel = format.channels[swizzle]
+                src_channel = channels[swizzle]
                 src_colorspace = format.colorspace
                 if src_colorspace == SRGB and i == 3:
                     # Alpha channel is linear
@@ -465,14 +471,14 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
                 assert False
             print '         dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
         
-    else:
+    def unpack_from_union(channels, swizzles):
         print '         union util_format_%s pixel;' % format.short_name()
         print '         memcpy(&pixel, src, sizeof pixel);'
     
         for i in range(4):
-            swizzle = format.swizzles[i]
+            swizzle = swizzles[i]
             if swizzle < 4:
-                src_channel = format.channels[swizzle]
+                src_channel = channels[swizzle]
                 src_colorspace = format.colorspace
                 if src_colorspace == SRGB and i == 3:
                     # Alpha channel is linear
@@ -492,6 +498,11 @@ def generate_unpack_kernel(format, dst_channel, dst_native_type):
                 assert False
             print '         dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
     
+    if format.is_bitmask():
+        print_channels(format, unpack_from_bitmask)
+    else:
+        print_channels(format, unpack_from_union)
+
 
 def generate_pack_kernel(format, src_channel, src_native_type):
 
@@ -502,14 +513,14 @@ def generate_pack_kernel(format, src_channel, src_native_type):
 
     assert format.layout == PLAIN
 
-    inv_swizzle = format.inv_swizzles()
+    def pack_into_bitmask(channels, swizzles):
+        inv_swizzle = inv_swizzles(swizzles)
 
-    if format.is_bitmask():
         depth = format.block_size()
         print '         uint%u_t value = 0;' % depth 
 
         for i in range(4):
-            dst_channel = format.channels[i]
+            dst_channel = channels[i]
             shift = dst_channel.shift
             if inv_swizzle[i] is not None:
                 value ='src[%u]' % inv_swizzle[i]
@@ -536,11 +547,13 @@ def generate_pack_kernel(format, src_channel, src_native_type):
                 
         print '         *(uint%u_t *)dst = value;' % depth 
 
-    else:
+    def pack_into_union(channels, swizzles):
+        inv_swizzle = inv_swizzles(swizzles)
+
         print '         union util_format_%s pixel;' % format.short_name()
     
         for i in range(4):
-            dst_channel = format.channels[i]
+            dst_channel = channels[i]
             width = dst_channel.size
             if inv_swizzle[i] is None:
                 continue
@@ -557,6 +570,11 @@ def generate_pack_kernel(format, src_channel, src_native_type):
     
         print '         memcpy(dst, &pixel, sizeof pixel);'
     
+    if format.is_bitmask():
+        print_channels(format, pack_into_bitmask)
+    else:
+        print_channels(format, pack_into_union)
+
 
 def generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix):
     '''Generate the function to unpack pixels from a particular format'''
@@ -654,7 +672,7 @@ def generate(formats):
             if is_format_supported(format):
                 generate_format_type(format)
 
-            if is_format_pure_unsigned(format):
+            if format.is_pure_unsigned():
                 native_type = 'unsigned'
                 suffix = 'unsigned'
                 channel = Channel(UNSIGNED, False, True, 32)
@@ -668,7 +686,7 @@ def generate(formats):
                 suffix = 'signed'
                 generate_format_unpack(format, channel, native_type, suffix)
                 generate_format_pack(format, channel, native_type, suffix)   
-            elif is_format_pure_signed(format):
+            elif format.is_pure_signed():
                 native_type = 'int'
                 suffix = 'signed'
                 channel = Channel(SIGNED, False, True, 32)
diff --git a/src/gallium/auxiliary/util/u_format_parse.py b/src/gallium/auxiliary/util/u_format_parse.py
index e202099..929017a 100755
--- a/src/gallium/auxiliary/util/u_format_parse.py
+++ b/src/gallium/auxiliary/util/u_format_parse.py
@@ -30,8 +30,6 @@
 '''
 
 
-import sys
-
 VOID, UNSIGNED, SIGNED, FIXED, FLOAT = range(5)
 
 SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W, SWIZZLE_0, SWIZZLE_1, SWIZZLE_NONE, = range(7)
@@ -44,9 +42,6 @@ YUV = 'yuv'
 ZS = 'zs'
 
 
-# Not cross-compiler friendly
-is_big_endian = sys.byteorder == 'big'
-
 def is_pot(x):
    return (x & (x - 1)) == 0
 
@@ -109,13 +104,15 @@ class Channel:
 class Format:
     '''Describe a pixel format.'''
 
-    def __init__(self, name, layout, block_width, block_height, channels, swizzles, colorspace):
+    def __init__(self, name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace):
         self.name = name
         self.layout = layout
         self.block_width = block_width
         self.block_height = block_height
-        self.channels = channels
-        self.swizzles = swizzles
+        self.le_channels = le_channels
+        self.le_swizzles = le_swizzles
+        self.be_channels = be_channels
+        self.be_swizzles = be_swizzles
         self.name = name
         self.colorspace = colorspace
 
@@ -134,42 +131,45 @@ class Format:
 
     def block_size(self):
         size = 0
-        for channel in self.channels:
+        for channel in self.le_channels:
             size += channel.size
         return size
 
     def nr_channels(self):
         nr_channels = 0
-        for channel in self.channels:
+        for channel in self.le_channels:
             if channel.size:
                 nr_channels += 1
         return nr_channels
 
-    def is_array(self):
+    def array_element(self):
         if self.layout != PLAIN:
-            return False
-        ref_channel = self.channels[0]
+            return None
+        ref_channel = self.le_channels[0]
         if ref_channel.type == VOID:
-           ref_channel = self.channels[1]
-        for channel in self.channels:
+           ref_channel = self.le_channels[1]
+        for channel in self.le_channels:
             if channel.size and (channel.size != ref_channel.size or channel.size % 8):
-                return False
+                return None
             if channel.type != VOID:
                 if channel.type != ref_channel.type:
-                    return False
+                    return None
                 if channel.norm != ref_channel.norm:
-                    return False
+                    return None
                 if channel.pure != ref_channel.pure:
-                    return False
-        return True
+                    return None
+        return ref_channel
+
+    def is_array(self):
+        return self.array_element() != None
 
     def is_mixed(self):
         if self.layout != PLAIN:
             return False
-        ref_channel = self.channels[0]
+        ref_channel = self.le_channels[0]
         if ref_channel.type == VOID:
-           ref_channel = self.channels[1]
-        for channel in self.channels[1:]:
+           ref_channel = self.le_channels[1]
+        for channel in self.le_channels[1:]:
             if channel.type != VOID:
                 if channel.type != ref_channel.type:
                     return True
@@ -185,7 +185,7 @@ class Format:
     def is_int(self):
         if self.layout != PLAIN:
             return False
-        for channel in self.channels:
+        for channel in self.le_channels:
             if channel.type not in (VOID, UNSIGNED, SIGNED):
                 return False
         return True
@@ -193,7 +193,7 @@ class Format:
     def is_float(self):
         if self.layout != PLAIN:
             return False
-        for channel in self.channels:
+        for channel in self.le_channels:
             if channel.type not in (VOID, FLOAT):
                 return False
         return True
@@ -203,20 +203,43 @@ class Format:
             return False
         if self.block_size() not in (8, 16, 32):
             return False
-        for channel in self.channels:
+        for channel in self.le_channels:
             if channel.type not in (VOID, UNSIGNED, SIGNED):
                 return False
         return True
 
-    def inv_swizzles(self):
-        '''Return an array[4] of inverse swizzle terms'''
-        '''Only pick the first matching value to avoid l8 getting blue and i8 getting alpha'''
-        inv_swizzle = [None]*4
-        for i in range(4):
-            swizzle = self.swizzles[i]
-            if swizzle < 4 and inv_swizzle[swizzle] == None:
-                inv_swizzle[swizzle] = i
-        return inv_swizzle
+    def is_pure_color(self):
+        if self.layout != PLAIN or self.colorspace == ZS:
+            return False
+        pures = [channel.pure
+                 for channel in self.le_channels
+                 if channel.type != VOID]
+        for x in pures:
+           assert x == pures[0]
+        return pures[0]
+
+    def channel_type(self):
+        types = [channel.type
+                 for channel in self.le_channels
+                 if channel.type != VOID]
+        for x in types:
+           assert x == types[0]
+        return types[0]
+
+    def is_pure_signed(self):
+        return self.is_pure_color() and self.channel_type() == SIGNED
+
+    def is_pure_unsigned(self):
+        return self.is_pure_color() and self.channel_type() == UNSIGNED
+
+    def has_channel(self, id):
+        return self.le_swizzles[id] != SWIZZLE_NONE
+
+    def has_depth(self):
+        return self.colorspace == ZS and self.has_channel(0)
+
+    def has_stencil(self):
+        return self.colorspace == ZS and self.has_channel(1)
 
     def stride(self):
         return self.block_size()/8
@@ -241,6 +264,54 @@ _swizzle_parse_map = {
     '_': SWIZZLE_NONE,
 }
 
+def _parse_channels(fields, layout, colorspace, swizzles):
+    if layout == PLAIN:
+        names = ['']*4
+        if colorspace in (RGB, SRGB):
+            for i in range(4):
+                swizzle = swizzles[i]
+                if swizzle < 4:
+                    names[swizzle] += 'rgba'[i]
+        elif colorspace == ZS:
+            for i in range(4):
+                swizzle = swizzles[i]
+                if swizzle < 4:
+                    names[swizzle] += 'zs'[i]
+        else:
+            assert False
+        for i in range(4):
+            if names[i] == '':
+                names[i] = 'x'
+    else:
+        names = ['x', 'y', 'z', 'w']
+
+    channels = []
+    for i in range(0, 4):
+        field = fields[i]
+        if field:
+            type = _type_parse_map[field[0]]
+            if field[1] == 'n':
+                norm = True
+                pure = False
+                size = int(field[2:])
+            elif field[1] == 'p':
+                pure = True
+                norm = False
+                size = int(field[2:])
+            else:
+                norm = False
+                pure = False
+                size = int(field[1:])
+        else:
+            type = VOID
+            norm = False
+            pure = False
+            size = 0
+        channel = Channel(type, norm, pure, size, names[i])
+        channels.append(channel)
+
+    return channels
+
 def parse(filename):
     '''Parse the format descrition in CSV format in terms of the 
     Channel and Format classes above.'''
@@ -259,65 +330,36 @@ def parse(filename):
             continue
 
         fields = [field.strip() for field in line.split(',')]
+        if len (fields) == 10:
+           fields += fields[4:9]
+        assert len (fields) == 15
         
         name = fields[0]
         layout = fields[1]
         block_width, block_height = map(int, fields[2:4])
-
-        swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
         colorspace = fields[9]
-        
-        if layout == PLAIN:
-            names = ['']*4
-            if colorspace in (RGB, SRGB):
-                for i in range(4):
-                    swizzle = swizzles[i]
-                    if swizzle < 4:
-                        names[swizzle] += 'rgba'[i]
-            elif colorspace == ZS:
-                for i in range(4):
-                    swizzle = swizzles[i]
-                    if swizzle < 4:
-                        names[swizzle] += 'zs'[i]
-            else:
-                assert False
-            for i in range(4):
-                if names[i] == '':
-                    names[i] = 'x'
-        else:
-            names = ['x', 'y', 'z', 'w']
-
-        channels = []
-        for i in range(0, 4):
-            field = fields[4 + i]
-            if field:
-                type = _type_parse_map[field[0]]
-                if field[1] == 'n':
-                    norm = True
-                    pure = False
-                    size = int(field[2:])
-                elif field[1] == 'p':
-                    pure = True
-                    norm = False
-                    size = int(field[2:])
-                else:
-                    norm = False
-                    pure = False
-                    size = int(field[1:])
-            else:
-                type = VOID
-                norm = False
-                pure = False
-                size = 0
-            channel = Channel(type, norm, pure, size, names[i])
-            channels.append(channel)
 
-        shift = 0
-        for channel in channels[3::-1] if is_big_endian else channels:
-            channel.shift = shift
-            shift += channel.size
+        le_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[8]]
+        le_channels = _parse_channels(fields[4:8], layout, colorspace, le_swizzles)
+
+        be_swizzles = [_swizzle_parse_map[swizzle] for swizzle in fields[14]]
+        be_channels = _parse_channels(fields[10:14], layout, colorspace, be_swizzles)
+
+        le_shift = 0
+        for channel in le_channels:
+            channel.shift = le_shift
+            le_shift += channel.size
+
+        be_shift = 0
+        for channel in be_channels[3::-1]:
+            channel.shift = be_shift
+            be_shift += channel.size
+
+        assert le_shift == be_shift
+        for i in range(4):
+            assert (le_swizzles[i] != SWIZZLE_NONE) == (be_swizzles[i] != SWIZZLE_NONE)
 
-        format = Format(name, layout, block_width, block_height, channels, swizzles, colorspace)
+        format = Format(name, layout, block_width, block_height, le_channels, le_swizzles, be_channels, be_swizzles, colorspace)
         formats.append(format)
     return formats
 
diff --git a/src/gallium/auxiliary/util/u_format_table.py b/src/gallium/auxiliary/util/u_format_table.py
index 9d44cf3..81fd399 100755
--- a/src/gallium/auxiliary/util/u_format_table.py
+++ b/src/gallium/auxiliary/util/u_format_table.py
@@ -94,21 +94,10 @@ def write_format_table(formats):
     
     u_format_pack.generate(formats)
     
-    for format in formats:
-        print 'const struct util_format_description'
-        print 'util_format_%s_description = {' % (format.short_name(),)
-        print "   %s," % (format.name,)
-        print "   \"%s\"," % (format.name,)
-        print "   \"%s\"," % (format.short_name(),)
-        print "   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
-        print "   %s," % (layout_map(format.layout),)
-        print "   %u,\t/* nr_channels */" % (format.nr_channels(),)
-        print "   %s,\t/* is_array */" % (bool_map(format.is_array()),)
-        print "   %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
-        print "   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+    def do_channel_array(channels, swizzles):
         print "   {"
         for i in range(4):
-            channel = format.channels[i]
+            channel = channels[i]
             if i < 3:
                 sep = ","
             else:
@@ -118,9 +107,11 @@ def write_format_table(formats):
             else:
                 print "      {0, 0, 0, 0, 0}%s" % (sep,)
         print "   },"
+
+    def do_swizzle_array(channels, swizzles):
         print "   {"
         for i in range(4):
-            swizzle = format.swizzles[i]
+            swizzle = swizzles[i]
             if i < 3:
                 sep = ","
             else:
@@ -131,8 +122,23 @@ def write_format_table(formats):
                 comment = 'ignored'
             print "      %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
         print "   },"
+
+    for format in formats:
+        print 'const struct util_format_description'
+        print 'util_format_%s_description = {' % (format.short_name(),)
+        print "   %s," % (format.name,)
+        print "   \"%s\"," % (format.name,)
+        print "   \"%s\"," % (format.short_name(),)
+        print "   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
+        print "   %s," % (layout_map(format.layout),)
+        print "   %u,\t/* nr_channels */" % (format.nr_channels(),)
+        print "   %s,\t/* is_array */" % (bool_map(format.is_array()),)
+        print "   %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
+        print "   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+        u_format_pack.print_channels(format, do_channel_array)
+        u_format_pack.print_channels(format, do_swizzle_array)
         print "   %s," % (colorspace_map(format.colorspace),)
-        if format.colorspace != ZS and format.channels[0].pure == False:
+        if format.colorspace != ZS and not format.is_pure_color():
             print "   &util_format_%s_unpack_rgba_8unorm," % format.short_name() 
             print "   &util_format_%s_pack_rgba_8unorm," % format.short_name() 
             if format.layout == 's3tc' or format.layout == 'rgtc':
@@ -149,7 +155,7 @@ def write_format_table(formats):
             print "   NULL, /* unpack_rgba_float */" 
             print "   NULL, /* pack_rgba_float */" 
             print "   NULL, /* fetch_rgba_float */" 
-        if format.colorspace == ZS and format.swizzles[0] != SWIZZLE_NONE:
+        if format.has_depth():
             print "   &util_format_%s_unpack_z_32unorm," % format.short_name() 
             print "   &util_format_%s_pack_z_32unorm," % format.short_name() 
             print "   &util_format_%s_unpack_z_float," % format.short_name() 
@@ -159,20 +165,20 @@ def write_format_table(formats):
             print "   NULL, /* pack_z_32unorm */" 
             print "   NULL, /* unpack_z_float */" 
             print "   NULL, /* pack_z_float */" 
-        if format.colorspace == ZS and format.swizzles[1] != SWIZZLE_NONE:
+        if format.has_stencil():
             print "   &util_format_%s_unpack_s_8uint," % format.short_name() 
             print "   &util_format_%s_pack_s_8uint," % format.short_name() 
         else:
             print "   NULL, /* unpack_s_8uint */" 
             print "   NULL, /* pack_s_8uint */"
-        if format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == UNSIGNED:
+        if format.is_pure_unsigned():
             print "   &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name() 
             print "   &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
             print "   &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
             print "   &util_format_%s_pack_signed,  /* pack_rgba_sint */" % format.short_name()
             print "   &util_format_%s_fetch_unsigned,  /* fetch_rgba_uint */" % format.short_name()
             print "   NULL  /* fetch_rgba_sint */"
-        elif format.colorspace != ZS and format.channels[0].pure == True and format.channels[0].type == SIGNED:
+        elif format.is_pure_signed():
             print "   &util_format_%s_unpack_unsigned, /* unpack_rgba_uint */" % format.short_name()
             print "   &util_format_%s_pack_unsigned, /* pack_rgba_uint */" % format.short_name()
             print "   &util_format_%s_unpack_signed, /* unpack_rgba_sint */" % format.short_name()
diff --git a/src/gallium/drivers/ilo/ilo_format.c b/src/gallium/drivers/ilo/ilo_format.c
index 65fb820..6bdac11 100644
--- a/src/gallium/drivers/ilo/ilo_format.c
+++ b/src/gallium/drivers/ilo/ilo_format.c
@@ -504,8 +504,8 @@ ilo_translate_color_format(enum pipe_format format)
       [PIPE_FORMAT_IYUV]                  = 0,
       [PIPE_FORMAT_NV12]                  = 0,
       [PIPE_FORMAT_NV21]                  = 0,
-      [PIPE_FORMAT_R4A4_UNORM]            = 0,
       [PIPE_FORMAT_A4R4_UNORM]            = 0,
+      [PIPE_FORMAT_R4A4_UNORM]            = 0,
       [PIPE_FORMAT_R8A8_UNORM]            = 0,
       [PIPE_FORMAT_A8R8_UNORM]            = 0,
       [PIPE_FORMAT_R10G10B10A2_SSCALED]   = BRW_SURFACEFORMAT_R10G10B10A2_SSCALED,
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
index 377eaa5..564e19a 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_blend_aos.c
@@ -255,7 +255,7 @@ lp_build_blend_factor(struct lp_build_blend_aos_context *bld,
    LLVMValueRef rgb_factor_, alpha_factor_;
    enum lp_build_blend_swizzle rgb_swizzle;
 
-   if (alpha_swizzle == 0) {
+   if (alpha_swizzle == UTIL_FORMAT_SWIZZLE_X && num_channels == 1) {
       return lp_build_blend_factor_unswizzled(bld, alpha_factor, TRUE);
    }
 
diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
index 5c13ee5..b6c32ff 100644
--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
@@ -363,7 +363,8 @@ get_z_shift_and_mask(const struct util_format_description *format_desc,
       return FALSE;
 
    *width = format_desc->channel[z_swizzle].size;
-   *shift = format_desc->channel[z_swizzle].shift;
+   /* & 31 is for the same reason as the 32-bit limit above */
+   *shift = format_desc->channel[z_swizzle].shift & 31;
 
    if (*width == total_bits) {
       *mask = 0xffffffff;
diff --git a/src/gallium/include/pipe/p_format.h b/src/gallium/include/pipe/p_format.h
index f181621..4cc0582 100644
--- a/src/gallium/include/pipe/p_format.h
+++ b/src/gallium/include/pipe/p_format.h
@@ -236,8 +236,8 @@ enum pipe_format {
    PIPE_FORMAT_NV12                    = 166,
    PIPE_FORMAT_NV21                    = 167,
 
-   PIPE_FORMAT_R4A4_UNORM              = 168,
-   PIPE_FORMAT_A4R4_UNORM              = 169,
+   PIPE_FORMAT_A4R4_UNORM              = 168,
+   PIPE_FORMAT_R4A4_UNORM              = 169,
    PIPE_FORMAT_R8A8_UNORM              = 170,
    PIPE_FORMAT_A8R8_UNORM              = 171,
 
diff --git a/src/gallium/state_trackers/vdpau/vdpau_private.h b/src/gallium/state_trackers/vdpau/vdpau_private.h
index 716d218..dd51d69 100644
--- a/src/gallium/state_trackers/vdpau/vdpau_private.h
+++ b/src/gallium/state_trackers/vdpau/vdpau_private.h
@@ -182,9 +182,9 @@ FormatIndexedToPipe(VdpRGBAFormat vdpau_format)
 {
    switch (vdpau_format) {
       case VDP_INDEXED_FORMAT_A4I4:
-         return PIPE_FORMAT_A4R4_UNORM;
-      case VDP_INDEXED_FORMAT_I4A4:
          return PIPE_FORMAT_R4A4_UNORM;
+      case VDP_INDEXED_FORMAT_I4A4:
+         return PIPE_FORMAT_A4R4_UNORM;
       case VDP_INDEXED_FORMAT_A8I8:
          return PIPE_FORMAT_A8R8_UNORM;
       case VDP_INDEXED_FORMAT_I8A8:
diff --git a/src/gallium/state_trackers/xvmc/subpicture.c b/src/gallium/state_trackers/xvmc/subpicture.c
index 3e13aa6..5898011 100644
--- a/src/gallium/state_trackers/xvmc/subpicture.c
+++ b/src/gallium/state_trackers/xvmc/subpicture.c
@@ -54,10 +54,10 @@ static enum pipe_format XvIDToPipe(int xvimage_id)
          return PIPE_FORMAT_B8G8R8X8_UNORM;
 
       case FOURCC_AI44:
-         return PIPE_FORMAT_A4R4_UNORM;
+         return PIPE_FORMAT_R4A4_UNORM;
 
       case FOURCC_IA44:
-         return PIPE_FORMAT_R4A4_UNORM;
+         return PIPE_FORMAT_A4R4_UNORM;
 
       default:
          XVMC_MSG(XVMC_ERR, "[XvMC] Unrecognized Xv image ID 0x%08X.\n", xvimage_id);
@@ -89,8 +89,8 @@ static int PipeToComponentOrder(enum pipe_format format, char *component_order)
       case PIPE_FORMAT_B8G8R8X8_UNORM:
          return 0;
 
-      case PIPE_FORMAT_R4A4_UNORM:
       case PIPE_FORMAT_A4R4_UNORM:
+      case PIPE_FORMAT_R4A4_UNORM:
          component_order[0] = 'Y';
          component_order[1] = 'U';
          component_order[2] = 'V';