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/validationES.cpp b/src/libANGLE/validationES.cpp
index 3306732..b0ffad2 100644
--- a/src/libANGLE/validationES.cpp
+++ b/src/libANGLE/validationES.cpp
@@ -292,11 +292,10 @@
GLenum currentFormat = framebuffer->getImplementationColorReadFormat();
GLenum currentType = framebuffer->getImplementationColorReadType();
- GLenum currentInternalFormat = readBuffer->getFormat().asSized();
+ GLenum currentComponentType = readBuffer->getFormat().info->componentType;
- const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(currentInternalFormat);
bool validFormatTypeCombination =
- ValidReadPixelsFormatType(context, internalFormatInfo.componentType, format, type);
+ ValidReadPixelsFormatType(context, currentComponentType, format, type);
if (!(currentFormat == format && currentType == type) && !validFormatTypeCombination)
{
@@ -315,8 +314,7 @@
// .. the data would be packed to the buffer object such that the memory writes required
// would exceed the data store size.
- GLenum sizedInternalFormat = GetSizedInternalFormat(format, type);
- const InternalFormat &formatInfo = GetInternalFormatInfo(sizedInternalFormat);
+ const InternalFormat &formatInfo = GetInternalFormatInfo(format, type);
const gl::Extents size(width, height, 1);
const auto &pack = context->getGLState().getPackState();
@@ -1569,7 +1567,8 @@
}
const gl::Framebuffer *framebuffer = context->getGLState().getReadFramebuffer();
- GLenum colorbufferFormat = framebuffer->getReadColorbuffer()->getFormat().asSized();
+ GLenum colorbufferFormat =
+ framebuffer->getReadColorbuffer()->getFormat().info->sizedInternalFormat;
const auto &formatInfo = *textureFormat.info;
// [OpenGL ES 2.0.24] table 3.9
@@ -2076,7 +2075,7 @@
GLsizei width,
GLsizei height)
{
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat);
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(internalFormat);
if (!formatInfo.compressed)
{
return false;
@@ -2122,8 +2121,7 @@
// ...the data would be unpacked from the buffer object such that the memory reads required
// would exceed the data store size.
- GLenum sizedFormat = GetSizedInternalFormat(internalFormat, type);
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(sizedFormat);
+ const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalFormat, type);
const gl::Extents size(width, height, depth);
const auto &unpack = context->getGLState().getUnpackState();
@@ -2362,8 +2360,8 @@
// ANGLE_framebuffer_multisample does not explicitly state that the internal format must be
// sized but it does state that the format must be in the ES2.0 spec table 4.5 which contains
// only sized internal formats.
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(convertedInternalFormat);
- if (formatInfo.pixelBytes == 0)
+ const gl::InternalFormat &formatInfo = gl::GetSizedInternalFormatInfo(convertedInternalFormat);
+ if (formatInfo.internalFormat == GL_NONE)
{
context->handleError(Error(GL_INVALID_ENUM));
return false;
@@ -3512,7 +3510,8 @@
return false;
}
- const gl::InternalFormat &formatInfo = gl::GetInternalFormatInfo(internalformat);
+ const gl::InternalFormat &formatInfo =
+ gl::GetInternalFormatInfo(internalformat, GL_UNSIGNED_BYTE);
if (formatInfo.depthBits > 0)
{
@@ -4507,7 +4506,8 @@
return false;
}
- const TextureCaps &textureCaps = context->getTextureCaps().get(image->getFormat().asSized());
+ const TextureCaps &textureCaps =
+ context->getTextureCaps().get(image->getFormat().info->sizedInternalFormat);
if (!textureCaps.texturable)
{
context->handleError(Error(GL_INVALID_OPERATION,
@@ -4545,7 +4545,8 @@
return false;
}
- const TextureCaps &textureCaps = context->getTextureCaps().get(image->getFormat().asSized());
+ const TextureCaps &textureCaps =
+ context->getTextureCaps().get(image->getFormat().info->sizedInternalFormat);
if (!textureCaps.renderable)
{
context->handleError(Error(
@@ -5055,7 +5056,7 @@
GLenum baseTarget = (target == GL_TEXTURE_CUBE_MAP) ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : target;
const auto &format = texture->getFormat(baseTarget, effectiveBaseLevel);
- const TextureCaps &formatCaps = context->getTextureCaps().get(format.asSized());
+ const TextureCaps &formatCaps = context->getTextureCaps().get(format.info->sizedInternalFormat);
// GenerateMipmap should not generate an INVALID_OPERATION for textures created with
// unsized formats or that are color renderable and filterable. Since we do not track if