[PATCH v2 03/14] etnaviv: rs: add support for multi layer formats

Lucas Stach l.stach at pengutronix.de
Fri May 4 07:56:12 UTC 2018


Am Dienstag, den 01.05.2018, 16:48 +0200 schrieb Christian Gmeiner:
> The binary blob driver supports 'multi layer' formats. For
> instance: gcvSURF_A16B16G16R16F_2_A8R8G8B8
>                      < format >_n_< base format >

Sort of high-level comment, but to me the usage of the term layer for
this is highly confusing, especially since layer is already used in the
context of textures with texture arrays.

My vote would be to come up with another description for this thing.

Regards,
Lucas

> This defines what base format we can use for RS.
> 
> > Signed-off-by: Christian Gmeiner <christian.gmeiner at gmail.com>
> ---
>  src/gallium/drivers/etnaviv/etnaviv_format.c | 56 ++++++++++++--------
>  src/gallium/drivers/etnaviv/etnaviv_format.h |  3 ++
>  2 files changed, 37 insertions(+), 22 deletions(-)
> 
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.c b/src/gallium/drivers/etnaviv/etnaviv_format.c
> index df4cff16d4..20beff84e8 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.c
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.c
> @@ -52,6 +52,10 @@ struct etna_format {
>  #define RS_FORMAT(x)          ((x) & RS_FORMAT_MASK)
>  #define RS_FORMAT_RB_SWAP     0x10
>  
> +#define RS_LAYER_MASK         0x700
> +#define RS_LAYER_SHIFT        8
> +#define RS_LAYER(x)           (((x) << RS_LAYER_SHIFT) & RS_LAYER_MASK)
> +
>  #define RS_FORMAT_X8B8G8R8    (RS_FORMAT_X8R8G8B8 | RS_FORMAT_RB_SWAP)
>  #define RS_FORMAT_A8B8G8R8    (RS_FORMAT_A8R8G8B8 | RS_FORMAT_RB_SWAP)
>  
> @@ -120,15 +124,15 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
>     V_(R16_SSCALED, SHORT,          NONE, NONE),
>     V_(R16_FLOAT,   HALF_FLOAT,     NONE, NONE),
>  
> -   _T(B4G4R4A4_UNORM, A4R4G4B4, SWIZ(X, Y, Z, W), A4R4G4B4, A4R4G4B4, A4R4G4B4),
> -   _T(B4G4R4X4_UNORM, X4R4G4B4, SWIZ(X, Y, Z, W), X4R4G4B4, A4R4G4B4, X4R4G4B4),
> +   _T(B4G4R4A4_UNORM, A4R4G4B4, SWIZ(X, Y, Z, W), A4R4G4B4 | RS_LAYER(1), A4R4G4B4, A4R4G4B4),
> +   _T(B4G4R4X4_UNORM, X4R4G4B4, SWIZ(X, Y, Z, W), X4R4G4B4 | RS_LAYER(1), A4R4G4B4, X4R4G4B4),
>  
> -   _T(L8A8_UNORM, A8L8, SWIZ(X, Y, Z, W), A4R4G4B4, NONE, NONE),
> +   _T(L8A8_UNORM, A8L8, SWIZ(X, Y, Z, W), A4R4G4B4 | RS_LAYER(1), NONE, NONE),
>  
> -   _T(Z16_UNORM,      D16,      SWIZ(X, Y, Z, W), A4R4G4B4, D16, A4R4G4B4),
> -   _T(B5G6R5_UNORM,   R5G6B5,   SWIZ(X, Y, Z, W), R5G6B5,   R5G6B5,   R5G6B5),
> -   _T(B5G5R5A1_UNORM, A1R5G5B5, SWIZ(X, Y, Z, W), A1R5G5B5, A1R5G5B5, A1R5G5B5),
> -   _T(B5G5R5X1_UNORM, X1R5G5B5, SWIZ(X, Y, Z, W), X1R5G5B5, A1R5G5B5, X1R5G5B5),
> +   _T(Z16_UNORM,      D16,      SWIZ(X, Y, Z, W), A4R4G4B4 | RS_LAYER(1), D16, A4R4G4B4),
> +   _T(B5G6R5_UNORM,   R5G6B5,   SWIZ(X, Y, Z, W), R5G6B5   | RS_LAYER(1), R5G6B5,   R5G6B5),
> +   _T(B5G5R5A1_UNORM, A1R5G5B5, SWIZ(X, Y, Z, W), A1R5G5B5 | RS_LAYER(1), A1R5G5B5, A1R5G5B5),
> +   _T(B5G5R5X1_UNORM, X1R5G5B5, SWIZ(X, Y, Z, W), X1R5G5B5 | RS_LAYER(1), A1R5G5B5, X1R5G5B5),
>  
>     VT(R8G8_UNORM,   UNSIGNED_BYTE,  EXT_G8R8 | EXT_FORMAT, SWIZ(X, Y, 0, 1), NONE, NONE, NONE),
>     V_(R8G8_SNORM,   BYTE,           NONE, NONE),
> @@ -165,26 +169,26 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
>  
>     V_(A8B8G8R8_UNORM,   UNSIGNED_BYTE, NONE, NONE),
>  
> -   VT(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8, A8R8G8B8, NONE),
> -   V_(R8G8B8A8_SNORM,   BYTE,          A8B8G8R8, NONE),
> -   _T(R8G8B8X8_UNORM,   X8B8G8R8,      SWIZ(X, Y, Z, W), X8B8G8R8, X8R8G8B8, NONE),
> -   V_(R8G8B8A8_UINT,    UNSIGNED_BYTE, A8B8G8R8, NONE),
> -   V_(R8G8B8A8_SINT,    BYTE,          A8B8G8R8, NONE),
> -   V_(R8G8B8A8_USCALED, UNSIGNED_BYTE, A8B8G8R8, NONE),
> -   V_(R8G8B8A8_SSCALED, BYTE,          A8B8G8R8, NONE),
> +   VT(R8G8B8A8_UNORM,   UNSIGNED_BYTE, A8B8G8R8, SWIZ(X, Y, Z, W), A8B8G8R8 | RS_LAYER(1), A8R8G8B8, NONE),
> +   V_(R8G8B8A8_SNORM,   BYTE,          A8B8G8R8 | RS_LAYER(1), NONE),
> +   _T(R8G8B8X8_UNORM,   X8B8G8R8,      SWIZ(X, Y, Z, W), X8B8G8R8 | RS_LAYER(1), X8R8G8B8, NONE),
> +   V_(R8G8B8A8_UINT,    UNSIGNED_BYTE, A8B8G8R8 | RS_LAYER(1), NONE),
> +   V_(R8G8B8A8_SINT,    BYTE,          A8B8G8R8 | RS_LAYER(1), NONE),
> +   V_(R8G8B8A8_USCALED, UNSIGNED_BYTE, A8B8G8R8 | RS_LAYER(1), NONE),
> +   V_(R8G8B8A8_SSCALED, BYTE,          A8B8G8R8 | RS_LAYER(1), NONE),
>  
> -   _T(B8G8R8A8_UNORM, A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8, A8R8G8B8, A8R8G8B8),
> -   _T(B8G8R8X8_UNORM, X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8, X8R8G8B8, X8R8G8B8),
> -   _T(B8G8R8A8_SRGB,  A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8, A8R8G8B8, A8R8G8B8),
> -   _T(B8G8R8X8_SRGB,  X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8, X8R8G8B8, X8R8G8B8),
> +   _T(B8G8R8A8_UNORM, A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8 | RS_LAYER(1), A8R8G8B8, A8R8G8B8),
> +   _T(B8G8R8X8_UNORM, X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8 | RS_LAYER(1), X8R8G8B8, X8R8G8B8),
> +   _T(B8G8R8A8_SRGB,  A8R8G8B8, SWIZ(X, Y, Z, W), A8R8G8B8 | RS_LAYER(1), A8R8G8B8, A8R8G8B8),
> +   _T(B8G8R8X8_SRGB,  X8R8G8B8, SWIZ(X, Y, Z, W), X8R8G8B8 | RS_LAYER(1), X8R8G8B8, X8R8G8B8),
>  
>     V_(R10G10B10A2_UNORM,   UNSIGNED_INT_10_10_10_2, NONE, NONE),
>     V_(R10G10B10A2_SNORM,   INT_10_10_10_2,          NONE, NONE),
>     V_(R10G10B10A2_USCALED, UNSIGNED_INT_10_10_10_2, NONE, NONE),
>     V_(R10G10B10A2_SSCALED, INT_10_10_10_2,          NONE, NONE),
>  
> -   _T(X8Z24_UNORM,       D24X8, SWIZ(X, Y, Z, W), A8R8G8B8, D24X8, A8R8G8B8),
> -   _T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8, D24X8, A8R8G8B8),
> +   _T(X8Z24_UNORM,       D24X8, SWIZ(X, Y, Z, W), A8R8G8B8 | RS_LAYER(1), D24X8, A8R8G8B8),
> +   _T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8 | RS_LAYER(1), D24X8, A8R8G8B8),
>  
>     /* 48-bit */
>     V_(R16G16B16_UNORM,   UNSIGNED_SHORT, NONE, NONE),
> @@ -286,8 +290,8 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
>     _T(ASTC_12x12_SRGB, ASTC_SRGB8_ALPHA8_12x12 | ASTC_FORMAT,          SWIZ(X, Y, Z, W), NONE, NONE, NONE),
>  
>     /* YUV */
> -   _T(YUYV, YUY2, SWIZ(X, Y, Z, W), A4R4G4B4, NONE, YUY2),
> -   _T(UYVY, UYVY, SWIZ(X, Y, Z, W), A4R4G4B4, NONE, NONE),
> +   _T(YUYV, YUY2, SWIZ(X, Y, Z, W), A4R4G4B4 | RS_LAYER(1), NONE, YUY2),
> +   _T(UYVY, UYVY, SWIZ(X, Y, Z, W), A4R4G4B4 | RS_LAYER(1), NONE, NONE),
>  };
>  
>  uint32_t
> @@ -356,6 +360,14 @@ translate_rs_format_rb_swap(enum pipe_format fmt)
>     return formats[fmt].rs & RS_FORMAT_RB_SWAP;
>  }
>  
> +int
> +translate_rs_layer(enum pipe_format fmt)
> +{
> +   assert(formats[fmt].present);
> +
> +   return (formats[fmt].rs & RS_LAYER_MASK) >> RS_LAYER_SHIFT;
> +}
> +
>  /* Return type flags for vertex element format */
>  uint32_t
>  translate_vertex_format_type(enum pipe_format fmt)
> diff --git a/src/gallium/drivers/etnaviv/etnaviv_format.h b/src/gallium/drivers/etnaviv/etnaviv_format.h
> index 448f4c298f..e490080421 100644
> --- a/src/gallium/drivers/etnaviv/etnaviv_format.h
> +++ b/src/gallium/drivers/etnaviv/etnaviv_format.h
> @@ -50,6 +50,9 @@ translate_rs_format(enum pipe_format fmt);
>  int
>  translate_rs_format_rb_swap(enum pipe_format fmt);
>  
> +int
> +translate_rs_layer(enum pipe_format fmt);
> +
>  uint32_t
>  translate_vertex_format_type(enum pipe_format fmt);
>  


More information about the etnaviv mailing list