Support EXT_texture_compression_s3tc_srgb on DX11
Also passes WEBGL_compressed_texture_s3tc_srgb conformance on WebGL 1/2 on DX11
BUG=angleproject:1553
BUG=chromium:630498
Change-Id: If1d17b54b1e8b998410079fd217626410015d7f1
Reviewed-on: https://chromium-review.googlesource.com/422585
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Caps.cpp b/src/libANGLE/Caps.cpp
index a2a10ff..19d7d48 100644
--- a/src/libANGLE/Caps.cpp
+++ b/src/libANGLE/Caps.cpp
@@ -149,6 +149,7 @@
textureCompressionDXT1(false),
textureCompressionDXT3(false),
textureCompressionDXT5(false),
+ textureCompressionS3TCsRGB(false),
textureCompressionASTCHDR(false),
textureCompressionASTCLDR(false),
compressedETC1RGB8Texture(false),
@@ -395,6 +396,18 @@
return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
}
+// Check for GL_EXT_texture_compression_s3tc_srgb
+static bool DetermineS3TCsRGBTextureSupport(const TextureCapsMap &textureCaps)
+{
+ std::vector<GLenum> requiredFormats;
+ requiredFormats.push_back(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
+ requiredFormats.push_back(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
+ requiredFormats.push_back(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
+ requiredFormats.push_back(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
+
+ return GetFormatSupport(textureCaps, requiredFormats, true, true, false);
+}
+
// Check for GL_KHR_texture_compression_astc_hdr and GL_KHR_texture_compression_astc_ldr
static bool DetermineASTCTextureSupport(const TextureCapsMap &textureCaps)
{
@@ -525,6 +538,7 @@
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
+ textureCompressionS3TCsRGB = DetermineS3TCsRGBTextureSupport(textureCaps);
textureCompressionASTCHDR = DetermineASTCTextureSupport(textureCaps);
textureCompressionASTCLDR = textureCompressionASTCHDR;
compressedETC1RGB8Texture = DetermineETC1RGB8TextureSupport(textureCaps);
@@ -571,6 +585,7 @@
map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1);
map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3);
map["GL_ANGLE_texture_compression_dxt5"] = esOnlyExtension(&Extensions::textureCompressionDXT5);
+ map["GL_EXT_texture_compression_s3tc_srgb"] = esOnlyExtension(&Extensions::textureCompressionS3TCsRGB);
map["GL_KHR_texture_compression_astc_hdr"] = esOnlyExtension(&Extensions::textureCompressionASTCHDR);
map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR);
map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture);
diff --git a/src/libANGLE/Caps.h b/src/libANGLE/Caps.h
index 1b22a4c..12b4874 100644
--- a/src/libANGLE/Caps.h
+++ b/src/libANGLE/Caps.h
@@ -160,6 +160,12 @@
bool textureCompressionDXT3;
bool textureCompressionDXT5;
+ // GL_EXT_texture_compression_s3tc_srgb
+ // Implies that TextureCaps for GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
+ // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, and
+ // GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
+ bool textureCompressionS3TCsRGB;
+
// GL_KHR_texture_compression_astc_hdr
bool textureCompressionASTCHDR;
diff --git a/src/libANGLE/format_map_autogen.cpp b/src/libANGLE/format_map_autogen.cpp
index 707d384..6899706 100644
--- a/src/libANGLE/format_map_autogen.cpp
+++ b/src/libANGLE/format_map_autogen.cpp
@@ -92,6 +92,46 @@
}
break;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;
+ default:
+ break;
+ }
+ break;
+
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
+ default:
+ break;
+ }
+ break;
+
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
+ default:
+ break;
+ }
+ break;
+
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
+ default:
+ break;
+ }
+ break;
+
case GL_DEPTH_COMPONENT:
switch (type)
{
diff --git a/src/libANGLE/format_map_data.json b/src/libANGLE/format_map_data.json
index 3d6ad6c..a4f1c98 100644
--- a/src/libANGLE/format_map_data.json
+++ b/src/libANGLE/format_map_data.json
@@ -115,6 +115,18 @@
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": {
"GL_UNSIGNED_BYTE": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"
},
+ "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT": {
+ "GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT"
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT": {
+ "GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT"
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT": {
+ "GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT"
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT": {
+ "GL_UNSIGNED_BYTE": "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT"
+ },
"GL_DEPTH_COMPONENT": {
"GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16",
"GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES",
diff --git a/src/libANGLE/formatutils.cpp b/src/libANGLE/formatutils.cpp
index 8b696d5..6692d3f 100644
--- a/src/libANGLE/formatutils.cpp
+++ b/src/libANGLE/formatutils.cpp
@@ -564,6 +564,13 @@
// From GL_OES_compressed_ETC1_RGB8_texture
map.insert(InternalFormatInfoPair(GL_ETC1_RGB8_OES, CompressedFormat(4, 4, 64, 3, GL_ETC1_RGB8_OES, GL_UNSIGNED_BYTE, false, RequireExt<&Extensions::compressedETC1RGB8Texture>, NeverSupported, AlwaysSupported)));
+ // From GL_EXT_texture_compression_s3tc_srgb
+ // | Internal format | |W |H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
+ map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 3, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported)));
+ map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, CompressedFormat(4, 4, 64, 4, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported)));
+ map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported)));
+ map.insert(InternalFormatInfoPair(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, CompressedFormat(4, 4, 128, 4, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_UNSIGNED_BYTE, true, RequireExt<&Extensions::textureCompressionS3TCsRGB>, NeverSupported, AlwaysSupported)));
+
// From KHR_texture_compression_astc_hdr
// | Internal format | | W | H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable |
map.insert(InternalFormatInfoPair(GL_COMPRESSED_RGBA_ASTC_4x4_KHR, CompressedFormat( 4, 4, 128, 4, GL_COMPRESSED_RGBA_ASTC_4x4_KHR, GL_UNSIGNED_BYTE, false, RequireExtOrExt<&Extensions::textureCompressionASTCHDR, &Extensions::textureCompressionASTCLDR>, NeverSupported, AlwaysSupported)));
diff --git a/src/libANGLE/renderer/Format_ID_autogen.inl b/src/libANGLE/renderer/Format_ID_autogen.inl
index deee1fe..5c01b50 100644
--- a/src/libANGLE/renderer/Format_ID_autogen.inl
+++ b/src/libANGLE/renderer/Format_ID_autogen.inl
@@ -50,9 +50,13 @@
B8G8R8A8_UNORM,
B8G8R8X8_UNORM,
BC1_RGBA_UNORM_BLOCK,
+ BC1_RGBA_UNORM_SRGB_BLOCK,
BC1_RGB_UNORM_BLOCK,
+ BC1_RGB_UNORM_SRGB_BLOCK,
BC2_RGBA_UNORM_BLOCK,
+ BC2_RGBA_UNORM_SRGB_BLOCK,
BC3_RGBA_UNORM_BLOCK,
+ BC3_RGBA_UNORM_SRGB_BLOCK,
D16_UNORM,
D24_UNORM,
D24_UNORM_S8_UINT,
diff --git a/src/libANGLE/renderer/Format_table_autogen.cpp b/src/libANGLE/renderer/Format_table_autogen.cpp
index 507827f..6b30642 100644
--- a/src/libANGLE/renderer/Format_table_autogen.cpp
+++ b/src/libANGLE/renderer/Format_table_autogen.cpp
@@ -62,9 +62,13 @@
{ Format::ID::B8G8R8A8_UNORM, GL_BGRA8_EXT, GL_BGRA8_EXT, GenerateMip<B8G8R8A8>, BGRACopyFunctions, ReadColor<B8G8R8A8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 8, 0, 0 },
{ Format::ID::B8G8R8X8_UNORM, GL_BGRA8_EXT, GL_BGRA8_EXT, GenerateMip<B8G8R8X8>, NoCopyFunctions, ReadColor<B8G8R8X8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 8, 8, 0, 0, 0 },
{ Format::ID::BC1_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
+ { Format::ID::BC1_RGBA_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
{ Format::ID::BC1_RGB_UNORM_BLOCK, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
+ { Format::ID::BC1_RGB_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
{ Format::ID::BC2_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
+ { Format::ID::BC2_RGBA_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
{ Format::ID::BC3_RGBA_UNORM_BLOCK, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
+ { Format::ID::BC3_RGBA_UNORM_SRGB_BLOCK, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 0, 0 },
{ Format::ID::D16_UNORM, GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT16, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 16, 0 },
{ Format::ID::D24_UNORM, GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT24, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 0 },
{ Format::ID::D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 8 },
diff --git a/src/libANGLE/renderer/angle_format_map.json b/src/libANGLE/renderer/angle_format_map.json
index 064c400..f7ad2bd 100644
--- a/src/libANGLE/renderer/angle_format_map.json
+++ b/src/libANGLE/renderer/angle_format_map.json
@@ -49,6 +49,10 @@
[ "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", "ETC2_R8G8B8A8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ETC2", "ETC2_R8G8B8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", "ETC2_R8G8B8A1_SRGB_BLOCK" ],
+ [ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT", "BC1_RGBA_UNORM_SRGB_BLOCK" ],
+ [ "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_DEPTH24_STENCIL8", "D24_UNORM_S8_UINT" ],
[ "GL_DEPTH32F_STENCIL8", "D32_FLOAT_S8X24_UINT" ],
[ "GL_DEPTH_COMPONENT16", "D16_UNORM" ],
diff --git a/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json b/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json
index 5b8d735..891d30d 100644
--- a/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json
+++ b/src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json
@@ -71,13 +71,13 @@
"G8R8_G8B8_UNORM": "",
"BC1_TYPELESS": "",
"BC1_UNORM": "BC1_RGBA_UNORM_BLOCK",
- "BC1_UNORM_SRGB": "",
+ "BC1_UNORM_SRGB": "BC1_RGBA_UNORM_SRGB_BLOCK",
"BC2_TYPELESS": "",
"BC2_UNORM": "BC2_RGBA_UNORM_BLOCK",
- "BC2_UNORM_SRGB": "",
+ "BC2_UNORM_SRGB": "BC2_RGBA_UNORM_SRGB_BLOCK",
"BC3_TYPELESS": "",
"BC3_UNORM": "BC3_RGBA_UNORM_BLOCK",
- "BC3_UNORM_SRGB": "",
+ "BC3_UNORM_SRGB": "BC3_RGBA_UNORM_SRGB_BLOCK",
"BC4_TYPELESS": "",
"BC4_UNORM": "",
"BC4_SNORM": "",
diff --git a/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp b/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp
index 66610ca..02513cf 100644
--- a/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/dxgi_format_map_autogen.cpp
@@ -304,19 +304,19 @@
case DXGI_FORMAT_BC1_UNORM:
return Format::Get(Format::ID::BC1_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC1_UNORM_SRGB:
- break;
+ return Format::Get(Format::ID::BC1_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC2_TYPELESS:
break;
case DXGI_FORMAT_BC2_UNORM:
return Format::Get(Format::ID::BC2_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC2_UNORM_SRGB:
- break;
+ return Format::Get(Format::ID::BC2_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC3_TYPELESS:
break;
case DXGI_FORMAT_BC3_UNORM:
return Format::Get(Format::ID::BC3_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC3_UNORM_SRGB:
- break;
+ return Format::Get(Format::ID::BC3_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC4_SNORM:
break;
case DXGI_FORMAT_BC4_TYPELESS:
diff --git a/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json b/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json
index dce0997..9427456 100644
--- a/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json
+++ b/src/libANGLE/renderer/d3d/d3d11/dxgi_support_data.json
@@ -796,7 +796,7 @@
"texture2D": "always",
"texture3D": "always",
"textureCube": "always",
- "shaderSample": "10_0",
+ "shaderSample": "always",
"renderTarget": "never",
"multisampleRT": "never",
"depthStencil": "never",
@@ -829,7 +829,7 @@
"texture2D": "always",
"texture3D": "always",
"textureCube": "always",
- "shaderSample": "10_0",
+ "shaderSample": "always",
"renderTarget": "never",
"multisampleRT": "never",
"depthStencil": "never",
@@ -862,7 +862,7 @@
"texture2D": "always",
"texture3D": "always",
"textureCube": "always",
- "shaderSample": "10_0",
+ "shaderSample": "always",
"renderTarget": "never",
"multisampleRT": "never",
"depthStencil": "never",
diff --git a/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp b/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp
index d202ce1..2816a24 100644
--- a/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/dxgi_support_table.cpp
@@ -129,7 +129,7 @@
}
case DXGI_FORMAT_BC1_UNORM_SRGB:
{
- static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
+ static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
return info;
}
case DXGI_FORMAT_BC2_TYPELESS:
@@ -144,7 +144,7 @@
}
case DXGI_FORMAT_BC2_UNORM_SRGB:
{
- static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
+ static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
return info;
}
case DXGI_FORMAT_BC3_TYPELESS:
@@ -159,7 +159,7 @@
}
case DXGI_FORMAT_BC3_UNORM_SRGB:
{
- static const DXGISupport info(F_2D | F_3D | F_CUBE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
+ static const DXGISupport info(F_2D | F_3D | F_CUBE | F_SAMPLE, F_DS | F_MIPGEN | F_MS | F_RT, 0);
return info;
}
case DXGI_FORMAT_BC4_SNORM:
diff --git a/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py b/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py
index dba583f..200a505 100644
--- a/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py
+++ b/src/libANGLE/renderer/d3d/d3d11/gen_dxgi_support_tables.py
@@ -8,6 +8,7 @@
# are natively support in D3D10+.
#
# MSDN links:
+# 10Level9 9_3: https://msdn.microsoft.com/en-us/library/windows/desktop/mt790740.aspx
# 10_0: https://msdn.microsoft.com/en-us/library/windows/desktop/cc627090.aspx
# 10_1: https://msdn.microsoft.com/en-us/library/windows/desktop/cc627091.aspx
# 11_0: https://msdn.microsoft.com/en-us/library/windows/desktop/ff471325.aspx
diff --git a/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py b/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py
index 3c4b228..db6a44b 100644
--- a/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py
+++ b/src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py
@@ -107,7 +107,7 @@
gl_channels = gl_format_channels(internal_format)
gl_format_no_alpha = gl_channels == 'rgb' or gl_channels == 'l'
if gl_format_no_alpha and angle_format['channels'] == 'rgba':
- if angle_format['texFormat'] == 'DXGI_FORMAT_BC1_UNORM':
+ if angle_format['texFormat'].startswith('DXGI_FORMAT_BC1_UNORM'):
# BC1 is a special case since the texture data determines whether each block has an alpha channel or not.
# This if statement is hit by COMPRESSED_RGB_S3TC_DXT1, which is a bit of a mess.
# TODO(oetuaho): Look into whether COMPRESSED_RGB_S3TC_DXT1 works right in general.
diff --git a/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json b/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json
index 06f7e2a..6d481ec 100644
--- a/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json
+++ b/src/libANGLE/renderer/d3d/d3d11/texture_format_data.json
@@ -61,32 +61,56 @@
"srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba",
"componentType": "unorm",
- "swizzleFormat": "GL_RGBA8",
- "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
+ "swizzleFormat": "GL_RGBA8"
},
"BC1_RGB_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC1_UNORM",
"srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba",
"componentType": "unorm",
- "swizzleFormat": "GL_RGBA8",
- "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
+ "swizzleFormat": "GL_RGBA8"
},
"BC2_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC2_UNORM",
"srvFormat": "DXGI_FORMAT_BC2_UNORM",
"channels": "rgba",
"componentType": "unorm",
- "swizzleFormat": "GL_RGBA8",
- "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
+ "swizzleFormat": "GL_RGBA8"
},
"BC3_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC3_UNORM",
"srvFormat": "DXGI_FORMAT_BC3_UNORM",
"channels": "rgba",
"componentType": "unorm",
- "swizzleFormat": "GL_RGBA8",
- "glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE"
+ "swizzleFormat": "GL_RGBA8"
+ },
+ "BC1_RGBA_UNORM_SRGB_BLOCK": {
+ "texFormat": "DXGI_FORMAT_BC1_UNORM_SRGB",
+ "srvFormat": "DXGI_FORMAT_BC1_UNORM_SRGB",
+ "channels": "rgba",
+ "componentType": "unorm",
+ "swizzleFormat": "GL_RGBA8"
+ },
+ "BC1_RGB_UNORM_SRGB_BLOCK": {
+ "texFormat": "DXGI_FORMAT_BC1_UNORM_SRGB",
+ "srvFormat": "DXGI_FORMAT_BC1_UNORM_SRGB",
+ "channels": "rgba",
+ "componentType": "unorm",
+ "swizzleFormat": "GL_RGBA8"
+ },
+ "BC2_RGBA_UNORM_SRGB_BLOCK": {
+ "texFormat": "DXGI_FORMAT_BC2_UNORM_SRGB",
+ "srvFormat": "DXGI_FORMAT_BC2_UNORM_SRGB",
+ "channels": "rgba",
+ "componentType": "unorm",
+ "swizzleFormat": "GL_RGBA8"
+ },
+ "BC3_RGBA_UNORM_SRGB_BLOCK": {
+ "texFormat": "DXGI_FORMAT_BC3_UNORM_SRGB",
+ "srvFormat": "DXGI_FORMAT_BC3_UNORM_SRGB",
+ "channels": "rgba",
+ "componentType": "unorm",
+ "swizzleFormat": "GL_RGBA8"
},
"D24_UNORM_S8_UINT": {
"FL10Plus": {
diff --git a/src/libANGLE/renderer/d3d/d3d11/texture_format_map.json b/src/libANGLE/renderer/d3d/d3d11/texture_format_map.json
index 9b2e8d9..278217d 100644
--- a/src/libANGLE/renderer/d3d/d3d11/texture_format_map.json
+++ b/src/libANGLE/renderer/d3d/d3d11/texture_format_map.json
@@ -22,7 +22,6 @@
"GL_COMPRESSED_RGBA_ASTC_10x10_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_12x10_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_12x12_KHR": "NONE",
- "GL_COMPRESSED_RGB_S3TC_DXT1_EXT": "BC1_RGB_UNORM_BLOCK",
"GL_COMPRESSED_SIGNED_R11_EAC": "R8_SNORM",
"GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE",
diff --git a/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp b/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp
index dd9c875..f7034ec 100644
--- a/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp
+++ b/src/libANGLE/renderer/d3d/d3d11/texture_format_table_autogen.cpp
@@ -702,6 +702,58 @@
nullptr);
return info;
}
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ {
+ static constexpr Format info(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
+ angle::Format::ID::BC1_RGBA_UNORM_SRGB_BLOCK,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ GL_RGBA8,
+ nullptr);
+ return info;
+ }
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ {
+ static constexpr Format info(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
+ angle::Format::ID::BC2_RGBA_UNORM_SRGB_BLOCK,
+ DXGI_FORMAT_BC2_UNORM_SRGB,
+ DXGI_FORMAT_BC2_UNORM_SRGB,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_BC2_UNORM_SRGB,
+ GL_RGBA8,
+ nullptr);
+ return info;
+ }
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ {
+ static constexpr Format info(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
+ angle::Format::ID::BC3_RGBA_UNORM_SRGB_BLOCK,
+ DXGI_FORMAT_BC3_UNORM_SRGB,
+ DXGI_FORMAT_BC3_UNORM_SRGB,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_BC3_UNORM_SRGB,
+ GL_RGBA8,
+ nullptr);
+ return info;
+ }
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ {
+ static constexpr Format info(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
+ angle::Format::ID::BC1_RGB_UNORM_SRGB_BLOCK,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_UNKNOWN,
+ DXGI_FORMAT_BC1_UNORM_SRGB,
+ GL_RGBA8,
+ nullptr);
+ return info;
+ }
case GL_DEPTH24_STENCIL8:
{
if (OnlyFL10Plus(deviceCaps))
diff --git a/src/libANGLE/renderer/load_functions_data.json b/src/libANGLE/renderer/load_functions_data.json
index 8145704..19ea026 100644
--- a/src/libANGLE/renderer/load_functions_data.json
+++ b/src/libANGLE/renderer/load_functions_data.json
@@ -558,5 +558,25 @@
"R16G16B16A16_SNORM": {
"GL_SHORT": "LoadToNative<GLushort, 4>"
}
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT": {
+ "NONE": {
+ "GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
+ }
+ },
+ "GL_COMPRESSED_SRGB_S3TC_DXT1_EXT": {
+ "NONE": {
+ "GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 8>"
+ }
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT": {
+ "NONE": {
+ "GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 8>"
+ }
+ },
+ "GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT": {
+ "NONE": {
+ "GL_UNSIGNED_BYTE": "LoadCompressedToNative<4, 4, 16>"
+ }
}
}
diff --git a/src/libANGLE/renderer/load_functions_table_autogen.cpp b/src/libANGLE/renderer/load_functions_table_autogen.cpp
index c93f873..d3da522 100644
--- a/src/libANGLE/renderer/load_functions_table_autogen.cpp
+++ b/src/libANGLE/renderer/load_functions_table_autogen.cpp
@@ -382,6 +382,54 @@
}
}
+LoadImageFunctionInfo COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT_to_default(GLenum type)
+{
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 8>, true);
+ default:
+ UNREACHABLE();
+ return LoadImageFunctionInfo(UnreachableLoadFunction, true);
+ }
+}
+
+LoadImageFunctionInfo COMPRESSED_SRGB_ALPHA_S3TC_DXT3_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_DXT5_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_S3TC_DXT1_EXT_to_default(GLenum type)
+{
+ switch (type)
+ {
+ case GL_UNSIGNED_BYTE:
+ return LoadImageFunctionInfo(LoadCompressedToNative<4, 4, 8>, true);
+ default:
+ UNREACHABLE();
+ return LoadImageFunctionInfo(UnreachableLoadFunction, true);
+ }
+}
+
LoadImageFunctionInfo DEPTH24_STENCIL8_to_D24_UNORM_S8_UINT(GLenum type)
{
switch (type)
@@ -1607,6 +1655,14 @@
break;
}
}
+ 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:
+ return COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT_to_default;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT_to_default;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ return COMPRESSED_SRGB_S3TC_DXT1_EXT_to_default;
case GL_DEPTH24_STENCIL8:
{
switch (angleFormat)
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index 4deb90a..dc2a008 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -436,6 +436,16 @@
return false;
}
break;
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ if (!context->getExtensions().textureCompressionS3TCsRGB)
+ {
+ context->handleError(Error(GL_INVALID_ENUM));
+ return false;
+ }
+ break;
case GL_ETC1_RGB8_OES:
if (!context->getExtensions().compressedETC1RGB8Texture)
{
diff --git a/src/tests/angle_end2end_tests.gypi b/src/tests/angle_end2end_tests.gypi
index 96a166b..a51f169 100644
--- a/src/tests/angle_end2end_tests.gypi
+++ b/src/tests/angle_end2end_tests.gypi
@@ -35,6 +35,7 @@
'<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp',
'<(angle_path)/src/tests/gl_tests/DrawElementsTest.cpp',
'<(angle_path)/src/tests/gl_tests/DXT1CompressedTextureTest.cpp',
+ '<(angle_path)/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/ETCTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp',
diff --git a/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp b/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp
new file mode 100644
index 0000000..0aa9422
--- /dev/null
+++ b/src/tests/gl_tests/DXTSRGBCompressedTextureTest.cpp
@@ -0,0 +1,170 @@
+//
+// Copyright 2016 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.
+//
+// DXTSRGBCompressedTextureTest.cpp
+// Tests for sRGB DXT textures (GL_EXT_texture_compression_s3tc_srgb)
+//
+
+#include "test_utils/ANGLETest.h"
+#include "test_utils/gl_raii.h"
+
+#include "media/pixel.inl"
+
+#include "DXTSRGBCompressedTextureTestData.inl"
+
+using namespace angle;
+
+static constexpr int kWindowSize = 64;
+
+class DXTSRGBCompressedTextureTest : public ANGLETest
+{
+ protected:
+ DXTSRGBCompressedTextureTest()
+ {
+ setWindowWidth(kWindowSize);
+ setWindowHeight(kWindowSize);
+ setConfigRedBits(8);
+ setConfigGreenBits(8);
+ setConfigBlueBits(8);
+ setConfigAlphaBits(8);
+ }
+
+ void SetUp() override
+ {
+ ANGLETest::SetUp();
+
+ const std::string vsSource = std::string(
+ "precision highp float;\n"
+ "attribute vec4 position;\n"
+ "varying vec2 texcoord;\n"
+ "void main() {\n"
+ " gl_Position = position;\n"
+ " texcoord = (position.xy * 0.5) + 0.5;\n"
+ " texcoord.y = 1.0 - texcoord.y;\n"
+ "}");
+
+ const std::string textureFSSource = std::string(
+ "precision highp float;\n"
+ "uniform sampler2D tex;\n"
+ "varying vec2 texcoord;\n"
+ "void main() {\n"
+ " gl_FragColor = texture2D(tex, texcoord);\n"
+ "}\n");
+
+ mTextureProgram = CompileProgram(vsSource, textureFSSource);
+ ASSERT_NE(0u, mTextureProgram);
+
+ mTextureUniformLocation = glGetUniformLocation(mTextureProgram, "tex");
+ ASSERT_NE(-1, mTextureUniformLocation);
+
+ ASSERT_GL_NO_ERROR();
+ }
+
+ void TearDown() override
+ {
+ glDeleteProgram(mTextureProgram);
+
+ ANGLETest::TearDown();
+ }
+
+ void runTestChecks(const TestCase &test)
+ {
+ GLColor actual[kWindowSize * kWindowSize] = {0};
+ drawQuad(mTextureProgram, "position", 0.5f);
+ ASSERT_GL_NO_ERROR();
+ glReadPixels(0, 0, kWindowSize, kWindowSize, GL_RGBA, GL_UNSIGNED_BYTE,
+ reinterpret_cast<void *>(actual));
+ ASSERT_GL_NO_ERROR();
+ for (GLsizei y = 0; y < test.height; ++y)
+ {
+ for (GLsizei x = 0; x < test.width; ++x)
+ {
+ GLColor exp = reinterpret_cast<const GLColor *>(test.expected)[y * test.width + x];
+ size_t x_actual = (x * kWindowSize + kWindowSize / 2) / test.width;
+ size_t y_actual =
+ ((test.height - y - 1) * kWindowSize + kWindowSize / 2) / test.height;
+ GLColor act = actual[y_actual * kWindowSize + x_actual];
+ EXPECT_COLOR_NEAR(exp, act, 2.0);
+ }
+ }
+ }
+
+ void runTest(GLenum format)
+ {
+ if (!extensionEnabled("GL_EXT_texture_compression_s3tc_srgb"))
+ {
+ std::cout
+ << "Test skipped because GL_EXT_texture_compression_s3tc_srgb is not available."
+ << std::endl;
+ return;
+ }
+
+ const TestCase &test = kTests.at(format);
+
+ GLTexture texture;
+ glBindTexture(GL_TEXTURE_2D, texture.get());
+ 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);
+
+ glUseProgram(mTextureProgram);
+ glUniform1i(mTextureUniformLocation, 0);
+ ASSERT_GL_NO_ERROR();
+
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, format, test.width, test.height, 0, test.dataSize,
+ test.data);
+ ASSERT_GL_NO_ERROR() << "glCompressedTexImage2D(format=" << format << ")";
+ runTestChecks(test);
+
+ glCompressedTexImage2D(GL_TEXTURE_2D, 0, format, test.width, test.height, 0, test.dataSize,
+ nullptr);
+ ASSERT_GL_NO_ERROR() << "glCompressedTexImage2D(format=" << format << ", data=null)";
+ glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, test.width, test.height, format,
+ test.dataSize, test.data);
+ ASSERT_GL_NO_ERROR() << "glCompressedTexSubImage2D(format=" << format << ")";
+ runTestChecks(test);
+
+ ASSERT_GL_NO_ERROR();
+ }
+
+ GLuint mTextureProgram = 0;
+ GLint mTextureUniformLocation = -1;
+};
+
+// Test correct decompression of 8x8 textures (four 4x4 blocks) of SRGB_S3TC_DXT1
+TEST_P(DXTSRGBCompressedTextureTest, Decompression8x8RGBDXT1)
+{
+ runTest(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT);
+}
+
+// Test correct decompression of 8x8 textures (four 4x4 blocks) of SRGB_ALPHA_S3TC_DXT1
+TEST_P(DXTSRGBCompressedTextureTest, Decompression8x8RGBADXT1)
+{
+ runTest(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT);
+}
+
+// Test correct decompression of 8x8 textures (four 4x4 blocks) of SRGB_ALPHA_S3TC_DXT3
+TEST_P(DXTSRGBCompressedTextureTest, Decompression8x8RGBADXT3)
+{
+ runTest(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT);
+}
+
+// Test correct decompression of 8x8 textures (four 4x4 blocks) of SRGB_ALPHA_S3TC_DXT5
+TEST_P(DXTSRGBCompressedTextureTest, Decompression8x8RGBADXT5)
+{
+ runTest(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT);
+}
+
+// Use this to select which configurations (e.g. which renderer, which GLES major version) these
+// tests should be run against.
+ANGLE_INSTANTIATE_TEST(DXTSRGBCompressedTextureTest,
+ ES2_D3D11(),
+ ES2_D3D11_FL9_3(),
+ ES3_D3D11(),
+ ES2_OPENGL(),
+ ES3_OPENGL(),
+ ES2_OPENGLES(),
+ ES3_OPENGLES());
diff --git a/src/tests/gl_tests/DXTSRGBCompressedTextureTestData.inl b/src/tests/gl_tests/DXTSRGBCompressedTextureTestData.inl
new file mode 100644
index 0000000..fa9a308
--- /dev/null
+++ b/src/tests/gl_tests/DXTSRGBCompressedTextureTestData.inl
@@ -0,0 +1,139 @@
+//
+// Copyright 2016 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.
+//
+// DXTSRGBCompressedTextureTestData.inl
+// Data for sRGB DXT texture tests (DXTSRGBCompressedTextureTest.cpp)
+//
+
+static constexpr size_t kMaxCompressedSize = 64;
+static constexpr size_t kMaxDecompressedSize = 256;
+
+struct TestCase
+{
+ GLsizei width;
+ GLsizei height;
+ GLsizei dataSize;
+ uint8_t data[kMaxCompressedSize];
+ uint8_t expected[kMaxDecompressedSize];
+};
+
+static const std::map<GLenum, TestCase> kTests = {
+ {
+ GL_COMPRESSED_SRGB_S3TC_DXT1_EXT,
+ {
+ 8, 8, 32,
+ {
+ 0x08, 0xba, 0xe8, 0x45, 0x44, 0x45, 0x40, 0x55, 0xe8, 0xbd, 0x17, 0x42, 0x44, 0x45, 0x40, 0x55,
+ 0x17, 0xba, 0xe8, 0x45, 0x11, 0x10, 0x15, 0x00, 0xf7, 0x45, 0x17, 0x42, 0x11, 0x10, 0x15, 0x00,
+ },
+ {
+ 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ }
+ }
+ },
+ {
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,
+ {
+ 8, 8, 32,
+ {
+ 0xa8, 0x4d, 0x48, 0xb2, 0x13, 0x10, 0x15, 0x00, 0xe8, 0xbd, 0x17, 0x42, 0x44, 0x45, 0x40, 0x55,
+ 0x17, 0xba, 0xe8, 0x45, 0x11, 0x10, 0x15, 0x00, 0xf7, 0x45, 0x17, 0x42, 0x11, 0x10, 0x15, 0x00,
+ },
+ {
+ 0x00, 0x00, 0x00, 0x00, 0x11, 0x77, 0x0d, 0xff, 0x74, 0x11, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x11, 0x77, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff, 0x74, 0x11, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x74, 0x11, 0x0d, 0xff, 0x74, 0x11, 0x0d, 0xff, 0x74, 0x11, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x11, 0x77, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff, 0x11, 0x77, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ }
+ }
+ },
+ {
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,
+ {
+ 8, 8, 64,
+ {
+ 0xf7, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0xba, 0xe8, 0x45, 0x44, 0x45, 0x40, 0x55,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe8, 0xbd, 0x17, 0x42, 0x44, 0x45, 0x40, 0x55,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x17, 0xba, 0xe8, 0x45, 0x11, 0x10, 0x15, 0x00,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf7, 0x45, 0x17, 0x42, 0x11, 0x10, 0x15, 0x00,
+ },
+ {
+ 0x82, 0x0d, 0x0d, 0x77, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ }
+ }
+ },
+ {
+ GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,
+ {
+ 8, 8, 64,
+ {
+ 0xff, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xba, 0xe8, 0x45, 0x44, 0x45, 0x40, 0x55,
+ 0xff, 0xff, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xe8, 0xbd, 0x17, 0x42, 0x44, 0x45, 0x40, 0x55,
+ 0xff, 0xff, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0x17, 0xba, 0xe8, 0x45, 0x11, 0x10, 0x15, 0x00,
+ 0xff, 0xff, 0x49, 0x92, 0x24, 0x49, 0x92, 0x24, 0xf7, 0x45, 0x17, 0x42, 0x11, 0x10, 0x15, 0x00,
+ },
+ {
+ 0x82, 0x0d, 0x0d, 0x7f, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x82, 0x0d, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x82, 0x83, 0x0d, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x0d, 0x83, 0x0d, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x0d, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff, 0x82, 0x0d, 0x82, 0xff,
+ 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff, 0x0d, 0x83, 0x82, 0xff,
+ }
+ }
+ },
+};