Fix validation of LUMA formats in glGenerateMipmap.
BUG=angle:673
Change-Id: I6c106962d8a50ed8f69d208c537166a30e4f92c6
Reviewed-on: https://chromium-review.googlesource.com/203292
Reviewed-by: Shannon Woods <shannonwoods@chromium.org>
Tested-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index 64ec9e7..791332b 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -1996,17 +1996,22 @@
}
GLenum internalFormat = texture->getBaseLevelInternalFormat();
-
- // Internally, all texture formats are sized so checking if the format
- // is color renderable and filterable will not fail.
-
const gl::TextureCaps &formatCaps = context->getCaps().textureCaps.get(internalFormat);
- bool validRenderable = (formatCaps.colorRendering ||
- gl::IsSizedInternalFormat(internalFormat, context->getClientVersion()));
+ // 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
+ // the texture was created with sized or unsized format (only sized formats are stored),
+ // it is not possible to make sure the the LUMA formats can generate mipmaps (they should
+ // be able to) because they aren't color renderable. Simply do a special case for LUMA
+ // textures since they're the only texture format that can be created with unsized formats
+ // that is not color renderable. New unsized formats are unlikely to be added, since ES2
+ // was the last version to use add them.
+ bool isLUMA = internalFormat == GL_LUMINANCE8_EXT ||
+ internalFormat == GL_LUMINANCE8_ALPHA8_EXT ||
+ internalFormat == GL_ALPHA8_EXT;
- if (formatCaps.depthRendering || gl::IsFormatCompressed(internalFormat, context->getClientVersion()) ||
- !formatCaps.filtering || !validRenderable)
+ if (formatCaps.depthRendering || !formatCaps.filtering || (!formatCaps.colorRendering && !isLUMA) ||
+ gl::IsFormatCompressed(internalFormat, context->getClientVersion()))
{
return gl::error(GL_INVALID_OPERATION);
}