[Freedreno] [PATCH 4/4] freedreno/a3xx: unify vertex/texture formats into a single table

Rob Clark robdclark at gmail.com
Sat Nov 29 06:14:07 PST 2014


On Fri, Nov 28, 2014 at 6:06 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> The table contains all the relevant information about each format. The
> helper functions now just do lookups in the table.
>
> Note that this adds support for a lot of formats that were previously
> unsupported. Additionally it adds disabled support for integer render
> buffers, which will require more work to actually enable.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>

Reviewed-by: Rob Clark <robclark at freedesktop.org>

> ---
>  docs/relnotes/10.5.0.html                       |   4 +
>  src/gallium/drivers/freedreno/a3xx/fd3_format.c | 566 +++++++++---------------
>  2 files changed, 218 insertions(+), 352 deletions(-)
>
> diff --git a/docs/relnotes/10.5.0.html b/docs/relnotes/10.5.0.html
> index 84bfcdb..c6df2de 100644
> --- a/docs/relnotes/10.5.0.html
> +++ b/docs/relnotes/10.5.0.html
> @@ -44,6 +44,10 @@ Note: some of the new features are only available with certain drivers.
>  </p>
>
>  <ul>
> +<li>GL_ARB_texture_rg on freedreno</li>
> +<li>GL_EXT_packed_float on freedreno</li>
> +<li>GL_EXT_texture_shared_exponent on freedreno</li>
> +<li>GL_EXT_texture_snorm on freedreno</li>
>  </ul>
>
>
> diff --git a/src/gallium/drivers/freedreno/a3xx/fd3_format.c b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
> index 41e48d0..9b22c9e 100644
> --- a/src/gallium/drivers/freedreno/a3xx/fd3_format.c
> +++ b/src/gallium/drivers/freedreno/a3xx/fd3_format.c
> @@ -1,5 +1,3 @@
> -/* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
> -
>  /*
>   * Copyright (C) 2013 Rob Clark <robclark at freedesktop.org>
>   *
> @@ -22,8 +20,6 @@
>   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
>   * SOFTWARE.
>   *
> - * Authors:
> - *    Rob Clark <robclark at freedesktop.org>
>   */
>
>  #include "pipe/p_defines.h"
> @@ -31,342 +27,239 @@
>
>  #include "fd3_format.h"
>
> -/* convert pipe format to vertex buffer format: */
> -enum a3xx_vtx_fmt
> -fd3_pipe2vtx(enum pipe_format format)
> -{
> -       switch (format) {
> -       /* 8-bit buffers. */
> -       case PIPE_FORMAT_R8_UNORM:
> -               return VFMT_8_UNORM;
> -
> -       case PIPE_FORMAT_R8_SNORM:
> -               return VFMT_8_SNORM;
> -
> -       case PIPE_FORMAT_R8_UINT:
> -       case PIPE_FORMAT_R8_USCALED:
> -               return VFMT_8_UINT;
> -
> -       case PIPE_FORMAT_R8_SINT:
> -       case PIPE_FORMAT_R8_SSCALED:
> -               return VFMT_8_SINT;
> -
> -       /* 16-bit buffers. */
> -       case PIPE_FORMAT_R16_UNORM:
> -       case PIPE_FORMAT_Z16_UNORM:
> -               return VFMT_16_UNORM;
> -
> -       case PIPE_FORMAT_R16_SNORM:
> -               return VFMT_16_SNORM;
> -
> -       case PIPE_FORMAT_R16_UINT:
> -       case PIPE_FORMAT_R16_USCALED:
> -               return VFMT_16_UINT;
> -
> -       case PIPE_FORMAT_R16_SINT:
> -       case PIPE_FORMAT_R16_SSCALED:
> -               return VFMT_16_SINT;
> -
> -       case PIPE_FORMAT_R16_FLOAT:
> -               return VFMT_16_FLOAT;
> -
> -       case PIPE_FORMAT_R8G8_UNORM:
> -               return VFMT_8_8_UNORM;
> -
> -       case PIPE_FORMAT_R8G8_SNORM:
> -               return VFMT_8_8_SNORM;
> -
> -       case PIPE_FORMAT_R8G8_UINT:
> -       case PIPE_FORMAT_R8G8_USCALED:
> -               return VFMT_8_8_UINT;
> -
> -       case PIPE_FORMAT_R8G8_SINT:
> -       case PIPE_FORMAT_R8G8_SSCALED:
> -               return VFMT_8_8_SINT;
> -
> -       /* 24-bit buffers. */
> -       case PIPE_FORMAT_R8G8B8_UNORM:
> -               return VFMT_8_8_8_UNORM;
> -
> -       case PIPE_FORMAT_R8G8B8_SNORM:
> -               return VFMT_8_8_8_SNORM;
> -
> -       case PIPE_FORMAT_R8G8B8_UINT:
> -       case PIPE_FORMAT_R8G8B8_USCALED:
> -               return VFMT_8_8_8_UINT;
> -
> -       case PIPE_FORMAT_R8G8B8_SINT:
> -       case PIPE_FORMAT_R8G8B8_SSCALED:
> -               return VFMT_8_8_8_SINT;
> -
> -       /* 32-bit buffers. */
> -       case PIPE_FORMAT_A8B8G8R8_UNORM:
> -       case PIPE_FORMAT_A8R8G8B8_UNORM:
> -       case PIPE_FORMAT_B8G8R8A8_UNORM:
> -       case PIPE_FORMAT_R8G8B8A8_UNORM:
> -               return VFMT_8_8_8_8_UNORM;
> -
> -       case PIPE_FORMAT_R8G8B8A8_SNORM:
> -               return VFMT_8_8_8_8_SNORM;
> -
> -       case PIPE_FORMAT_R8G8B8A8_UINT:
> -       case PIPE_FORMAT_R8G8B8A8_USCALED:
> -               return VFMT_8_8_8_8_UINT;
> -
> -       case PIPE_FORMAT_R8G8B8A8_SINT:
> -       case PIPE_FORMAT_R8G8B8A8_SSCALED:
> -               return VFMT_8_8_8_8_SINT;
> -
> -       case PIPE_FORMAT_R16G16_SSCALED:
> -       case PIPE_FORMAT_R16G16_SINT:
> -               return VFMT_16_16_SINT;
> -
> -       case PIPE_FORMAT_R16G16_FLOAT:
> -               return VFMT_16_16_FLOAT;
> -
> -       case PIPE_FORMAT_R16G16_UINT:
> -       case PIPE_FORMAT_R16G16_USCALED:
> -               return VFMT_16_16_UINT;
> -
> -       case PIPE_FORMAT_R16G16_UNORM:
> -               return VFMT_16_16_UNORM;
> -
> -       case PIPE_FORMAT_R16G16_SNORM:
> -               return VFMT_16_16_SNORM;
> -
> -       case PIPE_FORMAT_R32_UINT:
> -       case PIPE_FORMAT_R32_USCALED:
> -               return VFMT_32_UINT;
> -
> -       case PIPE_FORMAT_R32_SINT:
> -       case PIPE_FORMAT_R32_SSCALED:
> -               return VFMT_32_SINT;
> -
> -       case PIPE_FORMAT_R10G10B10A2_UNORM:
> -               return VFMT_10_10_10_2_UNORM;
> -
> -       case PIPE_FORMAT_R10G10B10A2_SNORM:
> -               return VFMT_10_10_10_2_SNORM;
> -
> -       case PIPE_FORMAT_R10G10B10A2_UINT:
> -       case PIPE_FORMAT_R10G10B10A2_USCALED:
> -               return VFMT_10_10_10_2_UINT;
> -
> -       case PIPE_FORMAT_R10G10B10A2_SSCALED:
> -               return VFMT_10_10_10_2_SINT;
> -
> -       /* 48-bit buffers. */
> -       case PIPE_FORMAT_R16G16B16_FLOAT:
> -               return VFMT_16_16_16_FLOAT;
> -
> -       case PIPE_FORMAT_R16G16B16_SINT:
> -       case PIPE_FORMAT_R16G16B16_SSCALED:
> -               return VFMT_16_16_16_SINT;
> -
> -       case PIPE_FORMAT_R16G16B16_UINT:
> -       case PIPE_FORMAT_R16G16B16_USCALED:
> -               return VFMT_16_16_16_UINT;
> -
> -       case PIPE_FORMAT_R16G16B16_SNORM:
> -               return VFMT_16_16_16_SNORM;
> -
> -       case PIPE_FORMAT_R16G16B16_UNORM:
> -               return VFMT_16_16_16_UNORM;
> -
> -       case PIPE_FORMAT_R32_FLOAT:
> -       case PIPE_FORMAT_Z32_FLOAT:
> -               return VFMT_32_FLOAT;
> -
> -       case PIPE_FORMAT_R32_FIXED:
> -               return VFMT_32_FIXED;
> -
> -       /* 64-bit buffers. */
> -       case PIPE_FORMAT_R16G16B16A16_UNORM:
> -               return VFMT_16_16_16_16_UNORM;
> -
> -       case PIPE_FORMAT_R16G16B16A16_SNORM:
> -               return VFMT_16_16_16_16_SNORM;
> -
> -       case PIPE_FORMAT_R16G16B16A16_UINT:
> -       case PIPE_FORMAT_R16G16B16A16_USCALED:
> -               return VFMT_16_16_16_16_UINT;
> -
> -       case PIPE_FORMAT_R16G16B16A16_SINT:
> -       case PIPE_FORMAT_R16G16B16A16_SSCALED:
> -               return VFMT_16_16_16_16_SINT;
> -
> -       case PIPE_FORMAT_R32G32_FLOAT:
> -               return VFMT_32_32_FLOAT;
> -
> -       case PIPE_FORMAT_R32G32_FIXED:
> -               return VFMT_32_32_FIXED;
> -
> -       case PIPE_FORMAT_R16G16B16A16_FLOAT:
> -               return VFMT_16_16_16_16_FLOAT;
> -
> -       case PIPE_FORMAT_R32G32_UINT:
> -       case PIPE_FORMAT_R32G32_USCALED:
> -               return VFMT_32_32_UINT;
> -
> -       case PIPE_FORMAT_R32G32_SINT:
> -       case PIPE_FORMAT_R32G32_SSCALED:
> -               return VFMT_32_32_SINT;
> -
> -       /* 96-bit buffers. */
> -       case PIPE_FORMAT_R32G32B32_FLOAT:
> -               return VFMT_32_32_32_FLOAT;
> -
> -       case PIPE_FORMAT_R32G32B32_FIXED:
> -               return VFMT_32_32_32_FIXED;
> -
> -       case PIPE_FORMAT_R32G32B32_UINT:
> -       case PIPE_FORMAT_R32G32B32_USCALED:
> -               return VFMT_32_32_32_UINT;
> -
> -       case PIPE_FORMAT_R32G32B32_SINT:
> -       case PIPE_FORMAT_R32G32B32_SSCALED:
> -               return VFMT_32_32_32_SINT;
> -
> -       /* 128-bit buffers. */
> -       case PIPE_FORMAT_R32G32B32A32_FLOAT:
> -               return VFMT_32_32_32_32_FLOAT;
> +/* Specifies the table of all the formats and their features. Also supplies
> + * the helpers that look up various data in those tables.
> + */
>
> -       case PIPE_FORMAT_R32G32B32A32_FIXED:
> -               return VFMT_32_32_32_32_FIXED;
> +struct fd3_format {
> +       enum a3xx_vtx_fmt vtx;
> +       enum a3xx_tex_fmt tex;
> +       enum a3xx_color_fmt rb;
> +       enum a3xx_color_swap swap;
> +       boolean present;
> +};
> +
> +#define RB_NONE ~0
> +
> +/* vertex + texture */
> +#define VT(pipe, fmt, rbfmt, swapfmt) \
> +       [PIPE_FORMAT_ ## pipe] = { \
> +               .present = 1, \
> +               .vtx = VFMT_ ## fmt, \
> +               .tex = TFMT_ ## fmt, \
> +               .rb = RB_ ## rbfmt, \
> +               .swap = swapfmt \
> +       }
>
> -       case PIPE_FORMAT_R32G32B32A32_UINT:
> -       case PIPE_FORMAT_R32G32B32A32_USCALED:
> -               return VFMT_32_32_32_32_UINT;
> +/* texture-only */
> +#define _T(pipe, fmt, rbfmt, swapfmt) \
> +       [PIPE_FORMAT_ ## pipe] = { \
> +               .present = 1, \
> +               .vtx = ~0, \
> +               .tex = TFMT_ ## fmt, \
> +               .rb = RB_ ## rbfmt, \
> +               .swap = swapfmt \
> +       }
>
> -       case PIPE_FORMAT_R32G32B32A32_SINT:
> -       case PIPE_FORMAT_R32G32B32A32_SSCALED:
> -               return VFMT_32_32_32_32_SINT;
> +/* vertex-only */
> +#define V_(pipe, fmt, rbfmt, swapfmt) \
> +       [PIPE_FORMAT_ ## pipe] = { \
> +               .present = 1, \
> +               .vtx = VFMT_ ## fmt, \
> +               .tex = ~0, \
> +               .rb = RB_ ## rbfmt, \
> +               .swap = swapfmt \
> +       }
>
> -/* TODO normalized 32bit int formats do not appear to be supported
> - * natively.. will require either shader variant or VFD_DECODE
> - * gymnastics like the blob driver does..
> -       case PIPE_FORMAT_R32G32B32A32_SNORM:
> -       case PIPE_FORMAT_R32G32B32A32_UNORM:
> - */
> +static struct fd3_format formats[PIPE_FORMAT_COUNT] = {
> +       /* 8-bit */
> +       VT(R8_UNORM,   8_UNORM, R8_UNORM, WZYX),
> +       VT(R8_SNORM,   8_SNORM, NONE,     WZYX),
> +       VT(R8_UINT,    8_UINT,  R8_UINT,  WZYX),
> +       VT(R8_SINT,    8_SINT,  R8_SINT,  WZYX),
> +       V_(R8_USCALED, 8_UINT,  NONE,     WZYX),
> +       V_(R8_SSCALED, 8_UINT,  NONE,     WZYX),
> +
> +       _T(A8_UNORM,   8_UNORM, A8_UNORM, WZYX),
> +       _T(L8_UNORM,   8_UNORM, R8_UNORM, WZYX),
> +       _T(I8_UNORM,   8_UNORM, NONE,     WZYX),
> +
> +       /* 16-bit */
> +       V_(R16_UNORM,   16_UNORM, NONE,     WZYX),
> +       V_(R16_SNORM,   16_SNORM, NONE,     WZYX),
> +       VT(R16_UINT,    16_UINT,  R16_UINT, WZYX),
> +       VT(R16_SINT,    16_SINT,  R16_SINT, WZYX),
> +       V_(R16_USCALED, 16_UINT,  NONE,     WZYX),
> +       V_(R16_SSCALED, 16_UINT,  NONE,     WZYX),
> +       VT(R16_FLOAT,   16_FLOAT, NONE,     WZYX),
> +
> +       VT(R8G8_UNORM,   8_8_UNORM, R8G8_UNORM, WZYX),
> +       VT(R8G8_SNORM,   8_8_SNORM, R8G8_SNORM, WZYX),
> +       VT(R8G8_UINT,    8_8_UINT,  NONE,       WZYX),
> +       VT(R8G8_SINT,    8_8_SINT,  NONE,       WZYX),
> +       V_(R8G8_USCALED, 8_8_UINT,  NONE,       WZYX),
> +       V_(R8G8_SSCALED, 8_8_SINT,  NONE,       WZYX),
> +
> +       _T(Z16_UNORM,      Z16_UNORM,     R8G8_UNORM,     WZYX),
> +       /*_T(B5G6R5_UNORM,   5_6_5_UNORM,   R5G6B5_UNORM,   WXYZ),*/
> +       _T(B5G5R5A1_UNORM, 5_5_5_1_UNORM, R5G5B5A1_UNORM, WXYZ),
> +       _T(B4G4R4A4_UNORM, 4_4_4_4_UNORM, R4G4B4A4_UNORM, WXYZ),
> +
> +       /* 24-bit */
> +       VT(R8G8B8_UNORM,   8_8_8_UNORM, R8G8B8_UNORM, WZYX),
> +       VT(R8G8B8_SNORM,   8_8_8_SNORM, NONE,         WZYX),
> +       VT(R8G8B8_UINT,    8_8_8_UINT,  NONE,         WZYX),
> +       VT(R8G8B8_SINT,    8_8_8_SINT,  NONE,         WZYX),
> +       V_(R8G8B8_USCALED, 8_8_8_UINT,  NONE,         WZYX),
> +       V_(R8G8B8_SSCALED, 8_8_8_SINT,  NONE,         WZYX),
> +
> +       /* 32-bit */
> +       VT(R32_UINT,    32_UINT,  R32_UINT, WZYX),
> +       VT(R32_SINT,    32_SINT,  R32_SINT, WZYX),
> +       V_(R32_USCALED, 32_UINT,  NONE,     WZYX),
> +       V_(R32_SSCALED, 32_UINT,  NONE,     WZYX),
> +       VT(R32_FLOAT,   32_FLOAT, NONE,     WZYX),
> +       V_(R32_FIXED,   32_FIXED, NONE,     WZYX),
> +
> +       V_(R16G16_UNORM,   16_16_UNORM, NONE,        WZYX),
> +       V_(R16G16_SNORM,   16_16_SNORM, NONE,        WZYX),
> +       VT(R16G16_UINT,    16_16_UINT,  R16G16_UINT, WZYX),
> +       VT(R16G16_SINT,    16_16_SINT,  R16G16_SINT, WZYX),
> +       V_(R16G16_USCALED, 16_16_UINT,  NONE,        WZYX),
> +       V_(R16G16_SSCALED, 16_16_SINT,  NONE,        WZYX),
> +       VT(R16G16_FLOAT,   16_16_FLOAT, NONE,        WZYX),
> +
> +       VT(R8G8B8A8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, WZYX),
> +       _T(R8G8B8X8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, WZYX),
> +       _T(R8G8B8A8_SRGB,    8_8_8_8_UNORM, NONE,           WZYX),
> +       _T(R8G8B8X8_SRGB,    8_8_8_8_UNORM, NONE,           WZYX),
> +       VT(R8G8B8A8_SNORM,   8_8_8_8_SNORM, R8G8B8A8_SNORM, WZYX),
> +       VT(R8G8B8A8_UINT,    8_8_8_8_UINT,  R8G8B8A8_UINT,  WZYX),
> +       VT(R8G8B8A8_SINT,    8_8_8_8_SINT,  R8G8B8A8_SINT,  WZYX),
> +       V_(R8G8B8A8_USCALED, 8_8_8_8_UINT,  NONE,           WZYX),
> +       V_(R8G8B8A8_SSCALED, 8_8_8_8_SINT,  NONE,           WZYX),
> +
> +       VT(B8G8R8A8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, WXYZ),
> +       _T(B8G8R8X8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, WXYZ),
> +       VT(B8G8R8A8_SRGB,    8_8_8_8_UNORM, NONE,           WXYZ),
> +       _T(B8G8R8X8_SRGB,    8_8_8_8_UNORM, NONE,           WXYZ),
> +
> +       VT(A8B8G8R8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, XYZW),
> +       _T(X8B8G8R8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, XYZW),
> +       _T(A8B8G8R8_SRGB,    8_8_8_8_UNORM, NONE,           XYZW),
> +       _T(X8B8G8R8_SRGB,    8_8_8_8_UNORM, NONE,           XYZW),
> +
> +       VT(A8R8G8B8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, ZYXW),
> +       _T(X8R8G8B8_UNORM,   8_8_8_8_UNORM, R8G8B8A8_UNORM, ZYXW),
> +       _T(A8R8G8B8_SRGB,    8_8_8_8_UNORM, NONE,           ZYXW),
> +       _T(X8R8G8B8_SRGB,    8_8_8_8_UNORM, NONE,           ZYXW),
> +
> +       V_(R10G10B10A2_UNORM,   10_10_10_2_UNORM, NONE/*R10G10B10A2_UNORM*/, WZYX),
> +       V_(R10G10B10A2_SNORM,   10_10_10_2_SNORM, NONE,              WZYX),
> +       V_(R10G10B10A2_UINT,    10_10_10_2_UINT,  NONE,              WZYX),
> +       V_(R10G10B10A2_USCALED, 10_10_10_2_UINT,  NONE,              WZYX),
> +       V_(R10G10B10A2_SSCALED, 10_10_10_2_SINT,  NONE,              WZYX),
> +
> +       _T(R11G11B10_FLOAT, 11_11_10_FLOAT, R11G11B10_FLOAT, WZYX),
> +       _T(R9G9B9E5_FLOAT,  9_9_9_E5_FLOAT, NONE,            WZYX),
> +
> +       _T(Z24X8_UNORM,       X8Z24_UNORM, R8G8B8A8_UNORM, WZYX),
> +       _T(Z24_UNORM_S8_UINT, X8Z24_UNORM, R8G8B8A8_UNORM, WZYX),
> +       /*_T(Z32_FLOAT,         Z32_FLOAT,   R8G8B8A8_UNORM, WZYX),*/
> +
> +       /* 48-bit */
> +       V_(R16G16B16_UNORM,   16_16_16_UNORM, NONE, WZYX),
> +       V_(R16G16B16_SNORM,   16_16_16_SNORM, NONE, WZYX),
> +       V_(R16G16B16_UINT,    16_16_16_UINT,  NONE, WZYX),
> +       V_(R16G16B16_SINT,    16_16_16_SINT,  NONE, WZYX),
> +       V_(R16G16B16_USCALED, 16_16_16_UINT,  NONE, WZYX),
> +       V_(R16G16B16_SSCALED, 16_16_16_SINT,  NONE, WZYX),
> +       V_(R16G16B16_FLOAT,   16_16_16_FLOAT, NONE, WZYX),
> +
> +       /* 64-bit */
> +       V_(R16G16B16A16_UNORM,   16_16_16_16_UNORM, NONE,               WZYX),
> +       V_(R16G16B16A16_SNORM,   16_16_16_16_SNORM, NONE,               WZYX),
> +       VT(R16G16B16A16_UINT,    16_16_16_16_UINT,  R16G16B16A16_UINT,  WZYX),
> +       _T(R16G16B16X16_UINT,    16_16_16_16_UINT,  R16G16B16A16_UINT,  WZYX),
> +       VT(R16G16B16A16_SINT,    16_16_16_16_SINT,  R16G16B16A16_SINT,  WZYX),
> +       _T(R16G16B16X16_SINT,    16_16_16_16_SINT,  R16G16B16A16_SINT,  WZYX),
> +       V_(R16G16B16A16_USCALED, 16_16_16_16_UINT,  NONE,               WZYX),
> +       V_(R16G16B16A16_SSCALED, 16_16_16_16_SINT,  NONE,               WZYX),
> +       VT(R16G16B16A16_FLOAT,   16_16_16_16_FLOAT, R16G16B16A16_FLOAT, WZYX),
> +       _T(R16G16B16X16_FLOAT,   16_16_16_16_FLOAT, R16G16B16A16_FLOAT, WZYX),
> +
> +       VT(R32G32_UINT,    32_32_UINT,  R32G32_UINT, WZYX),
> +       VT(R32G32_SINT,    32_32_SINT,  R32G32_SINT, WZYX),
> +       V_(R32G32_USCALED, 32_32_UINT,  NONE,        WZYX),
> +       V_(R32G32_SSCALED, 32_32_SINT,  NONE,        WZYX),
> +       VT(R32G32_FLOAT,   32_32_FLOAT, NONE,        WZYX),
> +       V_(R32G32_FIXED,   32_32_FIXED, NONE,        WZYX),
> +
> +       /* 96-bit */
> +       V_(R32G32B32_UINT,    32_32_32_UINT,  NONE, WZYX),
> +       V_(R32G32B32_SINT,    32_32_32_SINT,  NONE, WZYX),
> +       V_(R32G32B32_USCALED, 32_32_32_UINT,  NONE, WZYX),
> +       V_(R32G32B32_SSCALED, 32_32_32_SINT,  NONE, WZYX),
> +       V_(R32G32B32_FLOAT,   32_32_32_FLOAT, NONE, WZYX),
> +       V_(R32G32B32_FIXED,   32_32_32_FIXED, NONE, WZYX),
> +
> +       /* 128-bit */
> +       VT(R32G32B32A32_UINT,    32_32_32_32_UINT,  R32G32B32A32_UINT,  WZYX),
> +       _T(R32G32B32X32_UINT,    32_32_32_32_UINT,  R32G32B32A32_UINT,  WZYX),
> +       VT(R32G32B32A32_SINT,    32_32_32_32_SINT,  R32G32B32A32_SINT,  WZYX),
> +       _T(R32G32B32X32_SINT,    32_32_32_32_SINT,  R32G32B32A32_SINT,  WZYX),
> +       V_(R32G32B32A32_USCALED, 32_32_32_32_UINT,  NONE,               WZYX),
> +       V_(R32G32B32A32_SSCALED, 32_32_32_32_SINT,  NONE,               WZYX),
> +       VT(R32G32B32A32_FLOAT,   32_32_32_32_FLOAT, R32G32B32A32_FLOAT, WZYX),
> +       _T(R32G32B32X32_FLOAT,   32_32_32_32_FLOAT, R32G32B32A32_FLOAT, WZYX),
> +       V_(R32G32B32A32_FIXED,   32_32_32_32_FIXED, NONE,               WZYX),
> +};
>
> -       default:
> +enum a3xx_vtx_fmt
> +fd3_pipe2vtx(enum pipe_format format)
> +{
> +       if (!formats[format].present)
>                 return ~0;
> -       }
> +       return formats[format].vtx;
>  }
>
> -/* convert pipe format to texture sampler format: */
>  enum a3xx_tex_fmt
>  fd3_pipe2tex(enum pipe_format format)
>  {
> -       switch (format) {
> -       case PIPE_FORMAT_L8_UNORM:
> -       case PIPE_FORMAT_A8_UNORM:
> -       case PIPE_FORMAT_I8_UNORM:
> -               return TFMT_8_UNORM;
> -
> -       case PIPE_FORMAT_R8G8_UNORM:
> -               return TFMT_8_8_UNORM;
> -
> -       case PIPE_FORMAT_B8G8R8A8_UNORM:
> -       case PIPE_FORMAT_B8G8R8X8_UNORM:
> -       case PIPE_FORMAT_R8G8B8A8_UNORM:
> -       case PIPE_FORMAT_R8G8B8X8_UNORM:
> -       case PIPE_FORMAT_B8G8R8A8_SRGB:
> -       case PIPE_FORMAT_B8G8R8X8_SRGB:
> -       case PIPE_FORMAT_R8G8B8A8_SRGB:
> -       case PIPE_FORMAT_R8G8B8X8_SRGB:
> -               return TFMT_8_8_8_8_UNORM;
> -
> -       case PIPE_FORMAT_Z24X8_UNORM:
> -       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
> -               return TFMT_X8Z24_UNORM;
> -
> -       case PIPE_FORMAT_Z16_UNORM:
> -               return TFMT_Z16_UNORM;
> -
> -       case PIPE_FORMAT_R16G16B16A16_FLOAT:
> -       case PIPE_FORMAT_R16G16B16X16_FLOAT:
> -               return TFMT_16_16_16_16_FLOAT;
> -
> -       case PIPE_FORMAT_R32G32B32A32_FLOAT:
> -       case PIPE_FORMAT_R32G32B32X32_FLOAT:
> -               return TFMT_32_32_32_32_FLOAT;
> -
> -       // TODO add more..
> -
> -       default:
> +       if (!formats[format].present)
>                 return ~0;
> -       }
> +       return formats[format].tex;
>  }
>
> -enum a3xx_tex_fetchsize
> -fd3_pipe2fetchsize(enum pipe_format format)
> -{
> -       switch (format) {
> -       case PIPE_FORMAT_L8_UNORM:
> -       case PIPE_FORMAT_A8_UNORM:
> -       case PIPE_FORMAT_I8_UNORM:
> -               return TFETCH_1_BYTE;
> -
> -       case PIPE_FORMAT_Z16_UNORM:
> -               return TFETCH_2_BYTE;
> -
> -       case PIPE_FORMAT_B8G8R8A8_UNORM:
> -       case PIPE_FORMAT_B8G8R8X8_UNORM:
> -       case PIPE_FORMAT_R8G8B8A8_UNORM:
> -       case PIPE_FORMAT_R8G8B8X8_UNORM:
> -       case PIPE_FORMAT_B8G8R8A8_SRGB:
> -       case PIPE_FORMAT_B8G8R8X8_SRGB:
> -       case PIPE_FORMAT_R8G8B8A8_SRGB:
> -       case PIPE_FORMAT_R8G8B8X8_SRGB:
> -       case PIPE_FORMAT_Z24X8_UNORM:
> -       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
> -               return TFETCH_4_BYTE;
> -
> -       // TODO add more..
> -
> -       default:
> -               return TFETCH_DISABLE;  /* safe default */
> -       }
> -}
> -
> -/* convert pipe format to MRT / copydest format used for render-target: */
>  enum a3xx_color_fmt
>  fd3_pipe2color(enum pipe_format format)
>  {
> -       switch (format) {
> -       case PIPE_FORMAT_B8G8R8A8_UNORM:
> -       case PIPE_FORMAT_B8G8R8X8_UNORM:
> -       case PIPE_FORMAT_R8G8B8A8_UNORM:
> -               return RB_R8G8B8A8_UNORM;
> -
> -       case PIPE_FORMAT_Z16_UNORM:
> -               return RB_R8G8_UNORM;
> -
> -       case PIPE_FORMAT_Z24X8_UNORM:
> -       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
> -               /* for DEPTHX_24_8, blob driver also seems to use R8G8B8A8 fmt.. */
> -               return RB_R8G8B8A8_UNORM;
> -
> -       case PIPE_FORMAT_R8_UNORM:
> -       case PIPE_FORMAT_L8_UNORM:
> -               return RB_R8_UNORM;
> -
> -       case PIPE_FORMAT_A8_UNORM:
> -               return RB_A8_UNORM;
> -
> -       case PIPE_FORMAT_R16G16B16A16_FLOAT:
> -       case PIPE_FORMAT_R16G16B16X16_FLOAT:
> -               return RB_R16G16B16A16_FLOAT;
> -
> -       case PIPE_FORMAT_R32G32B32A32_FLOAT:
> -       case PIPE_FORMAT_R32G32B32X32_FLOAT:
> -               return RB_R32G32B32A32_FLOAT;
> +       if (!formats[format].present)
> +               return ~0;
> +       /* Integer formats don't render properly yet */
> +       if (util_format_is_pure_integer(format))
> +               return ~0;
> +       return formats[format].rb;
> +}
>
> -       // TODO add more..
> +enum a3xx_color_swap
> +fd3_pipe2swap(enum pipe_format format)
> +{
> +       if (!formats[format].present)
> +               return WZYX;
> +       return formats[format].swap;
> +}
>
> -       default:
> -               return ~0;
> +enum a3xx_tex_fetchsize
> +fd3_pipe2fetchsize(enum pipe_format format)
> +{
> +       switch (util_format_get_blocksizebits(format)) {
> +       case 8: return TFETCH_1_BYTE;
> +       case 16: return TFETCH_2_BYTE;
> +       case 32: return TFETCH_4_BYTE;
> +       case 64: return TFETCH_8_BYTE;
> +       case 128: return TFETCH_16_BYTE;
> +       default: return TFETCH_DISABLE;
>         }
>  }
>
> @@ -389,37 +282,6 @@ fd3_gmem_restore_format(enum pipe_format format)
>         }
>  }
>
> -enum a3xx_color_swap
> -fd3_pipe2swap(enum pipe_format format)
> -{
> -       switch (format) {
> -       case PIPE_FORMAT_B8G8R8A8_UNORM:
> -       case PIPE_FORMAT_B8G8R8X8_UNORM:
> -       case PIPE_FORMAT_B8G8R8A8_SRGB:
> -       case PIPE_FORMAT_B8G8R8X8_SRGB:
> -               return WXYZ;
> -
> -       case PIPE_FORMAT_A8R8G8B8_UNORM:
> -       case PIPE_FORMAT_X8R8G8B8_UNORM:
> -       case PIPE_FORMAT_A8R8G8B8_SRGB:
> -       case PIPE_FORMAT_X8R8G8B8_SRGB:
> -               return ZYXW;
> -
> -       case PIPE_FORMAT_A8B8G8R8_UNORM:
> -       case PIPE_FORMAT_X8B8G8R8_UNORM:
> -       case PIPE_FORMAT_A8B8G8R8_SRGB:
> -       case PIPE_FORMAT_X8B8G8R8_SRGB:
> -               return XYZW;
> -
> -       case PIPE_FORMAT_R8G8B8A8_UNORM:
> -       case PIPE_FORMAT_R8G8B8X8_UNORM:
> -       case PIPE_FORMAT_Z24X8_UNORM:
> -       case PIPE_FORMAT_Z24_UNORM_S8_UINT:
> -       default:
> -               return WZYX;
> -       }
> -}
> -
>  static inline enum a3xx_tex_swiz
>  tex_swiz(unsigned swiz)
>  {
> --
> 2.0.4
>


More information about the Freedreno mailing list