Commit 02f075c8 by Kai Ninomiya Committed by Commit Bot

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: 's avatarJamie Madill <jmadill@chromium.org>
parent cbcde724
...@@ -149,6 +149,7 @@ Extensions::Extensions() ...@@ -149,6 +149,7 @@ Extensions::Extensions()
textureCompressionDXT1(false), textureCompressionDXT1(false),
textureCompressionDXT3(false), textureCompressionDXT3(false),
textureCompressionDXT5(false), textureCompressionDXT5(false),
textureCompressionS3TCsRGB(false),
textureCompressionASTCHDR(false), textureCompressionASTCHDR(false),
textureCompressionASTCLDR(false), textureCompressionASTCLDR(false),
compressedETC1RGB8Texture(false), compressedETC1RGB8Texture(false),
...@@ -395,6 +396,18 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps) ...@@ -395,6 +396,18 @@ static bool DetermineDXT5TextureSupport(const TextureCapsMap &textureCaps)
return GetFormatSupport(textureCaps, requiredFormats, true, true, false); 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 // Check for GL_KHR_texture_compression_astc_hdr and GL_KHR_texture_compression_astc_ldr
static bool DetermineASTCTextureSupport(const TextureCapsMap &textureCaps) static bool DetermineASTCTextureSupport(const TextureCapsMap &textureCaps)
{ {
...@@ -525,6 +538,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps) ...@@ -525,6 +538,7 @@ void Extensions::setTextureExtensionSupport(const TextureCapsMap &textureCaps)
textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps); textureCompressionDXT1 = DetermineDXT1TextureSupport(textureCaps);
textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps); textureCompressionDXT3 = DetermineDXT3TextureSupport(textureCaps);
textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps); textureCompressionDXT5 = DetermineDXT5TextureSupport(textureCaps);
textureCompressionS3TCsRGB = DetermineS3TCsRGBTextureSupport(textureCaps);
textureCompressionASTCHDR = DetermineASTCTextureSupport(textureCaps); textureCompressionASTCHDR = DetermineASTCTextureSupport(textureCaps);
textureCompressionASTCLDR = textureCompressionASTCHDR; textureCompressionASTCLDR = textureCompressionASTCHDR;
compressedETC1RGB8Texture = DetermineETC1RGB8TextureSupport(textureCaps); compressedETC1RGB8Texture = DetermineETC1RGB8TextureSupport(textureCaps);
...@@ -571,6 +585,7 @@ const ExtensionInfoMap &GetExtensionInfoMap() ...@@ -571,6 +585,7 @@ const ExtensionInfoMap &GetExtensionInfoMap()
map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1); map["GL_EXT_texture_compression_dxt1"] = esOnlyExtension(&Extensions::textureCompressionDXT1);
map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3); map["GL_ANGLE_texture_compression_dxt3"] = esOnlyExtension(&Extensions::textureCompressionDXT3);
map["GL_ANGLE_texture_compression_dxt5"] = esOnlyExtension(&Extensions::textureCompressionDXT5); 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_hdr"] = esOnlyExtension(&Extensions::textureCompressionASTCHDR);
map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR); map["GL_KHR_texture_compression_astc_ldr"] = esOnlyExtension(&Extensions::textureCompressionASTCLDR);
map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture); map["GL_OES_compressed_ETC1_RGB8_texture"] = esOnlyExtension(&Extensions::compressedETC1RGB8Texture);
......
...@@ -160,6 +160,12 @@ struct Extensions ...@@ -160,6 +160,12 @@ struct Extensions
bool textureCompressionDXT3; bool textureCompressionDXT3;
bool textureCompressionDXT5; 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 // GL_KHR_texture_compression_astc_hdr
bool textureCompressionASTCHDR; bool textureCompressionASTCHDR;
......
...@@ -92,6 +92,46 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type) ...@@ -92,6 +92,46 @@ GLenum GetSizedFormatInternal(GLenum format, GLenum type)
} }
break; 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: case GL_DEPTH_COMPONENT:
switch (type) switch (type)
{ {
......
...@@ -115,6 +115,18 @@ ...@@ -115,6 +115,18 @@
"GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": { "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE": {
"GL_UNSIGNED_BYTE": "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_DEPTH_COMPONENT": {
"GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16", "GL_UNSIGNED_SHORT": "GL_DEPTH_COMPONENT16",
"GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES", "GL_UNSIGNED_INT": "GL_DEPTH_COMPONENT32_OES",
......
...@@ -564,6 +564,13 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -564,6 +564,13 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
// From GL_OES_compressed_ETC1_RGB8_texture // 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))); 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 // From KHR_texture_compression_astc_hdr
// | Internal format | | W | H | BS |CC| Format | Type | SRGB | Supported | Renderable | Filterable | // | 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))); 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)));
......
...@@ -50,9 +50,13 @@ enum class Format::ID ...@@ -50,9 +50,13 @@ enum class Format::ID
B8G8R8A8_UNORM, B8G8R8A8_UNORM,
B8G8R8X8_UNORM, B8G8R8X8_UNORM,
BC1_RGBA_UNORM_BLOCK, BC1_RGBA_UNORM_BLOCK,
BC1_RGBA_UNORM_SRGB_BLOCK,
BC1_RGB_UNORM_BLOCK, BC1_RGB_UNORM_BLOCK,
BC1_RGB_UNORM_SRGB_BLOCK,
BC2_RGBA_UNORM_BLOCK, BC2_RGBA_UNORM_BLOCK,
BC2_RGBA_UNORM_SRGB_BLOCK,
BC3_RGBA_UNORM_BLOCK, BC3_RGBA_UNORM_BLOCK,
BC3_RGBA_UNORM_SRGB_BLOCK,
D16_UNORM, D16_UNORM,
D24_UNORM, D24_UNORM,
D24_UNORM_S8_UINT, D24_UNORM_S8_UINT,
......
...@@ -62,9 +62,13 @@ constexpr Format g_formatInfoTable[] = { ...@@ -62,9 +62,13 @@ constexpr Format g_formatInfoTable[] = {
{ 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::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::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_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_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_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_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::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, 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 }, { Format::ID::D24_UNORM_S8_UINT, GL_DEPTH24_STENCIL8, GL_DEPTH24_STENCIL8, nullptr, NoCopyFunctions, nullptr, GL_UNSIGNED_NORMALIZED, 0, 0, 0, 0, 24, 8 },
......
...@@ -49,6 +49,10 @@ ...@@ -49,6 +49,10 @@
[ "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", "ETC2_R8G8B8A8_SRGB_BLOCK" ], [ "GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC", "ETC2_R8G8B8A8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_ETC2", "ETC2_R8G8B8_SRGB_BLOCK" ], [ "GL_COMPRESSED_SRGB8_ETC2", "ETC2_R8G8B8_SRGB_BLOCK" ],
[ "GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2", "ETC2_R8G8B8A1_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_DEPTH24_STENCIL8", "D24_UNORM_S8_UINT" ],
[ "GL_DEPTH32F_STENCIL8", "D32_FLOAT_S8X24_UINT" ], [ "GL_DEPTH32F_STENCIL8", "D32_FLOAT_S8X24_UINT" ],
[ "GL_DEPTH_COMPONENT16", "D16_UNORM" ], [ "GL_DEPTH_COMPONENT16", "D16_UNORM" ],
......
...@@ -71,13 +71,13 @@ ...@@ -71,13 +71,13 @@
"G8R8_G8B8_UNORM": "", "G8R8_G8B8_UNORM": "",
"BC1_TYPELESS": "", "BC1_TYPELESS": "",
"BC1_UNORM": "BC1_RGBA_UNORM_BLOCK", "BC1_UNORM": "BC1_RGBA_UNORM_BLOCK",
"BC1_UNORM_SRGB": "", "BC1_UNORM_SRGB": "BC1_RGBA_UNORM_SRGB_BLOCK",
"BC2_TYPELESS": "", "BC2_TYPELESS": "",
"BC2_UNORM": "BC2_RGBA_UNORM_BLOCK", "BC2_UNORM": "BC2_RGBA_UNORM_BLOCK",
"BC2_UNORM_SRGB": "", "BC2_UNORM_SRGB": "BC2_RGBA_UNORM_SRGB_BLOCK",
"BC3_TYPELESS": "", "BC3_TYPELESS": "",
"BC3_UNORM": "BC3_RGBA_UNORM_BLOCK", "BC3_UNORM": "BC3_RGBA_UNORM_BLOCK",
"BC3_UNORM_SRGB": "", "BC3_UNORM_SRGB": "BC3_RGBA_UNORM_SRGB_BLOCK",
"BC4_TYPELESS": "", "BC4_TYPELESS": "",
"BC4_UNORM": "", "BC4_UNORM": "",
"BC4_SNORM": "", "BC4_SNORM": "",
......
...@@ -304,19 +304,19 @@ const Format &GetFormat(DXGI_FORMAT dxgiFormat) ...@@ -304,19 +304,19 @@ const Format &GetFormat(DXGI_FORMAT dxgiFormat)
case DXGI_FORMAT_BC1_UNORM: case DXGI_FORMAT_BC1_UNORM:
return Format::Get(Format::ID::BC1_RGBA_UNORM_BLOCK); return Format::Get(Format::ID::BC1_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC1_UNORM_SRGB: case DXGI_FORMAT_BC1_UNORM_SRGB:
break; return Format::Get(Format::ID::BC1_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC2_TYPELESS: case DXGI_FORMAT_BC2_TYPELESS:
break; break;
case DXGI_FORMAT_BC2_UNORM: case DXGI_FORMAT_BC2_UNORM:
return Format::Get(Format::ID::BC2_RGBA_UNORM_BLOCK); return Format::Get(Format::ID::BC2_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC2_UNORM_SRGB: case DXGI_FORMAT_BC2_UNORM_SRGB:
break; return Format::Get(Format::ID::BC2_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC3_TYPELESS: case DXGI_FORMAT_BC3_TYPELESS:
break; break;
case DXGI_FORMAT_BC3_UNORM: case DXGI_FORMAT_BC3_UNORM:
return Format::Get(Format::ID::BC3_RGBA_UNORM_BLOCK); return Format::Get(Format::ID::BC3_RGBA_UNORM_BLOCK);
case DXGI_FORMAT_BC3_UNORM_SRGB: case DXGI_FORMAT_BC3_UNORM_SRGB:
break; return Format::Get(Format::ID::BC3_RGBA_UNORM_SRGB_BLOCK);
case DXGI_FORMAT_BC4_SNORM: case DXGI_FORMAT_BC4_SNORM:
break; break;
case DXGI_FORMAT_BC4_TYPELESS: case DXGI_FORMAT_BC4_TYPELESS:
......
...@@ -796,7 +796,7 @@ ...@@ -796,7 +796,7 @@
"texture2D": "always", "texture2D": "always",
"texture3D": "always", "texture3D": "always",
"textureCube": "always", "textureCube": "always",
"shaderSample": "10_0", "shaderSample": "always",
"renderTarget": "never", "renderTarget": "never",
"multisampleRT": "never", "multisampleRT": "never",
"depthStencil": "never", "depthStencil": "never",
...@@ -829,7 +829,7 @@ ...@@ -829,7 +829,7 @@
"texture2D": "always", "texture2D": "always",
"texture3D": "always", "texture3D": "always",
"textureCube": "always", "textureCube": "always",
"shaderSample": "10_0", "shaderSample": "always",
"renderTarget": "never", "renderTarget": "never",
"multisampleRT": "never", "multisampleRT": "never",
"depthStencil": "never", "depthStencil": "never",
...@@ -862,7 +862,7 @@ ...@@ -862,7 +862,7 @@
"texture2D": "always", "texture2D": "always",
"texture3D": "always", "texture3D": "always",
"textureCube": "always", "textureCube": "always",
"shaderSample": "10_0", "shaderSample": "always",
"renderTarget": "never", "renderTarget": "never",
"multisampleRT": "never", "multisampleRT": "never",
"depthStencil": "never", "depthStencil": "never",
......
...@@ -129,7 +129,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) ...@@ -129,7 +129,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat)
} }
case DXGI_FORMAT_BC1_UNORM_SRGB: 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; return info;
} }
case DXGI_FORMAT_BC2_TYPELESS: case DXGI_FORMAT_BC2_TYPELESS:
...@@ -144,7 +144,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) ...@@ -144,7 +144,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat)
} }
case DXGI_FORMAT_BC2_UNORM_SRGB: 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; return info;
} }
case DXGI_FORMAT_BC3_TYPELESS: case DXGI_FORMAT_BC3_TYPELESS:
...@@ -159,7 +159,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat) ...@@ -159,7 +159,7 @@ const DXGISupport &GetDXGISupport_9_3(DXGI_FORMAT dxgiFormat)
} }
case DXGI_FORMAT_BC3_UNORM_SRGB: 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; return info;
} }
case DXGI_FORMAT_BC4_SNORM: case DXGI_FORMAT_BC4_SNORM:
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
# are natively support in D3D10+. # are natively support in D3D10+.
# #
# MSDN links: # 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_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 # 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 # 11_0: https://msdn.microsoft.com/en-us/library/windows/desktop/ff471325.aspx
......
...@@ -107,7 +107,7 @@ def get_internal_format_initializer(internal_format, angle_format): ...@@ -107,7 +107,7 @@ def get_internal_format_initializer(internal_format, angle_format):
gl_channels = gl_format_channels(internal_format) gl_channels = gl_format_channels(internal_format)
gl_format_no_alpha = gl_channels == 'rgb' or gl_channels == 'l' gl_format_no_alpha = gl_channels == 'rgb' or gl_channels == 'l'
if gl_format_no_alpha and angle_format['channels'] == 'rgba': 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. # 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. # 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. # TODO(oetuaho): Look into whether COMPRESSED_RGB_S3TC_DXT1 works right in general.
......
...@@ -61,32 +61,56 @@ ...@@ -61,32 +61,56 @@
"srvFormat": "DXGI_FORMAT_BC1_UNORM", "srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8"
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
}, },
"BC1_RGB_UNORM_BLOCK": { "BC1_RGB_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC1_UNORM", "texFormat": "DXGI_FORMAT_BC1_UNORM",
"srvFormat": "DXGI_FORMAT_BC1_UNORM", "srvFormat": "DXGI_FORMAT_BC1_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8"
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT"
}, },
"BC2_RGBA_UNORM_BLOCK": { "BC2_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC2_UNORM", "texFormat": "DXGI_FORMAT_BC2_UNORM",
"srvFormat": "DXGI_FORMAT_BC2_UNORM", "srvFormat": "DXGI_FORMAT_BC2_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8"
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE"
}, },
"BC3_RGBA_UNORM_BLOCK": { "BC3_RGBA_UNORM_BLOCK": {
"texFormat": "DXGI_FORMAT_BC3_UNORM", "texFormat": "DXGI_FORMAT_BC3_UNORM",
"srvFormat": "DXGI_FORMAT_BC3_UNORM", "srvFormat": "DXGI_FORMAT_BC3_UNORM",
"channels": "rgba", "channels": "rgba",
"componentType": "unorm", "componentType": "unorm",
"swizzleFormat": "GL_RGBA8", "swizzleFormat": "GL_RGBA8"
"glInternalFormat": "GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE" },
"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": { "D24_UNORM_S8_UINT": {
"FL10Plus": { "FL10Plus": {
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
"GL_COMPRESSED_RGBA_ASTC_10x10_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_10x10_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_12x10_KHR": "NONE", "GL_COMPRESSED_RGBA_ASTC_12x10_KHR": "NONE",
"GL_COMPRESSED_RGBA_ASTC_12x12_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_R11_EAC": "R8_SNORM",
"GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM", "GL_COMPRESSED_SIGNED_RG11_EAC": "R8G8_SNORM",
"GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE", "GL_COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR": "NONE",
......
...@@ -702,6 +702,58 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev ...@@ -702,6 +702,58 @@ const Format &Format::Get(GLenum internalFormat, const Renderer11DeviceCaps &dev
nullptr); nullptr);
return info; 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: case GL_DEPTH24_STENCIL8:
{ {
if (OnlyFL10Plus(deviceCaps)) if (OnlyFL10Plus(deviceCaps))
......
...@@ -558,5 +558,25 @@ ...@@ -558,5 +558,25 @@
"R16G16B16A16_SNORM": { "R16G16B16A16_SNORM": {
"GL_SHORT": "LoadToNative<GLushort, 4>" "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>"
}
} }
} }
...@@ -382,6 +382,54 @@ LoadImageFunctionInfo COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2_to_R8G8B8A8_UNOR ...@@ -382,6 +382,54 @@ LoadImageFunctionInfo COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2_to_R8G8B8A8_UNOR
} }
} }
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) LoadImageFunctionInfo DEPTH24_STENCIL8_to_D24_UNORM_S8_UINT(GLenum type)
{ {
switch (type) switch (type)
...@@ -1607,6 +1655,14 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, Format::ID angleForma ...@@ -1607,6 +1655,14 @@ LoadFunctionMap GetLoadFunctionsMap(GLenum internalFormat, Format::ID angleForma
break; 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: case GL_DEPTH24_STENCIL8:
{ {
switch (angleFormat) switch (angleFormat)
......
...@@ -436,6 +436,16 @@ bool ValidateES2TexImageParameters(Context *context, ...@@ -436,6 +436,16 @@ bool ValidateES2TexImageParameters(Context *context,
return false; return false;
} }
break; 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: case GL_ETC1_RGB8_OES:
if (!context->getExtensions().compressedETC1RGB8Texture) if (!context->getExtensions().compressedETC1RGB8Texture)
{ {
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
'<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp', '<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp',
'<(angle_path)/src/tests/gl_tests/DrawElementsTest.cpp', '<(angle_path)/src/tests/gl_tests/DrawElementsTest.cpp',
'<(angle_path)/src/tests/gl_tests/DXT1CompressedTextureTest.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/ETCTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp', '<(angle_path)/src/tests/gl_tests/FenceSyncTests.cpp',
'<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp', '<(angle_path)/src/tests/gl_tests/FramebufferMixedSamplesTest.cpp',
......
//
// 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());
//
// 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,
}
}
},
};
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