Add support for EXT_texture_compression_bptc

After validation, the enums are simply forwarded to the native
drivers. The BPTC formats are supported on both OpenGL and D3D.

The included test coverage covers the API quite well, but only has
basic coverage for correct decoding of texture data. More coverage for
texture data could be added later.

BUG=angleproject:2869
TEST=angle_end2end_tests

Change-Id: I3de37972dcf13c6fa3fc1bc429a2627523a4a082
Reviewed-on: https://chromium-review.googlesource.com/c/1261675
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Olli Etuaho 2018-10-04 13:54:42 +03:00 коммит произвёл Commit Bot
Родитель 956ab4d9fa
Коммит f2ed299569
19 изменённых файлов: 695 добавлений и 18 удалений

Просмотреть файл

@ -4,19 +4,19 @@
"ANGLE format:src/libANGLE/renderer/angle_format_data.json":
"1ab73531d2d9655e669b5560fb43c698",
"ANGLE format:src/libANGLE/renderer/angle_format_map.json":
"ea6dfe3ebbc86e04f0d4b9f568ba22ae",
"be9f9bdbdf785dda05920146e8c55dbb",
"ANGLE format:src/libANGLE/renderer/gen_angle_format_table.py":
"9de29b6ca59a05747623c0dc32344b14",
"ANGLE load functions table:src/libANGLE/renderer/gen_load_functions_table.py":
"8afc7eecce2a3ba9f0b4beacb1aa7fe2",
"ANGLE load functions table:src/libANGLE/renderer/load_functions_data.json":
"21a603f6224d3b6cd606b71dca0ae181",
"4253e14cd3217f42b6fec75ee400655a",
"D3D11 format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
"15fb2a9b3f81e39a22090bce2f071185",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
"fde460b6823388a8f27082ec266ad64f",
"70a1798cb4e6ebabe31be5bec40c6d6f",
"D3D11 format:src/libANGLE/renderer/d3d/d3d11/texture_format_map.json":
"805d30e2443935e3a3bd68839699e171",
"DXGI format support:src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json":
@ -26,7 +26,7 @@
"DXGI format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798",
"DXGI format:src/libANGLE/renderer/angle_format_map.json":
"ea6dfe3ebbc86e04f0d4b9f568ba22ae",
"be9f9bdbdf785dda05920146e8c55dbb",
"DXGI format:src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json":
"24f525b05dc665fbbc8c6d68fb863719",
"DXGI format:src/libANGLE/renderer/d3d/d3d11/gen_dxgi_format_table.py":
@ -56,7 +56,7 @@
"GL format map:src/libANGLE/es3_format_type_combinations.json":
"a232823cd6430f14e28793ccabb968ee",
"GL format map:src/libANGLE/format_map_data.json":
"81b2775940d4ba19f874c931dfdc239e",
"779798d4879e5f73a5a108e3e3fd3095",
"GL format map:src/libANGLE/gen_format_map.py":
"a383ee79a7bf929d145165f3e76c1079",
"OpenGL dispatch table:scripts/gl.xml":
@ -66,7 +66,7 @@
"Vulkan format:src/libANGLE/renderer/angle_format.py":
"b18ca0fe4835114a4a2f54977b19e798",
"Vulkan format:src/libANGLE/renderer/angle_format_map.json":
"ea6dfe3ebbc86e04f0d4b9f568ba22ae",
"be9f9bdbdf785dda05920146e8c55dbb",
"Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"45b9efadef12298527dce8bb5da49178",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json":
@ -84,7 +84,7 @@
"Vulkan mandatory format support table:src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
"fa2bd54c1bb0ab2cf1d386061a4bc5c5",
"Vulkan mandatory format support table:third_party/vulkan-headers/src/registry/vk.xml":
"de9fb16e43de8ab4b69f673c2ca03704",
"cd73387d7cdaa5d403eab411194342b3",
"packed enum:src/common/gen_packed_gl_enums.py":
"a9b1c38b4e4d8a1038e743be323f1a51",
"packed enum:src/common/packed_egl_enums.json":

Просмотреть файл

@ -165,6 +165,7 @@ Extensions::Extensions()
textureCompressionS3TCsRGB(false),
textureCompressionASTCHDR(false),
textureCompressionASTCLDR(false),
textureCompressionBPTC(false),
compressedETC1RGB8Texture(false),
compressedETC2RGB8Texture(false),
compressedETC2sRGB8Texture(false),
@ -715,25 +716,35 @@ static bool DetermineTextureNorm16Support(const TextureCapsMap &textureCaps)
GetFormatSupport(textureCaps, requiredRenderFormats, true, false, true, true);
}
// Check for EXT_texture_compression_bptc
static bool DetermineBPTCTextureSupport(const TextureCapsMap &textureCaps)
{
constexpr GLenum requiredFormats[] = {
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT};
return GetFormatSupport(textureCaps, requiredFormats, true, true, false, false);
}
void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
{
// TODO(ynovikov): rgb8rgba8, colorBufferHalfFloat, textureHalfFloat, textureHalfFloatLinear,
// textureFloat, textureFloatLinear, textureRG, sRGB, colorBufferFloatRGB, colorBufferFloatRGBA
// and colorBufferFloat were verified. Verify the rest.
packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps);
rgb8rgba8 = DetermineRGB8AndRGBA8TextureSupport(textureCaps);
textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps);
packedDepthStencil = DeterminePackedDepthStencilSupport(textureCaps);
rgb8rgba8 = DetermineRGB8AndRGBA8TextureSupport(textureCaps);
textureFormatBGRA8888 = DetermineBGRA8TextureSupport(textureCaps);
textureHalfFloat = DetermineHalfFloatTextureSupport(textureCaps);
textureHalfFloatLinear =
textureHalfFloat && DetermineHalfFloatTextureFilteringSupport(textureCaps);
textureFloat = DetermineFloatTextureSupport(textureCaps);
textureFloatLinear = textureFloat && DetermineFloatTextureFilteringSupport(textureCaps);
textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat);
textureFloat = DetermineFloatTextureSupport(textureCaps);
textureFloatLinear = textureFloat && DetermineFloatTextureFilteringSupport(textureCaps);
textureRG = DetermineRGTextureSupport(textureCaps, textureHalfFloat, textureFloat);
colorBufferHalfFloat =
textureHalfFloat && DetermineColorBufferHalfFloatSupport(textureCaps, textureRG);
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
textureCompressionS3TCsRGB = DetermineS3TCsRGBTextureSupport(textureCaps);
textureCompressionASTCHDR = DetermineASTCTextureSupport(textureCaps);
textureCompressionASTCLDR = textureCompressionASTCHDR;
@ -757,6 +768,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
colorBufferFloatRGBA = DetermineColorBufferFloatRGBASupport(textureCaps);
colorBufferFloat = DetermineColorBufferFloatSupport(textureCaps);
textureNorm16 = DetermineTextureNorm16Support(textureCaps);
textureCompressionBPTC = DetermineBPTCTextureSupport(textureCaps);
}
const ExtensionInfoMap &GetExtensionInfoMap()
@ -809,6 +821,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["OES_compressed_EAC_R11_signed_texture"] = enableableExtension(&Extensions::compressedEACR11SignedTexture);
map["OES_compressed_EAC_RG11_unsigned_texture"] = enableableExtension(&Extensions::compressedEACRG11UnsignedTexture);
map["OES_compressed_EAC_RG11_signed_texture"] = enableableExtension(&Extensions::compressedEACRG11SignedTexture);
map["GL_EXT_texture_compression_bptc"] = enableableExtension(&Extensions::textureCompressionBPTC);
map["GL_EXT_sRGB"] = enableableExtension(&Extensions::sRGB);
map["GL_ANGLE_depth_texture"] = esOnlyExtension(&Extensions::depthTextures);
map["GL_OES_depth32"] = esOnlyExtension(&Extensions::depth32);

Просмотреть файл

@ -109,6 +109,7 @@ struct Extensions
// GL_ANGLE_depth_texture, GL_OES_depth32
// GL_EXT_color_buffer_float
// GL_EXT_texture_norm16
// GL_EXT_texture_compression_bptc
void setTextureExtensionSupport(const TextureCapsMap &textureCaps);
// ES2 Extension support
@ -182,6 +183,9 @@ struct Extensions
// GL_KHR_texture_compression_astc_ldr
bool textureCompressionASTCLDR;
// GL_EXT_texture_compression_bptc
bool textureCompressionBPTC;
// GL_OES_compressed_ETC1_RGB8_texture
// Implies that TextureCaps for GL_ETC1_RGB8_OES exist
bool compressedETC1RGB8Texture;

Просмотреть файл

@ -52,6 +52,16 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
}
break;
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGBA_BPTC_UNORM_EXT;
default:
break;
}
break;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
switch (type)
{
@ -82,6 +92,26 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
}
break;
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
default:
break;
}
break;
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
default:
break;
}
break;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
switch (type)
{
@ -92,6 +122,16 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
}
break;
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
switch (type)
{
case GL_UNSIGNED_BYTE:
return GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
default:
break;
}
break;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
switch (type)
{

Просмотреть файл

@ -127,6 +127,18 @@
"GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"
},
"GL_COMPRESSED_RGBA_BPTC_UNORM_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_BPTC_UNORM_EXT"
},
"GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT"
},
"GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT"
},
"GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT"
},
"GL_DEPTH_COMPONENT": {
"GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16",
"GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES",

Просмотреть файл

@ -894,6 +894,13 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR, 12, 10, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
AddCompressedFormat(&map, GL_COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR, 12, 12, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, AlwaysSupported, NeverSupported, NeverSupported);
// From EXT_texture_compression_bptc
// | Internal format | W | H | BS |CC| Format | Type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
AddCompressedFormat(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, 4, 4, 128, 4, GL_RGBA, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
AddCompressedFormat(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4, 4, 128, 4, GL_RGB, GL_FLOAT, false, RequireExt<&Extensions::textureCompressionBPTC>, AlwaysSupported, NeverSupported, NeverSupported);
// For STENCIL_INDEX8 we chose a normalized component type for the following reasons:
// - Multisampled buffer are disallowed for non-normalized integer component types and we want to support it for STENCIL_INDEX8
// - All other stencil formats (all depth-stencil) are either float or normalized

Просмотреть файл

@ -61,6 +61,10 @@ enum class FormatID
BC2_RGBA_UNORM_SRGB_BLOCK,
BC3_RGBA_UNORM_BLOCK,
BC3_RGBA_UNORM_SRGB_BLOCK,
BPTC_RGBA_UNORM_BLOCK,
BPTC_RGB_SIGNED_FLOAT_BLOCK,
BPTC_RGB_UNSIGNED_FLOAT_BLOCK,
BPTC_SRGB_ALPHA_UNORM_BLOCK,
D16_UNORM,
D24_UNORM_S8_UINT,
D24_UNORM_X8_UINT,
@ -187,6 +191,6 @@ enum class FormatID
S8_UINT
};
constexpr uint32_t kNumANGLEFormats = 173;
constexpr uint32_t kNumANGLEFormats = 177;
} // namespace angle

Просмотреть файл

@ -73,6 +73,10 @@ constexpr Format g_formatInfoTable[] = {
{ FormatID::BC2_RGBA_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BC3_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BC3_RGBA_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BPTC_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_FLOAT, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_FLOAT, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, nullptr, NoCopyFunctions, nullptr, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0, 0, true },
{ FormatID::D16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, nullptr, NoCopyFunctions, ReadDepthStencil<D16>, WriteDepthStencil<D16>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 16, 0, 2, false },
{ FormatID::D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, nullptr, NoCopyFunctions, ReadDepthStencil<D24S8>, WriteDepthStencil<D24S8>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 8, 4, false },
{ FormatID::D24_UNORM_X8_UINT, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, nullptr, NoCopyFunctions, ReadDepthStencil<D24>, WriteDepthStencil<D24>, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 0, 4, false },
@ -267,12 +271,18 @@ FormatID Format::InternalFormatToID(GLenum internalFormat)
return FormatID::ASTC_8x6_UNORM_BLOCK;
case GL_COMPRESSED_RGBA_ASTC_8x8_KHR:
return FormatID::ASTC_8x8_UNORM_BLOCK;
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
return FormatID::BPTC_RGBA_UNORM_BLOCK;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return FormatID::BC1_RGBA_UNORM_BLOCK;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
return FormatID::BC2_RGBA_UNORM_BLOCK;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return FormatID::BC3_RGBA_UNORM_BLOCK;
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
return FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK;
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
return FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return FormatID::BC1_RGB_UNORM_BLOCK;
case GL_COMPRESSED_SIGNED_R11_EAC:
@ -313,6 +323,8 @@ FormatID Format::InternalFormatToID(GLenum internalFormat)
return FormatID::ETC2_R8G8B8_SRGB_BLOCK;
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
return FormatID::ETC2_R8G8B8A1_SRGB_BLOCK;
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
return FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
return FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:

Просмотреть файл

@ -54,6 +54,10 @@
[ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT", "BC2_RGBA_UNORM_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT", "BC3_RGBA_UNORM_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT", "BC1_RGB_UNORM_SRGB_BLOCK" ],
[ "GL_COMPRESSED_RGBA_BPTC_UNORM_EXT", "BPTC_RGBA_UNORM_BLOCK" ],
[ "GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT", "BPTC_SRGB_ALPHA_UNORM_BLOCK" ],
[ "GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT", "BPTC_RGB_SIGNED_FLOAT_BLOCK" ],
[ "GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT", "BPTC_RGB_UNSIGNED_FLOAT_BLOCK" ],
[ "GL_DEPTH24_STENCIL8", "D24_UNORM_S8_UINT" ],
[ "GL_DEPTH32F_STENCIL8", "D32_FLOAT_S8X24_UINT" ],
[ "GL_DEPTH_COMPONENT16", "D16_UNORM" ],

Просмотреть файл

@ -171,6 +171,34 @@
"componentType": "unorm",
"swizzleFormat": "GL_RGBA8"
},
"BPTC_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC7_UNORM",
"srvFormat": "DXGI_FORMAT_BC7_UNORM",
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "GL_RGBA8"
},
"BPTC_SRGB_ALPHA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC7_UNORM_SRGB",
"srvFormat": "DXGI_FORMAT_BC7_UNORM_SRGB",
"channels": "rgba",
"componentType": "unorm",
"swizzleFormat": "GL_SRGB8_ALPHA8"
},
"BPTC_RGB_SIGNED_FLOAT_BLOCK": {
"texFormat": "DXGI_FORMAT_BC6H_SF16",
"srvFormat": "DXGI_FORMAT_BC6H_SF16",
"channels": "rgb",
"componentType": "float",
"swizzleFormat": "GL_RGBA32F"
},
"BPTC_RGB_UNSIGNED_FLOAT_BLOCK": {
"texFormat": "DXGI_FORMAT_BC6H_UF16",
"srvFormat": "DXGI_FORMAT_BC6H_UF16",
"channels": "rgb",
"componentType": "float",
"swizzleFormat": "GL_RGBA32F"
},
"D24_UNORM_S8_UINT": {
"FL10Plus": {
"texFormat": "DXGI_FORMAT_R24G8_TYPELESS",

Просмотреть файл

@ -504,6 +504,20 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
nullptr);
return info;
}
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
{
static constexpr Format info(GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
angle::FormatID::BPTC_RGBA_UNORM_BLOCK,
DXGI_FORMAT_BC7_UNORM,
DXGI_FORMAT_BC7_UNORM,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC7_UNORM,
GL_RGBA8,
nullptr);
return info;
}
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
{
static constexpr Format info(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
@ -546,6 +560,34 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
nullptr);
return info;
}
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
{
static constexpr Format info(GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT,
angle::FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK,
DXGI_FORMAT_BC6H_SF16,
DXGI_FORMAT_BC6H_SF16,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC6H_SF16,
GL_RGBA32F,
nullptr);
return info;
}
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
{
static constexpr Format info(GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT,
angle::FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK,
DXGI_FORMAT_BC6H_UF16,
DXGI_FORMAT_BC6H_UF16,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC6H_UF16,
GL_RGBA32F,
nullptr);
return info;
}
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
{
static constexpr Format info(GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
@ -854,6 +896,20 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
nullptr);
return info;
}
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
{
static constexpr Format info(GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,
angle::FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK,
DXGI_FORMAT_BC7_UNORM_SRGB,
DXGI_FORMAT_BC7_UNORM_SRGB,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_BC7_UNORM_SRGB,
GL_SRGB8_ALPHA8,
nullptr);
return info;
}
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
{
static constexpr Format info(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,

Просмотреть файл

@ -279,6 +279,13 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
InsertFormatMapping(&map, GL_LUMINANCE32F_EXT, VersionOrExts(3, 0, "GL_ARB_texture_float"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_OES_texture_float"), ExtsOnly("GL_OES_texture_float_linear"), NeverSupported(), NeverSupported() );
InsertFormatMapping(&map, GL_LUMINANCE_ALPHA32F_EXT, VersionOrExts(3, 0, "GL_ARB_texture_float"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_OES_texture_float"), ExtsOnly("GL_OES_texture_float_linear"), NeverSupported(), NeverSupported() );
// EXT_texture_compression_bptc formats
// | Format | OpenGL texture support | Filter | Render | OpenGL ES texture support | Filter | OpenGL ES texture attachment support | OpenGL ES renderbuffer support |
InsertFormatMapping(&map, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, VersionOrExts(4, 2, "GL_ARB_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), NeverSupported() );
InsertFormatMapping(&map, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, VersionOrExts(4, 2, "GL_ARB_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), NeverSupported() );
InsertFormatMapping(&map, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, VersionOrExts(4, 2, "GL_ARB_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), NeverSupported() );
InsertFormatMapping(&map, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, VersionOrExts(4, 2, "GL_ARB_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), ExtsOnly("GL_EXT_texture_compression_bptc"), AlwaysSupported(), NeverSupported(), NeverSupported() );
// Compressed formats, From ES 3.0.1 spec, table 3.16
// | Format | OpenGL texture support | Filter | Render | OpenGL ES texture support | Filter | OpenGL ES texture attachment support | OpenGL ES renderbuffer support |
InsertFormatMapping(&map, GL_COMPRESSED_R11_EAC, VersionOrExts(4, 3, "GL_ARB_ES3_compatibility"), AlwaysSupported(), NeverSupported(), VersionOrExts(3, 0, "OES_compressed_EAC_R11_unsigned_texture"), AlwaysSupported(), NeverSupported(), NeverSupported() );

Просмотреть файл

@ -613,5 +613,25 @@
"NONE": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_COMPRESSED_RGBA_BPTC_UNORM_EXT": {
"NONE": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT": {
"NONE": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT": {
"NONE": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
},
"GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT": {
"NONE": {
"GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
}
}
}

Просмотреть файл

@ -311,6 +311,18 @@ LoadImageFunctionInfo COMPRESSED_RGBA8_ETC2_EAC_to_R8G8B8A8_UNORM(GLenum type)
}
}
LoadImageFunctionInfo COMPRESSED_RGBA_BPTC_UNORM_EXT_to_default(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 16>, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo COMPRESSED_RGBA_S3TC_DXT1_EXT_to_default(GLenum type)
{
switch (type)
@ -347,6 +359,30 @@ LoadImageFunctionInfo COMPRESSED_RGBA_S3TC_DXT5_ANGLE_to_default(GLenum type)
}
}
LoadImageFunctionInfo COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT_to_default(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 16>, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT_to_default(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 16>, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo COMPRESSED_RGB_S3TC_DXT1_EXT_to_default(GLenum type)
{
switch (type)
@ -446,6 +482,18 @@ COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE_to_BC1_RGBA_UNORM_S
}
}
LoadImageFunctionInfo COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT_to_default(GLenum type)
{
switch (type)
{
case GL_UNSIGNED_BYTE:
return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 16>, true);
default:
UNREACHABLE();
return LoadImageFunctionInfo(UnreachableLoadFunction, true);
}
}
LoadImageFunctionInfo COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT_to_default(GLenum type)
{
switch (type)
@ -1740,12 +1788,18 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
}
break;
}
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
return COMPRESSED_RGBA_BPTC_UNORM_EXT_to_default;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
return COMPRESSED_RGBA_S3TC_DXT1_EXT_to_default;
case GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE:
return COMPRESSED_RGBA_S3TC_DXT3_ANGLE_to_default;
case GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE:
return COMPRESSED_RGBA_S3TC_DXT5_ANGLE_to_default;
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
return COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT_to_default;
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
return COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT_to_default;
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
return COMPRESSED_RGB_S3TC_DXT1_EXT_to_default;
case GL_COMPRESSED_SIGNED_R11_EAC:
@ -1825,6 +1879,8 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, FormatID angleFormat)
}
break;
}
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
return COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT_to_default;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
return COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT_to_default;
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:

Просмотреть файл

@ -502,6 +502,22 @@ void Format::initialize(VkPhysicalDevice physicalDevice, const angle::Format &an
// This format is not implemented in Vulkan.
break;
case angle::FormatID::BPTC_RGBA_UNORM_BLOCK:
// This format is not implemented in Vulkan.
break;
case angle::FormatID::BPTC_RGB_SIGNED_FLOAT_BLOCK:
// This format is not implemented in Vulkan.
break;
case angle::FormatID::BPTC_RGB_UNSIGNED_FLOAT_BLOCK:
// This format is not implemented in Vulkan.
break;
case angle::FormatID::BPTC_SRGB_ALPHA_UNORM_BLOCK:
// This format is not implemented in Vulkan.
break;
case angle::FormatID::D16_UNORM:
internalFormat = GL_DEPTH_COMPONENT16;
textureFormatID = angle::FormatID::D16_UNORM;

Просмотреть файл

@ -56,6 +56,10 @@ bool CompressedTextureFormatRequiresExactSize(GLenum internalFormat)
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGBA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
case GL_COMPRESSED_SRGB8_ALPHA8_LOSSY_DECODE_ETC2_EAC_ANGLE:
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
return true;
default:

Просмотреть файл

@ -576,6 +576,10 @@ bool ValidateES2CopyTexImageParameters(Context *context,
case GL_COMPRESSED_SRGB8_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_LOSSY_DECODE_ETC2_ANGLE:
case GL_COMPRESSED_RGBA_BPTC_UNORM_EXT:
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:
case GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT:
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT:
ANGLE_VALIDATION_ERR(context, InvalidOperation(), InvalidFormat);
return false;
case GL_DEPTH_COMPONENT:

Просмотреть файл

@ -10,6 +10,7 @@ angle_end2end_tests_sources = [
"gl_tests/BlendFuncExtendedTest.cpp",
"gl_tests/BlendMinMaxTest.cpp",
"gl_tests/BlitFramebufferANGLETest.cpp",
"gl_tests/BPTCCompressedTextureTest.cpp",
"gl_tests/BufferDataTest.cpp",
"gl_tests/BuiltinVariableTest.cpp",
"gl_tests/ClearTest.cpp",

Просмотреть файл

@ -0,0 +1,389 @@
//
// Copyright 2018 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// BPTCCompressedTextureTest.cpp: Tests of the GL_EXT_texture_compression_bptc extension
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
namespace
{
const unsigned int kPixelTolerance = 1u;
// The pixel data represents a 4x4 pixel image with the left side colored red and the right side
// green. It was BC7 encoded using Microsoft's BC6HBC7Encoder.
const std::array<GLubyte, 16> kBC7Data4x4 = {0x50, 0x1f, 0xfc, 0xf, 0x0, 0xf0, 0xe3, 0xe1,
0xe1, 0xe1, 0xc1, 0xf, 0xfc, 0xc0, 0xf, 0xfc};
}; // anonymous namespace
class BPTCCompressedTextureTest : public ANGLETest
{
protected:
BPTCCompressedTextureTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
void SetUp() override
{
ANGLETest::SetUp();
const std::string vsSource =
R"(precision highp float;
attribute vec4 position;
varying vec2 texcoord;
void main()
{
gl_Position = position;
texcoord = (position.xy * 0.5) + 0.5;
texcoord.y = 1.0 - texcoord.y;
})";
const std::string textureFSSource =
R"(precision highp float;
uniform sampler2D tex;
varying vec2 texcoord;
void main()
{
gl_FragColor = texture2D(tex, texcoord);
})";
mTextureProgram = CompileProgram(vsSource, textureFSSource);
if (mTextureProgram == 0)
{
FAIL() << "shader compilation failed.";
}
mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex");
ASSERT_GL_NO_ERROR();
}
void TearDown() override
{
glDeleteProgram(mTextureProgram);
ANGLETest::TearDown();
}
void setupTextureParameters(GLuint texture)
{
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
void drawTexture()
{
glUseProgram(mTextureProgram);
glUniform1i(mTextureUniformLocation, 0);
drawQuad(mTextureProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
}
GLuint mTextureProgram;
GLint mTextureUniformLocation;
};
class BPTCCompressedTextureTestES3 : public BPTCCompressedTextureTest
{
public:
BPTCCompressedTextureTestES3() : BPTCCompressedTextureTest() {}
};
// Test sampling from a BC7 non-SRGB image.
TEST_P(BPTCCompressedTextureTest, CompressedTexImageBC7)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 0,
kBC7Data4x4.size(), kBC7Data4x4.data());
EXPECT_GL_NO_ERROR();
drawTexture();
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, getWindowHeight() - 1, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green,
kPixelTolerance);
}
// Test sampling from a BC7 SRGB image.
TEST_P(BPTCCompressedTextureTest, CompressedTexImageBC7SRGB)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT, 4, 4, 0,
kBC7Data4x4.size(), kBC7Data4x4.data());
EXPECT_GL_NO_ERROR();
drawTexture();
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, getWindowHeight() - 1, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green,
kPixelTolerance);
}
// Test that using the BC6H floating point formats doesn't crash.
TEST_P(BPTCCompressedTextureTest, CompressedTexImageBC6HNoCrash)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
// This dummy pixel data represents a 4x4 pixel image.
// TODO(http://anglebug.com/2869): Add pixel tests for these formats. These need HDR source
// images.
std::vector<GLubyte> data;
data.resize(16u, 0u);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT, 4, 4, 0,
data.size(), data.data());
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT, 4, 4, 0,
data.size(), data.data());
EXPECT_GL_NO_ERROR();
drawTexture();
}
// Test texStorage2D with a BPTC format.
TEST_P(BPTCCompressedTextureTestES3, CompressedTexStorage)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
GLTexture texture;
setupTextureParameters(texture);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4);
EXPECT_GL_NO_ERROR();
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), kBC7Data4x4.data());
EXPECT_GL_NO_ERROR();
drawTexture();
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, getWindowHeight() - 1, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green,
kPixelTolerance);
}
// Test validation of glCompressedTexSubImage2D with BPTC formats
TEST_P(BPTCCompressedTextureTest, CompressedTexSubImageValidation)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture);
std::vector<GLubyte> data(16 * 2 * 2); // 2x2 blocks, thats 8x8 pixels.
// Size mip 0 to a large size.
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 8, 8, 0,
data.size(), data.data());
ASSERT_GL_NO_ERROR();
// Test a sub image with an offset that isn't a multiple of the block size.
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 1, 0, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 3, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
// Test a sub image with a negative offset.
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, -1, 0, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_VALUE);
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, -1, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_VALUE);
}
// Test that copying BPTC textures is not allowed. This restriction exists only in
// EXT_texture_compression_bptc, and not in the ARB variant.
TEST_P(BPTCCompressedTextureTest, CopyTexImage2DDisallowed)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 0, 0, 4, 4, 0);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test that copying BPTC textures is not allowed. This restriction exists only in
// EXT_texture_compression_bptc, and not in the ARB variant.
TEST_P(BPTCCompressedTextureTest, CopyTexSubImage2DDisallowed)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 0,
kBC7Data4x4.size(), kBC7Data4x4.data());
ASSERT_GL_NO_ERROR();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 4, 4);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test that copying BPTC textures is not allowed. This restriction exists only in
// EXT_texture_compression_bptc, and not in the ARB variant.
TEST_P(BPTCCompressedTextureTestES3, CopyTexSubImage3DDisallowed)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
glBindTexture(GL_TEXTURE_2D_ARRAY, texture);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 1);
ASSERT_GL_NO_ERROR();
glCopyTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 0, 0, 4, 4);
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
}
// Test uploading texture data from a PBO to a texture.
TEST_P(BPTCCompressedTextureTestES3, PBOCompressedTexImage)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
GLBuffer buffer;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, kBC7Data4x4.size(), kBC7Data4x4.data(), GL_STREAM_DRAW);
ASSERT_GL_NO_ERROR();
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4, 0,
kBC7Data4x4.size(), nullptr);
ASSERT_GL_NO_ERROR();
drawTexture();
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, getWindowHeight() - 1, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green,
kPixelTolerance);
}
// Test uploading texture data from a PBO to a texture allocated with texStorage2D.
TEST_P(BPTCCompressedTextureTestES3, PBOCompressedTexStorage)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
setupTextureParameters(texture);
glTexStorage2D(GL_TEXTURE_2D, 1, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 4, 4);
ASSERT_GL_NO_ERROR();
GLBuffer buffer;
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, buffer);
glBufferData(GL_PIXEL_UNPACK_BUFFER, kBC7Data4x4.size(), kBC7Data4x4.data(), GL_STREAM_DRAW);
ASSERT_GL_NO_ERROR();
glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT,
kBC7Data4x4.size(), nullptr);
ASSERT_GL_NO_ERROR();
drawTexture();
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(0, getWindowHeight() - 1, GLColor::red, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, 0, GLColor::green, kPixelTolerance);
EXPECT_PIXEL_COLOR_NEAR(getWindowWidth() - 1, getWindowHeight() - 1, GLColor::green,
kPixelTolerance);
}
// Test validation of glCompressedTexSubImage3D with BPTC formats
TEST_P(BPTCCompressedTextureTestES3, CompressedTexSubImage3DValidation)
{
ANGLE_SKIP_TEST_IF(!extensionEnabled("GL_EXT_texture_compression_bptc"));
GLTexture texture;
glBindTexture(GL_TEXTURE_2D_ARRAY, texture.get());
std::vector<GLubyte> data(16 * 2 * 2); // 2x2x1 blocks, thats 8x8x1 pixels.
// Size mip 0 to a large size.
glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, 8, 8, 1, 0,
data.size(), data.data());
ASSERT_GL_NO_ERROR();
// Test a sub image with an offset that isn't a multiple of the block size.
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 2, 0, 0, 4, 4, 1,
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, kBC7Data4x4.size(),
kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 2, 0, 4, 4, 1,
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, kBC7Data4x4.size(),
kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_OPERATION);
// Test a sub image with a negative offset.
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, -1, 0, 0, 4, 4, 1,
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, kBC7Data4x4.size(),
kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_VALUE);
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, -1, 0, 4, 4, 1,
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, kBC7Data4x4.size(),
kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_VALUE);
glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, -1, 4, 4, 1,
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, kBC7Data4x4.size(),
kBC7Data4x4.data());
ASSERT_GL_ERROR(GL_INVALID_VALUE);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(BPTCCompressedTextureTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES(),
ES2_VULKAN());
ANGLE_INSTANTIATE_TEST(BPTCCompressedTextureTestES3, ES3_D3D11(), ES3_OPENGL(), ES3_OPENGLES());