Modified: trunk/Source/ThirdParty/ANGLE/src/libANGLE/formatutils.cpp (262459 => 262460)
--- trunk/Source/ThirdParty/ANGLE/src/libANGLE/formatutils.cpp 2020-06-02 23:10:26 UTC (rev 262459)
+++ trunk/Source/ThirdParty/ANGLE/src/libANGLE/formatutils.cpp 2020-06-02 23:18:03 UTC (rev 262460)
@@ -964,17 +964,17 @@
// From GL_IMG_texture_compression_pvrtc
// | Internal format | W | H | D | BS |CC| SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | Blend
- AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 8, 8, 1, 256, 3, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 16, 8, 1, 256, 3, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 8, 8, 1, 256, 4, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 16, 8, 1, 256, 4, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG, 4, 4, 1, 64, 3, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG, 8, 4, 1, 64, 3, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, 4, 4, 1, 64, 4, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 8, 4, 1, 64, 4, false, RequireExt<&Extensions::compressedTexturePVRTC>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
// From GL_EXT_pvrtc_sRGB
// | Internal format | W | H | D | BS |CC| SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | Blend
- AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT, 16, 8, 1, 256, 3, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT, 8, 8, 1, 256, 3, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT, 16, 8, 1, 256, 4, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
- AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT, 8, 8, 1, 256, 4, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT, 8, 4, 1, 64, 3, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT, 4, 4, 1, 64, 3, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT, 8, 4, 1, 64, 4, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, NeverSupported, NeverSupported);
+ AddCompressedFormat(&map, GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT, 4, 4, 1, 64, 4, true, RequireExt<&Extensions::compressedTexturePVRTCsRGB>, AlwaysSupported, NeverSupported, 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
@@ -1311,14 +1311,48 @@
CheckedNumeric<GLuint> checkedDepth(size.depth);
CheckedNumeric<GLuint> checkedBlockWidth(compressedBlockWidth);
CheckedNumeric<GLuint> checkedBlockHeight(compressedBlockHeight);
+ GLuint minBlockWidth, minBlockHeight;
+ getCompressedImageMinBlocks(&minBlockWidth, &minBlockHeight);
ASSERT(compressed);
auto numBlocksWide = (checkedWidth + checkedBlockWidth - 1u) / checkedBlockWidth;
auto numBlocksHigh = (checkedHeight + checkedBlockHeight - 1u) / checkedBlockHeight;
- auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth;
+ if (numBlocksWide.IsValid() && numBlocksWide.ValueOrDie() < minBlockWidth)
+ numBlocksWide = minBlockWidth;
+ if (numBlocksHigh.IsValid() && numBlocksHigh.ValueOrDie() < minBlockHeight)
+ numBlocksHigh = minBlockHeight;
+ auto bytes = numBlocksWide * numBlocksHigh * pixelBytes * checkedDepth;
return CheckedMathResult(bytes, resultOut);
}
+void InternalFormat::getCompressedImageMinBlocks(GLuint* minBlockWidth, GLuint* minBlockHeight) const
+{
+ *minBlockWidth = 0;
+ *minBlockHeight = 0;
+
+ // Per the specification, a PVRTC block needs information from the 3 nearest blocks.
+ // GL_IMG_texture_compression_pvrtc specifies the minimum size requirement in pixels, but
+ // ANGLE's texture tables are written in terms of blocks. The 4BPP formats use 4x4 blocks, and
+ // the 2BPP formats, 8x4 blocks. Therefore, both kinds of formats require a minimum of 2x2 blocks.
+ switch (internalFormat)
+ {
+ case GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG:
+ case GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG:
+ case GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:
+ case GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:
+ case GL_COMPRESSED_SRGB_PVRTC_2BPPV1_EXT:
+ case GL_COMPRESSED_SRGB_PVRTC_4BPPV1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_PVRTC_2BPPV1_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_PVRTC_4BPPV1_EXT:
+ *minBlockWidth = 2;
+ *minBlockHeight = 2;
+ break;
+
+ default:
+ break;
+ }
+}
+
bool InternalFormat::computeSkipBytes(GLenum formatType,
GLuint rowPitch,
GLuint depthPitch,