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/validationES3.cpp b/src/libGLESv2/validationES3.cpp
index 9e58ddc..a44d660 100644
--- a/src/libGLESv2/validationES3.cpp
+++ b/src/libGLESv2/validationES3.cpp
@@ -21,21 +21,6 @@
namespace gl
{
-static bool validCompressedImageSize(GLsizei width, GLsizei height)
-{
- if (width != 1 && width != 2 && width % 4 != 0)
- {
- return false;
- }
-
- if (height != 1 && height != 2 && height % 4 != 0)
- {
- return false;
- }
-
- return true;
-}
-
bool ValidateES3TexImageParameters(gl::Context *context, GLenum target, GLint level, GLint internalformat, bool isCompressed, bool isSubImage,
GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth,
GLint border, GLenum format, GLenum type, const GLvoid *pixels)
@@ -46,11 +31,6 @@
return gl::error(GL_INVALID_VALUE, false);
}
- if (isCompressed && !validCompressedImageSize(width, height))
- {
- return gl::error(GL_INVALID_OPERATION, false);
- }
-
// Verify zero border
if (border != 0)
{
@@ -178,6 +158,11 @@
GLenum actualInternalFormat = isSubImage ? textureInternalFormat : internalformat;
if (isCompressed)
{
+ if (!ValidCompressedImageSize(context, actualInternalFormat, width, height))
+ {
+ return gl::error(GL_INVALID_OPERATION, false);
+ }
+
if (!gl::IsFormatCompressed(actualInternalFormat, context->getClientVersion()))
{
return gl::error(GL_INVALID_ENUM, false);