formats:add astc 2d compressed format support

astc compressed texture is missing in virgl, add support.

Signed-off-by: cheyang <cheyang@bytedance.com>
Signed-off-by: hexin   <hexin.op@bytedance.com>
Reviewed-by: Gert Wollny <gert.wollny@collabora.com>
macos/master
cheyang 4 years ago
parent acf0fe9d99
commit 51d4d37c29
  1. 30
      src/gallium/auxiliary/util/u_format.csv
  2. 14
      src/gallium/auxiliary/util/u_format.h
  3. 29
      src/virgl_hw.h
  4. 84
      src/vrend_formats.c

@ -409,3 +409,33 @@ PIPE_FORMAT_ETC2_R11_UNORM , etc, 4, 4, x64, , , , x001, rgb
PIPE_FORMAT_ETC2_R11_SNORM , etc, 4, 4, x64, , , , x001, rgb
PIPE_FORMAT_ETC2_RG11_UNORM , etc, 4, 4, x128, , , , xy01, rgb
PIPE_FORMAT_ETC2_RG11_SNORM , etc, 4, 4, x128, , , , xy01, rgb
PIPE_FORMAT_ASTC_4x4 , astc, 4, 4, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_5x4 , astc, 5, 4, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_5x5 , astc, 5, 5, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_6x5 , astc, 6, 5, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_6x6 , astc, 6, 6, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_8x5 , astc, 8, 5, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_8x6 , astc, 8, 6, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_8x8 , astc, 8, 8, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_10x5 , astc,10, 5, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_10x6 , astc,10, 6, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_10x8 , astc,10, 8, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_10x10 , astc,10,10, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_12x10 , astc,12,10, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_12x12 , astc,12,12, x128, , , , xyzw, rgb
PIPE_FORMAT_ASTC_4x4_SRGB , astc, 4, 4, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_5x4_SRGB , astc, 5, 4, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_5x5_SRGB , astc, 5, 5, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_6x5_SRGB , astc, 6, 5, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_6x6_SRGB , astc, 6, 6, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_8x5_SRGB , astc, 8, 5, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_8x6_SRGB , astc, 8, 6, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_8x8_SRGB , astc, 8, 8, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_10x5_SRGB , astc,10, 5, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_10x6_SRGB , astc,10, 6, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_10x8_SRGB , astc,10, 8, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_10x10_SRGB , astc,10,10, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_12x10_SRGB , astc,12,10, x128, , , , xyzw, srgb
PIPE_FORMAT_ASTC_12x12_SRGB , astc,12,12, x128, , , , xyzw, srgb
Can't render this file because it contains an unexpected character in line 8 and column 3.

@ -83,10 +83,19 @@ enum util_format_layout {
*/
UTIL_FORMAT_LAYOUT_BPTC = 7,
UTIL_FORMAT_LAYOUT_ASTC = 8,
UTIL_FORMAT_LAYOUT_ATC = 9,
/** Formats with 2 or more planes. */
UTIL_FORMAT_LAYOUT_PLANAR2 = 10,
UTIL_FORMAT_LAYOUT_PLANAR3 = 11,
UTIL_FORMAT_LAYOUT_FXT1 = 12,
/**
* Everything else that doesn't fit in any of the above layouts.
*/
UTIL_FORMAT_LAYOUT_OTHER = 8
UTIL_FORMAT_LAYOUT_OTHER = 13,
};
@ -299,6 +308,9 @@ util_format_is_compressed(enum pipe_format format)
case UTIL_FORMAT_LAYOUT_RGTC:
case UTIL_FORMAT_LAYOUT_ETC:
case UTIL_FORMAT_LAYOUT_BPTC:
case UTIL_FORMAT_LAYOUT_ASTC:
case UTIL_FORMAT_LAYOUT_ATC:
case UTIL_FORMAT_LAYOUT_FXT1:
/* XXX add other formats in the future */
return TRUE;
default:

@ -358,6 +358,35 @@ enum virgl_formats {
VIRGL_FORMAT_ETC2_RG11_UNORM = 277,
VIRGL_FORMAT_ETC2_RG11_SNORM = 278,
VIRGL_FORMAT_ASTC_4x4 = 279,
VIRGL_FORMAT_ASTC_5x4 = 280,
VIRGL_FORMAT_ASTC_5x5 = 281,
VIRGL_FORMAT_ASTC_6x5 = 282,
VIRGL_FORMAT_ASTC_6x6 = 283,
VIRGL_FORMAT_ASTC_8x5 = 284,
VIRGL_FORMAT_ASTC_8x6 = 285,
VIRGL_FORMAT_ASTC_8x8 = 286,
VIRGL_FORMAT_ASTC_10x5 = 287,
VIRGL_FORMAT_ASTC_10x6 = 288,
VIRGL_FORMAT_ASTC_10x8 = 289,
VIRGL_FORMAT_ASTC_10x10 = 290,
VIRGL_FORMAT_ASTC_12x10 = 291,
VIRGL_FORMAT_ASTC_12x12 = 292,
VIRGL_FORMAT_ASTC_4x4_SRGB = 293,
VIRGL_FORMAT_ASTC_5x4_SRGB = 294,
VIRGL_FORMAT_ASTC_5x5_SRGB = 295,
VIRGL_FORMAT_ASTC_6x5_SRGB = 296,
VIRGL_FORMAT_ASTC_6x6_SRGB = 297,
VIRGL_FORMAT_ASTC_8x5_SRGB = 298,
VIRGL_FORMAT_ASTC_8x6_SRGB = 299,
VIRGL_FORMAT_ASTC_8x8_SRGB = 300,
VIRGL_FORMAT_ASTC_10x5_SRGB = 301,
VIRGL_FORMAT_ASTC_10x6_SRGB = 302,
VIRGL_FORMAT_ASTC_10x8_SRGB = 303,
VIRGL_FORMAT_ASTC_10x10_SRGB = 304,
VIRGL_FORMAT_ASTC_12x10_SRGB = 305,
VIRGL_FORMAT_ASTC_12x12_SRGB = 306,
VIRGL_FORMAT_R10G10B10X2_UNORM = 308,
VIRGL_FORMAT_A4B4G4R4_UNORM = 311,

@ -246,6 +246,36 @@ static struct vrend_format_table etc2_formats[] = {
{VIRGL_FORMAT_ETC2_RG11_UNORM, GL_COMPRESSED_RG11_EAC, GL_RG, GL_UNSIGNED_BYTE, NO_SWIZZLE},
{VIRGL_FORMAT_ETC2_RG11_SNORM, GL_COMPRESSED_SIGNED_RG11_EAC, GL_RG, GL_BYTE, NO_SWIZZLE},
};
static struct vrend_format_table astc_formats[] = {
{VIRGL_FORMAT_ASTC_4x4, GL_COMPRESSED_RGBA_ASTC_4x4, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_5x4, GL_COMPRESSED_RGBA_ASTC_5x4, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_5x5, GL_COMPRESSED_RGBA_ASTC_5x5, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_6x5, GL_COMPRESSED_RGBA_ASTC_6x5, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_6x6, GL_COMPRESSED_RGBA_ASTC_6x6, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x5, GL_COMPRESSED_RGBA_ASTC_8x5, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x6, GL_COMPRESSED_RGBA_ASTC_8x6, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x8, GL_COMPRESSED_RGBA_ASTC_8x8, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x5, GL_COMPRESSED_RGBA_ASTC_10x5, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x6, GL_COMPRESSED_RGBA_ASTC_10x6, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x8, GL_COMPRESSED_RGBA_ASTC_10x8, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x10, GL_COMPRESSED_RGBA_ASTC_10x10, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_12x10, GL_COMPRESSED_RGBA_ASTC_12x10, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_12x12, GL_COMPRESSED_RGBA_ASTC_12x12, GL_RGBA, GL_UNSIGNED_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_4x4_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_5x4_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x4, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_5x5_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_5x5, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_6x5_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x5, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_6x6_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_6x6, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x5_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x5, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x6_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x6, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_8x8_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_8x8, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x5_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x5, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x6_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x6, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x8_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x8, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_10x10_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_10x10, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_12x10_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10, GL_RGBA, GL_BYTE, NO_SWIZZLE },
{VIRGL_FORMAT_ASTC_12x12_SRGB, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12, GL_RGBA, GL_BYTE, NO_SWIZZLE },
};
static struct vrend_format_table rgtc_formats[] = {
{ VIRGL_FORMAT_RGTC1_UNORM, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE, NO_SWIZZLE },
@ -433,6 +463,10 @@ static void vrend_add_formats(struct vrend_format_table *table, int num_entries)
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue;
case UTIL_FORMAT_LAYOUT_ASTC:
if(epoxy_has_gl_extension("GL_KHR_texture_compression_astc_ldr"))
vrend_insert_format(&table[i], VIRGL_BIND_SAMPLER_VIEW, flags);
continue;
default:
;/* do logic below */
}
@ -552,6 +586,7 @@ void vrend_build_format_list_common(void)
/* compressed */
add_formats(etc2_formats);
add_formats(astc_formats);
add_formats(rgtc_formats);
add_formats(dxtn_formats);
add_formats(dxtn_srgb_formats);
@ -712,6 +747,7 @@ unsigned vrend_renderer_query_multisample_caps(unsigned max_samples, struct virg
static int format_uncompressed_compressed_copy_compatible(enum virgl_formats src,
enum virgl_formats dst)
{
switch (src) {
case VIRGL_FORMAT_R32G32B32A32_UINT:
case VIRGL_FORMAT_R32G32B32A32_SINT:
@ -734,6 +770,34 @@ static int format_uncompressed_compressed_copy_compatible(enum virgl_formats src
case VIRGL_FORMAT_ETC2_RG11_UNORM:
case VIRGL_FORMAT_ETC2_RG11_SNORM:
return 1;
case VIRGL_FORMAT_ASTC_4x4:
case VIRGL_FORMAT_ASTC_5x4:
case VIRGL_FORMAT_ASTC_5x5:
case VIRGL_FORMAT_ASTC_6x5:
case VIRGL_FORMAT_ASTC_6x6:
case VIRGL_FORMAT_ASTC_8x5:
case VIRGL_FORMAT_ASTC_8x6:
case VIRGL_FORMAT_ASTC_8x8:
case VIRGL_FORMAT_ASTC_10x5:
case VIRGL_FORMAT_ASTC_10x6:
case VIRGL_FORMAT_ASTC_10x8:
case VIRGL_FORMAT_ASTC_10x10:
case VIRGL_FORMAT_ASTC_12x10:
case VIRGL_FORMAT_ASTC_12x12:
case VIRGL_FORMAT_ASTC_4x4_SRGB:
case VIRGL_FORMAT_ASTC_5x5_SRGB:
case VIRGL_FORMAT_ASTC_6x5_SRGB:
case VIRGL_FORMAT_ASTC_6x6_SRGB:
case VIRGL_FORMAT_ASTC_8x5_SRGB:
case VIRGL_FORMAT_ASTC_8x6_SRGB:
case VIRGL_FORMAT_ASTC_8x8_SRGB:
case VIRGL_FORMAT_ASTC_10x5_SRGB:
case VIRGL_FORMAT_ASTC_10x6_SRGB:
case VIRGL_FORMAT_ASTC_10x8_SRGB:
case VIRGL_FORMAT_ASTC_10x10_SRGB:
case VIRGL_FORMAT_ASTC_12x10_SRGB:
case VIRGL_FORMAT_ASTC_12x12_SRGB:
return epoxy_is_desktop_gl() ? -1 : 1;
default:
return -1;
}
@ -771,6 +835,26 @@ static int format_uncompressed_compressed_copy_compatible(enum virgl_formats src
static boolean format_compressed_compressed_copy_compatible(enum virgl_formats src, enum virgl_formats dst)
{
const bool is_desktop_gl = epoxy_is_desktop_gl();
if(!is_desktop_gl) {
if((src == VIRGL_FORMAT_ASTC_4x4 && dst == VIRGL_FORMAT_ASTC_4x4_SRGB) ||
(src == VIRGL_FORMAT_ASTC_5x4 && dst == VIRGL_FORMAT_ASTC_5x4_SRGB) ||
(src == VIRGL_FORMAT_ASTC_5x5 && dst == VIRGL_FORMAT_ASTC_5x5_SRGB) ||
(src == VIRGL_FORMAT_ASTC_6x5 && dst == VIRGL_FORMAT_ASTC_6x5_SRGB) ||
(src == VIRGL_FORMAT_ASTC_6x6 && dst == VIRGL_FORMAT_ASTC_6x6_SRGB) ||
(src == VIRGL_FORMAT_ASTC_8x5 && dst == VIRGL_FORMAT_ASTC_8x5_SRGB) ||
(src == VIRGL_FORMAT_ASTC_8x6 && dst == VIRGL_FORMAT_ASTC_8x6_SRGB) ||
(src == VIRGL_FORMAT_ASTC_8x8 && dst == VIRGL_FORMAT_ASTC_8x8_SRGB) ||
(src == VIRGL_FORMAT_ASTC_10x5 && dst == VIRGL_FORMAT_ASTC_10x5_SRGB) ||
(src == VIRGL_FORMAT_ASTC_10x6 && dst == VIRGL_FORMAT_ASTC_10x5_SRGB) ||
(src == VIRGL_FORMAT_ASTC_10x8 && dst == VIRGL_FORMAT_ASTC_10x8_SRGB) ||
(src == VIRGL_FORMAT_ASTC_10x10 && dst == VIRGL_FORMAT_ASTC_10x10_SRGB) ||
(src == VIRGL_FORMAT_ASTC_12x10 && dst == VIRGL_FORMAT_ASTC_12x10_SRGB) ||
(src == VIRGL_FORMAT_ASTC_12x12 && dst == VIRGL_FORMAT_ASTC_12x12_SRGB))
return true;
}
if ((src == VIRGL_FORMAT_RGTC1_UNORM && dst == VIRGL_FORMAT_RGTC1_SNORM) ||
(src == VIRGL_FORMAT_RGTC2_UNORM && dst == VIRGL_FORMAT_RGTC2_SNORM) ||
(src == VIRGL_FORMAT_BPTC_RGBA_UNORM && dst == VIRGL_FORMAT_BPTC_SRGBA) ||

Loading…
Cancel
Save