[Mesa-dev] [PATCH 03/13] gallium: Introduce 32-bit bytewise format names

Jose Fonseca jfonseca at vmware.com
Fri May 17 08:07:38 PDT 2013


----- Original Message -----
> From: Richard Sandiford <r.sandiford at uk.ibm.com>
> 
> RGBA8888 has R at byte 0 and A at byte 3, regardless of platform
> endianness.

Maybe I'm missing something, but this naming convention seems to me the exact opposite of what was decided [1], which is:

 - R at byte 0, ..., and A at byte 3, regardless of platform endianness would be called "R8G8B8A8"

 - R at bit 0, ..., A at bit 24, encoded as integers that match the platform endianness would be called "RGBA8888"

which would be consistent with (as in a superset of) D3D10 format naming.  I'm afraid I must insist on this, as I don't want D3D10 formats to change in anyway.  It should be hard to do this -- you can easily craft a script that swaps these using statements like:

   git ls-files | xargs sed -i -e 's at foo@boo@'

But other than this naming convention issue, the actual implementation looks quite nice.

Jose

[1] http://lists.freedesktop.org/archives/mesa-dev/2013-February/034378.html , from "Actually, on second thought ..."


> 
> Reviewed-by: Adam Jackson <ajax at redhat.com>
> ---
>  src/gallium/include/pipe/p_format.h | 38
>  +++++++++++++++++++++++++++++--------
>  1 file changed, 30 insertions(+), 8 deletions(-)
> 
> diff --git a/src/gallium/include/pipe/p_format.h
> b/src/gallium/include/pipe/p_format.h
> index 098b25b..1289983 100644
> --- a/src/gallium/include/pipe/p_format.h
> +++ b/src/gallium/include/pipe/p_format.h
> @@ -33,6 +33,7 @@
>  extern "C" {
>  #endif
>  
> +#include "p_config.h"
>  
>  enum pipe_type {
>     PIPE_TYPE_UNORM = 0,
> @@ -53,10 +54,10 @@ enum pipe_type {
>  
>  enum pipe_format {
>     PIPE_FORMAT_NONE                    = 0,
> -   PIPE_FORMAT_B8G8R8A8_UNORM          = 1,
> -   PIPE_FORMAT_B8G8R8X8_UNORM          = 2,
> -   PIPE_FORMAT_A8R8G8B8_UNORM          = 3,
> -   PIPE_FORMAT_X8R8G8B8_UNORM          = 4,
> +   PIPE_FORMAT_ARGB8888_UNORM          = 1,
> +   PIPE_FORMAT_XRGB8888_UNORM          = 2,
> +   PIPE_FORMAT_BGRA8888_UNORM          = 3,
> +   PIPE_FORMAT_BGRX8888_UNORM          = 4,
>     PIPE_FORMAT_B5G5R5A1_UNORM          = 5,
>     PIPE_FORMAT_B4G4R4A4_UNORM          = 6,
>     PIPE_FORMAT_B5G6R5_UNORM            = 7,
> @@ -119,8 +120,8 @@ enum pipe_format {
>     PIPE_FORMAT_R8_UNORM                = 64,
>     PIPE_FORMAT_R8G8_UNORM              = 65,
>     PIPE_FORMAT_R8G8B8_UNORM            = 66,
> -   PIPE_FORMAT_R8G8B8A8_UNORM          = 67,
> -   PIPE_FORMAT_X8B8G8R8_UNORM          = 68,
> +   PIPE_FORMAT_ABGR8888_UNORM          = 67,
> +   PIPE_FORMAT_RGBX8888_UNORM          = 68,
>     PIPE_FORMAT_R8_USCALED              = 69,
>     PIPE_FORMAT_R8G8_USCALED            = 70,
>     PIPE_FORMAT_R8G8B8_USCALED          = 71,
> @@ -180,7 +181,7 @@ enum pipe_format {
>     PIPE_FORMAT_R5SG5SB6U_NORM          = 120,
>  
>     /* TODO: re-order these */
> -   PIPE_FORMAT_A8B8G8R8_UNORM          = 121,
> +   PIPE_FORMAT_RGBA8888_UNORM          = 121,
>     PIPE_FORMAT_B5G5R5X1_UNORM          = 122,
>     PIPE_FORMAT_R10G10B10A2_USCALED     = 123,
>     PIPE_FORMAT_R11G11B10_FLOAT         = 124,
> @@ -193,7 +194,7 @@ enum pipe_format {
>     PIPE_FORMAT_B10G10R10A2_UNORM       = 131,
>     PIPE_FORMAT_R10SG10SB10SA2U_NORM    = 132,
>     PIPE_FORMAT_R8G8Bx_SNORM            = 133,
> -   PIPE_FORMAT_R8G8B8X8_UNORM          = 134,
> +   PIPE_FORMAT_XBGR8888_UNORM          = 134,
>     PIPE_FORMAT_B4G4R4X4_UNORM          = 135,
>  
>     /* some stencil samplers formats */
> @@ -343,6 +344,27 @@ enum pipe_format {
>     PIPE_FORMAT_COUNT
>  };
>  
> +#if defined(PIPE_ARCH_LITTLE_ENDIAN)
> +#define PIPE_FORMAT_R8G8B8A8_UNORM PIPE_FORMAT_ABGR8888_UNORM
> +#define PIPE_FORMAT_R8G8B8X8_UNORM PIPE_FORMAT_XBGR8888_UNORM
> +#define PIPE_FORMAT_B8G8R8X8_UNORM PIPE_FORMAT_XRGB8888_UNORM
> +#define PIPE_FORMAT_B8G8R8A8_UNORM PIPE_FORMAT_ARGB8888_UNORM
> +#define PIPE_FORMAT_B8G8R8X8_UNORM PIPE_FORMAT_XRGB8888_UNORM
> +#define PIPE_FORMAT_A8R8G8B8_UNORM PIPE_FORMAT_BGRA8888_UNORM
> +#define PIPE_FORMAT_X8R8G8B8_UNORM PIPE_FORMAT_BGRX8888_UNORM
> +#define PIPE_FORMAT_A8B8G8R8_UNORM PIPE_FORMAT_RGBA8888_UNORM
> +#define PIPE_FORMAT_X8B8G8R8_UNORM PIPE_FORMAT_RGBX8888_UNORM
> +#elif defined(PIPE_ARCH_BIG_ENDIAN)
> +#define PIPE_FORMAT_R8G8B8A8_UNORM PIPE_FORMAT_RGBA8888_UNORM
> +#define PIPE_FORMAT_R8G8B8X8_UNORM PIPE_FORMAT_RGBX8888_UNORM
> +#define PIPE_FORMAT_B8G8R8A8_UNORM PIPE_FORMAT_BGRA8888_UNORM
> +#define PIPE_FORMAT_B8G8R8X8_UNORM PIPE_FORMAT_BGRX8888_UNORM
> +#define PIPE_FORMAT_A8R8G8B8_UNORM PIPE_FORMAT_ARGB8888_UNORM
> +#define PIPE_FORMAT_X8R8G8B8_UNORM PIPE_FORMAT_XRGB8888_UNORM
> +#define PIPE_FORMAT_A8B8G8R8_UNORM PIPE_FORMAT_ABGR8888_UNORM
> +#define PIPE_FORMAT_X8B8G8R8_UNORM PIPE_FORMAT_XBGR8888_UNORM
> +#endif
> +
>  enum pipe_video_chroma_format
>  {
>     PIPE_VIDEO_CHROMA_FORMAT_420,
> --
> 1.8.2.1
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list