Commit e2c00841 by Jiang Committed by Commit Bot

GenerateMipmaps should generate INVALID_OPERATION in ES 2.0 with EXT_sRGB

According to the OpenGL extension spec EXT_sRGB.txt, EXT_SRGB is based on ES 2.0 and generateMipmap is not allowed if texture format is SRGB_EXT or SRGB_ALPHA_EXT. BUG=769989 TEST=SRGBTextureTest.SRGBValidation* TEST=SRGBTextureTest.SRGBAValidation* Change-Id: Ic51da224fcd318187865a44630af6fca5c3ad2de Reviewed-on: https://chromium-review.googlesource.com/1137924Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Yizhou Jiang <yizhou.jiang@intel.com>
parent 04f0f133
...@@ -6129,11 +6129,9 @@ bool ValidateGenerateMipmap(Context *context, TextureType target) ...@@ -6129,11 +6129,9 @@ bool ValidateGenerateMipmap(Context *context, TextureType target)
return false; return false;
} }
// ES3 and WebGL grant mipmap generation for sRGBA (with alpha) textures but GL_EXT_sRGB does // According to the OpenGL extension spec EXT_sRGB.txt, EXT_SRGB is based on ES 2.0 and
// not. Differentiate the ES3 format from the extension format by checking if the format is // generateMipmap is not allowed if texture format is SRGB_EXT or SRGB_ALPHA_EXT.
// sized, GL_EXT_sRGB does not add any sized formats. if (context->getClientVersion() < Version(3, 0) && format.colorEncoding == GL_SRGB)
bool supportsSRGBMipmapGeneration = context->getExtensions().webglCompatibility;
if (!supportsSRGBMipmapGeneration && !format.sized && format.colorEncoding == GL_SRGB)
{ {
ANGLE_VALIDATION_ERR(context, InvalidOperation(), GenerateMipmapNotAllowed); ANGLE_VALIDATION_ERR(context, InvalidOperation(), GenerateMipmapNotAllowed);
return false; return false;
......
...@@ -66,6 +66,8 @@ class SRGBTextureTest : public ANGLETest ...@@ -66,6 +66,8 @@ class SRGBTextureTest : public ANGLETest
GLint mTextureLocation = -1; GLint mTextureLocation = -1;
}; };
// GenerateMipmaps should generate INVALID_OPERATION in ES 2.0 / WebGL 1.0 with EXT_sRGB.
// https://bugs.chromium.org/p/chromium/issues/detail?id=769989
TEST_P(SRGBTextureTest, SRGBValidation) TEST_P(SRGBTextureTest, SRGBValidation)
{ {
// TODO(fjhenigman): Figure out why this fails on Ozone Intel. // TODO(fjhenigman): Figure out why this fails on Ozone Intel.
...@@ -87,7 +89,14 @@ TEST_P(SRGBTextureTest, SRGBValidation) ...@@ -87,7 +89,14 @@ TEST_P(SRGBTextureTest, SRGBValidation)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
EXPECT_GL_ERROR(GL_INVALID_OPERATION); if (getClientMajorVersion() < 3)
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
else
{
EXPECT_GL_NO_ERROR();
}
} }
else else
{ {
...@@ -118,7 +127,14 @@ TEST_P(SRGBTextureTest, SRGBAValidation) ...@@ -118,7 +127,14 @@ TEST_P(SRGBTextureTest, SRGBAValidation)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
EXPECT_GL_ERROR(GL_INVALID_OPERATION); if (getClientMajorVersion() < 3)
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
else
{
EXPECT_GL_NO_ERROR();
}
} }
else else
{ {
......
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