Bug 1676242 - Enforce BPTC/RGTC level 0 => w/h multiple of 4. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D96457
This commit is contained in:
Jeff Gilbert 2020-11-09 22:04:21 +00:00
parent ee30ccbff9
commit 439d12dc7e

View File

@ -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;