Validate compressed texture dimensions based on the per-format compressed block sizes rather than hard-coded values.
TRAC #23630
Signed-off-by: Jamie Madill
Signed-off-by: Shannon Woods
diff --git a/src/libGLESv2/validationES.cpp b/src/libGLESv2/validationES.cpp
index f5e447c..e72dd0d 100644
--- a/src/libGLESv2/validationES.cpp
+++ b/src/libGLESv2/validationES.cpp
@@ -62,6 +62,25 @@
return true;
}
+bool ValidCompressedImageSize(const gl::Context *context, GLint internalFormat, GLsizei width, GLsizei height)
+{
+ GLuint clientVersion = context->getClientVersion();
+ if (!IsFormatCompressed(internalFormat, clientVersion))
+ {
+ return false;
+ }
+
+ GLint blockWidth = GetCompressedBlockWidth(internalFormat, clientVersion);
+ GLint blockHeight = GetCompressedBlockHeight(internalFormat, clientVersion);
+ if (width < 0 || (width > blockWidth && width % blockWidth != 0) ||
+ height < 0 || (height > blockHeight && height % blockHeight != 0))
+ {
+ return false;
+ }
+
+ return true;
+}
+
bool ValidateRenderbufferStorageParameters(const gl::Context *context, GLenum target, GLsizei samples,
GLenum internalformat, GLsizei width, GLsizei height,
bool angleExtension)