diff --git a/dom/canvas/WebGLTextureUpload.cpp b/dom/canvas/WebGLTextureUpload.cpp index cf4d88e0d437..978f4ae6b1a6 100644 --- a/dom/canvas/WebGLTextureUpload.cpp +++ b/dom/canvas/WebGLTextureUpload.cpp @@ -1171,7 +1171,8 @@ void WebGLTexture::CompressedTexImage(bool sub, GLenum imageTarget, break; // Full-only: (The ES3 default) - default: // PVRTC + case webgl::CompressionFamily::ASTC: + case webgl::CompressionFamily::PVRTC: if (offset.x || offset.y || size.x != imageInfo->mWidth || size.y != imageInfo->mHeight) { mContext->ErrorInvalidOperation( @@ -1183,6 +1184,22 @@ void WebGLTexture::CompressedTexImage(bool sub, GLenum imageTarget, } } + switch (usage->format->compression->family) { + case webgl::CompressionFamily::BPTC: + case webgl::CompressionFamily::RGTC: + if (level == 0) { + if (size.x % 4 != 0 || size.y % 4 != 0) { + mContext->ErrorInvalidOperation( + "For level == 0, width and height must be multiples of 4."); + return; + } + } + break; + + default: + break; + } + if (!ValidateCompressedTexUnpack(mContext, size, usage->format, imageSize)) return;