Commit 6b21d3c9 authored by Ilia Mirkin's avatar Ilia Mirkin

st/mesa: add astc support

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's avatarIlia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: default avatarMarek Olšák <marek.olsak@amd.com>
Reviewed-by: default avatarRoland Scheidegger <sroland@vmware.com>
parent 33339775
......@@ -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 } },
......
......@@ -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.
*/
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment