Key the format tables on internal format and type.
Keying the format tables on internal format alone is not enough to fully
validate the unsized formats which require additional type information.
This CL has no functional changes, it just splits the tables and updates
the calls to GetInternalFormat info to provide type information when the
format is not sized.
BUG=angleproject:1523
BUG=angleproject:1958
BUG=angleproject:1228
Change-Id: I37e5201e7f54fa8eca01b8a6e64b11a6b94484e7
Reviewed-on: https://chromium-review.googlesource.com/468449
Commit-Queue: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index f13a596..f9c8c6a 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -208,8 +208,7 @@
bool IsValidCopyTextureFormat(Context *context, GLenum internalFormat)
{
- const InternalFormat &internalFormatInfo = GetInternalFormatInfo(internalFormat);
- switch (internalFormatInfo.format)
+ switch (GetUnsizedFormat(internalFormat))
{
case GL_ALPHA:
case GL_LUMINANCE:
@@ -421,8 +420,8 @@
if (isSubImage)
{
- GLenum textureFormat = texture->getFormat(target, level).asSized();
- if (textureFormat == GL_NONE)
+ const InternalFormat &textureInternalFormat = *texture->getFormat(target, level).info;
+ if (textureInternalFormat.internalFormat == GL_NONE)
{
context->handleError(Error(GL_INVALID_OPERATION, "Texture level does not exist."));
return false;
@@ -430,7 +429,8 @@
if (format != GL_NONE)
{
- if (gl::GetSizedInternalFormat(format, type) != textureFormat)
+ if (GetInternalFormatInfo(format, type).sizedInternalFormat !=
+ textureInternalFormat.sizedInternalFormat)
{
context->handleError(Error(GL_INVALID_OPERATION));
return false;
@@ -463,7 +463,8 @@
if (isCompressed)
{
GLenum actualInternalFormat =
- isSubImage ? texture->getFormat(target, level).asSized() : internalformat;
+ isSubImage ? texture->getFormat(target, level).info->sizedInternalFormat
+ : internalformat;
switch (actualInternalFormat)
{
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
@@ -824,7 +825,7 @@
return false;
}
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalformat);
if (formatInfo.format == GL_NONE || formatInfo.type == GL_NONE)
{
context->handleError(Error(GL_INVALID_ENUM));
@@ -1897,7 +1898,7 @@
}
}
- const InternalFormat &formatInfo = GetInternalFormatInfo(internalformat);
+ const InternalFormat &formatInfo = GetSizedInternalFormatInfo(internalformat);
auto blockSizeOrErr =
formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1));
if (blockSizeOrErr.isError())
@@ -1985,7 +1986,7 @@
}
}
- const InternalFormat &formatInfo = GetInternalFormatInfo(format);
+ const InternalFormat &formatInfo = GetSizedInternalFormatInfo(format);
auto blockSizeOrErr =
formatInfo.computeCompressedImageSize(GL_UNSIGNED_BYTE, gl::Extents(width, height, 1));
if (blockSizeOrErr.isError())
@@ -3033,7 +3034,7 @@
return false;
}
- const gl::Format &sourceFormat = source->getFormat(sourceTarget, 0);
+ const gl::InternalFormat &sourceFormat = *source->getFormat(sourceTarget, 0).info;
if (!IsValidCopyTextureFormat(context, sourceFormat.format))
{
context->handleError(
@@ -3139,7 +3140,7 @@
}
const gl::Format &sourceFormat = source->getFormat(sourceTarget, 0);
- if (!IsValidCopyTextureFormat(context, sourceFormat.format))
+ if (!IsValidCopyTextureFormat(context, sourceFormat.info->internalFormat))
{
context->handleError(
Error(GL_INVALID_OPERATION, "Source texture internal format is invalid."));
@@ -3168,7 +3169,7 @@
return false;
}
- const gl::Format &destFormat = dest->getFormat(destTarget, 0);
+ const gl::InternalFormat &destFormat = *dest->getFormat(destTarget, 0).info;
if (!IsValidCopyTextureDestinationFormatType(context, destFormat.format, destFormat.type))
{
context->handleError(