Commit 56ea854e by Alexey Knyazev Committed by Commit Bot

Metal: Allow unswizzled BC1 RGB

Refine DXT1CompressedTextureTest.DXT1Alpha to pass on more configurations. Fix the test's payload so that all 16 pixels use code 3. Refine texture swizzling detection. Bug: angleproject:2634 Bug: angleproject:5049 Change-Id: If9e1ab63220170a54954234ea205e19583b0df0a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2467896Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarLe Hoang Quyen <le.hoang.q@gmail.com> Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
parent c07bd2f2
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
"src/libANGLE/renderer/metal/gen_mtl_format_table.py": "src/libANGLE/renderer/metal/gen_mtl_format_table.py":
"60bf684695cd552e85fc11eba2a1d5bc", "60bf684695cd552e85fc11eba2a1d5bc",
"src/libANGLE/renderer/metal/mtl_format_map.json": "src/libANGLE/renderer/metal/mtl_format_map.json":
"bd60f72f1dc35054ce439c3edad1caab", "22b62b3705e53c5a6ecf5a173f2e7dc9",
"src/libANGLE/renderer/metal/mtl_format_table_autogen.mm": "src/libANGLE/renderer/metal/mtl_format_table_autogen.mm":
"1d962a58e82ce1288470e9e0ba3d688b" "e47df76e259be3e039541b9615b35a32"
} }
\ No newline at end of file
...@@ -184,11 +184,11 @@ ...@@ -184,11 +184,11 @@
"R5G5B5A1_UNORM": "R8G8B8A8_UNORM", "R5G5B5A1_UNORM": "R8G8B8A8_UNORM",
"R4G4B4A4_UNORM": "R8G8B8A8_UNORM", "R4G4B4A4_UNORM": "R8G8B8A8_UNORM",
"BC1_RGB_UNORM_BLOCK": { "BC1_RGB_UNORM_BLOCK": {
"default": "NONE", "default": "BC1_RGBA_UNORM_BLOCK",
"swizzle": ["RGB1", "BC1_RGBA_UNORM_BLOCK"] "swizzle": ["RGB1", "BC1_RGBA_UNORM_BLOCK"]
}, },
"BC1_RGB_UNORM_SRGB_BLOCK": { "BC1_RGB_UNORM_SRGB_BLOCK": {
"default": "NONE", "default": "BC1_RGBA_UNORM_SRGB_BLOCK",
"swizzle": ["RGB1", "BC1_RGBA_UNORM_SRGB_BLOCK"] "swizzle": ["RGB1", "BC1_RGBA_UNORM_SRGB_BLOCK"]
}, },
"ETC1_R8G8B8_UNORM_BLOCK": "R8G8B8A8_UNORM", "ETC1_R8G8B8_UNORM_BLOCK": "R8G8B8A8_UNORM",
......
...@@ -859,8 +859,8 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_) ...@@ -859,8 +859,8 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
# endif // #if defined(__IPHONE_13_0) || defined(__MAC_10_15) # endif // #if defined(__IPHONE_13_0) || defined(__MAC_10_15)
{ {
this->metalFormat = MTLPixelFormatInvalid; this->metalFormat = MTLPixelFormatBC1_RGBA;
this->actualFormatId = angle::FormatID::NONE; this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_BLOCK;
this->initFunction = nullptr; this->initFunction = nullptr;
this->swizzled = false; this->swizzled = false;
...@@ -883,8 +883,8 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_) ...@@ -883,8 +883,8 @@ void Format::init(const DisplayMtl *display, angle::FormatID intendedFormatId_)
# endif // #if defined(__IPHONE_13_0) || defined(__MAC_10_15) # endif // #if defined(__IPHONE_13_0) || defined(__MAC_10_15)
{ {
this->metalFormat = MTLPixelFormatInvalid; this->metalFormat = MTLPixelFormatBC1_RGBA_sRGB;
this->actualFormatId = angle::FormatID::NONE; this->actualFormatId = angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK;
this->initFunction = nullptr; this->initFunction = nullptr;
this->swizzled = false; this->swizzled = false;
......
...@@ -144,8 +144,8 @@ bool Format::needConversion(angle::FormatID srcFormatId) const ...@@ -144,8 +144,8 @@ bool Format::needConversion(angle::FormatID srcFormatId) const
(srcFormatId == angle::FormatID::BC1_RGB_UNORM_SRGB_BLOCK && (srcFormatId == angle::FormatID::BC1_RGB_UNORM_SRGB_BLOCK &&
actualFormatId == angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK)) actualFormatId == angle::FormatID::BC1_RGBA_UNORM_SRGB_BLOCK))
{ {
// DXT1 RGB format already swizzled with alpha=1, so no need to convert // When texture swizzling is available, DXT1 RGB format will be swizzled with RGB1.
ASSERT(swizzled); // WebGL allows unswizzled mapping when swizzling is not available. No need to convert.
return false; return false;
} }
if (srcFormatId == angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK && if (srcFormatId == angle::FormatID::ETC1_R8G8B8_UNORM_BLOCK &&
......
...@@ -115,8 +115,13 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha) ...@@ -115,8 +115,13 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha)
{ {
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1")); ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_dxt1"));
// http://anglebug.com/4917 // On Intel Metal, results would depend on the GPU Family.
ANGLE_SKIP_TEST_IF(IsD3D()); ANGLE_SKIP_TEST_IF(IsMetal() && IsIntel());
// On platforms without native support for DXT1 RGB or texture swizzling (such as D3D or some
// Metal configurations), this test is allowed to succeed with transparent black instead of
// opaque black.
const bool opaque = !IsD3D() && !(IsMetal() && !IsMetalTextureSwizzleAvailable());
GLTexture texture; GLTexture texture;
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
...@@ -125,7 +130,7 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha) ...@@ -125,7 +130,7 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha)
// Image using pixels with the code for transparent black: // Image using pixels with the code for transparent black:
// "BLACK, if color0 <= color1 and code(x,y) == 3" // "BLACK, if color0 <= color1 and code(x,y) == 3"
constexpr uint8_t CompressedImageDXT1[] = {0, 0, 0, 0, 51, 204, 51, 204}; constexpr uint8_t CompressedImageDXT1[] = {0, 0, 0, 0, 255, 255, 255, 255};
glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0, glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, 4, 4, 0,
sizeof(CompressedImageDXT1), CompressedImageDXT1); sizeof(CompressedImageDXT1), CompressedImageDXT1);
...@@ -146,7 +151,7 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha) ...@@ -146,7 +151,7 @@ TEST_P(DXT1CompressedTextureTest, DXT1Alpha)
{ {
for (GLint x = 0; x < kDrawSize; x++) for (GLint x = 0; x < kDrawSize; x++)
{ {
EXPECT_PIXEL_EQ(x, y, 0, 0, 0, 255) << "at (" << x << ", " << y << ")"; EXPECT_PIXEL_EQ(x, y, 0, 0, 0, opaque ? 255 : 0) << "at (" << x << ", " << y << ")";
} }
} }
} }
......
...@@ -31,9 +31,9 @@ bool IsMetalTextureSwizzleAvailable() ...@@ -31,9 +31,9 @@ bool IsMetalTextureSwizzleAvailable()
// hardwares, however, it is OK for testing. // hardwares, however, it is OK for testing.
if (ANGLE_APPLE_AVAILABLE_XCI(10.15, 13.0, 13)) if (ANGLE_APPLE_AVAILABLE_XCI(10.15, 13.0, 13))
{ {
// Intel doesn't support swizzle because it is GPU family 1. We don't have a way to detect // All NVIDIA and older Intel don't support swizzle because they are GPU family 1.
// Metal family here, so skip on Intel. // We don't have a way to detect Metal family here, so skip all Intel for now.
return !IsIntel(); return !IsIntel() && !IsNVIDIA();
} }
return false; return false;
} }
......
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