Commit bbb8fc17 by Alexis Hetu Committed by Alexis Hétu

glCompressedTexSub* validation fixes

- Added imageSize validation checks - Added ETC2/EAC specific validations Change-Id: I8671b08caecb7aaff0b42d6843d31738b54d0f5a Reviewed-on: https://swiftshader-review.googlesource.com/14088Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 848aa7fc
......@@ -947,9 +947,9 @@ void CompressedTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yo
return error(validationError);
}
if(width == 0 || height == 0)
if(imageSize != egl::ComputeCompressedSize(width, height, format))
{
return;
return error(GL_INVALID_VALUE);
}
es2::Context *context = es2::getContext();
......@@ -6578,9 +6578,9 @@ void CompressedTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint
return error(validationError);
}
if(width == 0 || height == 0 || depth == 0)
if(imageSize != egl::ComputeCompressedSize(width, height, format) * depth)
{
return;
return error(GL_INVALID_VALUE);
}
es2::Context *context = es2::getContext();
......
......@@ -912,9 +912,39 @@ GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level
return error(validationError);
}
if(width == 0 || height == 0 || depth == 0)
if(imageSize != egl::ComputeCompressedSize(width, height, format) * depth)
{
return;
return error(GL_INVALID_VALUE);
}
bool is_ETC2_EAC = false;
switch(format)
{
case GL_COMPRESSED_R11_EAC:
case GL_COMPRESSED_SIGNED_R11_EAC:
case GL_COMPRESSED_RG11_EAC:
case GL_COMPRESSED_SIGNED_RG11_EAC:
case GL_COMPRESSED_RGB8_ETC2:
case GL_COMPRESSED_SRGB8_ETC2:
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
case GL_COMPRESSED_RGBA8_ETC2_EAC:
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
if(target != GL_TEXTURE_2D_ARRAY)
{
return error(GL_INVALID_OPERATION);
}
if(((width % 4) != 0) || ((height % 4) != 0) ||
((xoffset % 4) != 0) || ((yoffset % 4) != 0))
{
return error(GL_INVALID_OPERATION);
}
is_ETC2_EAC = true;
break;
default:
break;
}
es2::Context *context = es2::getContext();
......@@ -934,6 +964,15 @@ GL_APICALL void GL_APIENTRY glCompressedTexSubImage3D(GLenum target, GLint level
return error(validationError);
}
if(is_ETC2_EAC)
{
if(((width + xoffset) != texture->getWidth(target, level)) ||
((height + yoffset) != texture->getHeight(target, level)))
{
return error(GL_INVALID_OPERATION);
}
}
texture->subImageCompressed(level, xoffset, yoffset, zoffset, width, height, depth, format, imageSize, data);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment