[Mesa-dev] [PATCH 3/3] st/mesa: add astc support

Marek Olšák maraeo at gmail.com
Sat Nov 21 14:35:20 PST 2015


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Sat, Nov 21, 2015 at 9:03 PM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> This doesn't account for the ldr/hdr distinction... that will probably
> have to be exposed via a separate cap. When relevant hardware appears,
> this can be worked out.
>
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>  src/mesa/state_tracker/st_extensions.c |  32 ++++-
>  src/mesa/state_tracker/st_format.c     | 231 +++++++++++++++++++++++++++++++++
>  2 files changed, 262 insertions(+), 1 deletion(-)
>
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 99e96e1..a2418e2 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -343,7 +343,7 @@ struct st_extension_cap_mapping {
>
>  struct st_extension_format_mapping {
>     int extension_offset[2];
> -   enum pipe_format format[8];
> +   enum pipe_format format[32];
>
>     /* If TRUE, at least one format must be supported for the extensions to be
>      * advertised. If FALSE, all the formats must be supported. */
> @@ -569,6 +569,36 @@ void st_init_extensions(struct pipe_screen *screen,
>            PIPE_FORMAT_BPTC_RGB_FLOAT,
>            PIPE_FORMAT_BPTC_RGB_UFLOAT } },
>
> +      { { o(KHR_texture_compression_astc_ldr) },
> +        { PIPE_FORMAT_ASTC_4x4,
> +          PIPE_FORMAT_ASTC_5x4,
> +          PIPE_FORMAT_ASTC_5x5,
> +          PIPE_FORMAT_ASTC_6x5,
> +          PIPE_FORMAT_ASTC_6x6,
> +          PIPE_FORMAT_ASTC_8x5,
> +          PIPE_FORMAT_ASTC_8x6,
> +          PIPE_FORMAT_ASTC_8x8,
> +          PIPE_FORMAT_ASTC_10x5,
> +          PIPE_FORMAT_ASTC_10x6,
> +          PIPE_FORMAT_ASTC_10x8,
> +          PIPE_FORMAT_ASTC_10x10,
> +          PIPE_FORMAT_ASTC_12x10,
> +          PIPE_FORMAT_ASTC_12x12,
> +          PIPE_FORMAT_ASTC_4x4_SRGB,
> +          PIPE_FORMAT_ASTC_5x4_SRGB,
> +          PIPE_FORMAT_ASTC_5x5_SRGB,
> +          PIPE_FORMAT_ASTC_6x5_SRGB,
> +          PIPE_FORMAT_ASTC_6x6_SRGB,
> +          PIPE_FORMAT_ASTC_8x5_SRGB,
> +          PIPE_FORMAT_ASTC_8x6_SRGB,
> +          PIPE_FORMAT_ASTC_8x8_SRGB,
> +          PIPE_FORMAT_ASTC_10x5_SRGB,
> +          PIPE_FORMAT_ASTC_10x6_SRGB,
> +          PIPE_FORMAT_ASTC_10x8_SRGB,
> +          PIPE_FORMAT_ASTC_10x10_SRGB,
> +          PIPE_FORMAT_ASTC_12x10_SRGB,
> +          PIPE_FORMAT_ASTC_12x12_SRGB } },
> +
>        { { o(EXT_texture_shared_exponent) },
>          { PIPE_FORMAT_R9G9B9E5_FLOAT } },
>
> diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
> index 144b7d6..2b92bad 100644
> --- a/src/mesa/state_tracker/st_format.c
> +++ b/src/mesa/state_tracker/st_format.c
> @@ -465,6 +465,64 @@ st_mesa_format_to_pipe_format(struct st_context *st, mesa_format mesaFormat)
>     case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1:
>        return st->has_etc2 ? PIPE_FORMAT_ETC2_SRGB8A1 : PIPE_FORMAT_B8G8R8A8_SRGB;
>
> +   case MESA_FORMAT_RGBA_ASTC_4x4:
> +      return PIPE_FORMAT_ASTC_4x4;
> +   case MESA_FORMAT_RGBA_ASTC_5x4:
> +      return PIPE_FORMAT_ASTC_5x4;
> +   case MESA_FORMAT_RGBA_ASTC_5x5:
> +      return PIPE_FORMAT_ASTC_5x5;
> +   case MESA_FORMAT_RGBA_ASTC_6x5:
> +      return PIPE_FORMAT_ASTC_6x5;
> +   case MESA_FORMAT_RGBA_ASTC_6x6:
> +      return PIPE_FORMAT_ASTC_6x6;
> +   case MESA_FORMAT_RGBA_ASTC_8x5:
> +      return PIPE_FORMAT_ASTC_8x5;
> +   case MESA_FORMAT_RGBA_ASTC_8x6:
> +      return PIPE_FORMAT_ASTC_8x6;
> +   case MESA_FORMAT_RGBA_ASTC_8x8:
> +      return PIPE_FORMAT_ASTC_8x8;
> +   case MESA_FORMAT_RGBA_ASTC_10x5:
> +      return PIPE_FORMAT_ASTC_10x5;
> +   case MESA_FORMAT_RGBA_ASTC_10x6:
> +      return PIPE_FORMAT_ASTC_10x6;
> +   case MESA_FORMAT_RGBA_ASTC_10x8:
> +      return PIPE_FORMAT_ASTC_10x8;
> +   case MESA_FORMAT_RGBA_ASTC_10x10:
> +      return PIPE_FORMAT_ASTC_10x10;
> +   case MESA_FORMAT_RGBA_ASTC_12x10:
> +      return PIPE_FORMAT_ASTC_12x10;
> +   case MESA_FORMAT_RGBA_ASTC_12x12:
> +      return PIPE_FORMAT_ASTC_12x12;
> +
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4:
> +      return PIPE_FORMAT_ASTC_4x4_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4:
> +      return PIPE_FORMAT_ASTC_5x4_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5:
> +      return PIPE_FORMAT_ASTC_5x5_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5:
> +      return PIPE_FORMAT_ASTC_6x5_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6:
> +      return PIPE_FORMAT_ASTC_6x6_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5:
> +      return PIPE_FORMAT_ASTC_8x5_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6:
> +      return PIPE_FORMAT_ASTC_8x6_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8:
> +      return PIPE_FORMAT_ASTC_8x8_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5:
> +      return PIPE_FORMAT_ASTC_10x5_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6:
> +      return PIPE_FORMAT_ASTC_10x6_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8:
> +      return PIPE_FORMAT_ASTC_10x8_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10:
> +      return PIPE_FORMAT_ASTC_10x10_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10:
> +      return PIPE_FORMAT_ASTC_12x10_SRGB;
> +   case MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12:
> +      return PIPE_FORMAT_ASTC_12x12_SRGB;
> +
>     default:
>        return PIPE_FORMAT_NONE;
>     }
> @@ -883,6 +941,64 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
>     case PIPE_FORMAT_ETC2_RG11_SNORM:
>        return MESA_FORMAT_ETC2_SIGNED_RG11_EAC;
>
> +   case PIPE_FORMAT_ASTC_4x4:
> +      return MESA_FORMAT_RGBA_ASTC_4x4;
> +   case PIPE_FORMAT_ASTC_5x4:
> +      return MESA_FORMAT_RGBA_ASTC_5x4;
> +   case PIPE_FORMAT_ASTC_5x5:
> +      return MESA_FORMAT_RGBA_ASTC_5x5;
> +   case PIPE_FORMAT_ASTC_6x5:
> +      return MESA_FORMAT_RGBA_ASTC_6x5;
> +   case PIPE_FORMAT_ASTC_6x6:
> +      return MESA_FORMAT_RGBA_ASTC_6x6;
> +   case PIPE_FORMAT_ASTC_8x5:
> +      return MESA_FORMAT_RGBA_ASTC_8x5;
> +   case PIPE_FORMAT_ASTC_8x6:
> +      return MESA_FORMAT_RGBA_ASTC_8x6;
> +   case PIPE_FORMAT_ASTC_8x8:
> +      return MESA_FORMAT_RGBA_ASTC_8x8;
> +   case PIPE_FORMAT_ASTC_10x5:
> +      return MESA_FORMAT_RGBA_ASTC_10x5;
> +   case PIPE_FORMAT_ASTC_10x6:
> +      return MESA_FORMAT_RGBA_ASTC_10x6;
> +   case PIPE_FORMAT_ASTC_10x8:
> +      return MESA_FORMAT_RGBA_ASTC_10x8;
> +   case PIPE_FORMAT_ASTC_10x10:
> +      return MESA_FORMAT_RGBA_ASTC_10x10;
> +   case PIPE_FORMAT_ASTC_12x10:
> +      return MESA_FORMAT_RGBA_ASTC_12x10;
> +   case PIPE_FORMAT_ASTC_12x12:
> +      return MESA_FORMAT_RGBA_ASTC_12x12;
> +
> +   case PIPE_FORMAT_ASTC_4x4_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4;
> +   case PIPE_FORMAT_ASTC_5x4_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4;
> +   case PIPE_FORMAT_ASTC_5x5_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5;
> +   case PIPE_FORMAT_ASTC_6x5_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5;
> +   case PIPE_FORMAT_ASTC_6x6_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6;
> +   case PIPE_FORMAT_ASTC_8x5_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5;
> +   case PIPE_FORMAT_ASTC_8x6_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6;
> +   case PIPE_FORMAT_ASTC_8x8_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8;
> +   case PIPE_FORMAT_ASTC_10x5_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5;
> +   case PIPE_FORMAT_ASTC_10x6_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6;
> +   case PIPE_FORMAT_ASTC_10x8_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8;
> +   case PIPE_FORMAT_ASTC_10x10_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10;
> +   case PIPE_FORMAT_ASTC_12x10_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10;
> +   case PIPE_FORMAT_ASTC_12x12_SRGB:
> +      return MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12;
> +
>     default:
>        return MESA_FORMAT_NONE;
>     }
> @@ -1386,6 +1502,121 @@ static const struct format_mapping format_map[] = {
>        { PIPE_FORMAT_BPTC_RGB_UFLOAT, 0 },
>     },
>
> +   /* ASTC */
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_4x4_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_4x4, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_5x4_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_5x4, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_5x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_5x5, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_6x5, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_6x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_6x6, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_8x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x5, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_8x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x6, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_8x8_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x8, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_10x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x5, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_10x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x6, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_10x8_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x8, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_10x10_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x10, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_12x10_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_12x10, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_RGBA_ASTC_12x12_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_12x12, 0},
> +   },
> +
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_4x4_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_5x4_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_5x5_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_6x5_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_6x6_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x5_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x6_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_8x8_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x5_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x6_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x8_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_10x10_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_12x10_SRGB, 0},
> +   },
> +   {
> +      { GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 0 },
> +      { PIPE_FORMAT_ASTC_12x12_SRGB, 0},
> +   },
> +
>     /* signed/unsigned integer formats.
>      */
>     {
> --
> 2.4.10
>
> _______________________________________________
> 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