Commit e24032a2 by Geoff Lang Committed by Commit Bot

The 'format' of unsized SRGB internal formats should be SRGB too.

EXT_sRGB requires calling TexImage with SRGB as the 'format' parameter. This was causing issues when we would take an InternalFormat struct representing an unsized sRGB format and be unable to use it's format member to make GL calls without transforming it. BUG=693090 Change-Id: I8b9baf2591a998a0088e5275f42ffc568e37100d Reviewed-on: https://chromium-review.googlesource.com/984965 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 1d97a4d0
...@@ -850,23 +850,23 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -850,23 +850,23 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported); AddRGBAFormat(&map, GL_RGBA16_SNORM_EXT, true, 16, 16, 16, 16, 0, GL_RGBA, GL_SHORT, GL_SIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, NeverSupported, AlwaysSupported);
// Unsized formats // Unsized formats
// | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable | // | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Renderable | Filterable |
AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported); AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported);
AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported );
AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported); AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, AlwaysSupported);
AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported );
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, AlwaysSupported, AlwaysSupported); AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, AlwaysSupported, AlwaysSupported);
AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported); AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported);
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported );
AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported); AddRGBAFormat(&map, GL_RGBA, false, 4, 4, 4, 4, 0, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported);
AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported); AddRGBAFormat(&map, GL_RGBA, false, 5, 5, 5, 1, 0, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported);
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported); AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported);
AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported); AddRGBAFormat(&map, GL_RGBA, false, 10, 10, 10, 2, 0, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, GL_UNSIGNED_NORMALIZED, false, RequireES<1, 0>, RequireES<1, 0>, AlwaysSupported);
AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported ); AddRGBAFormat(&map, GL_RGBA, false, 8, 8, 8, 8, 0, GL_RGBA, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported );
AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, NeverSupported, AlwaysSupported); AddRGBAFormat(&map, GL_SRGB, false, 8, 8, 8, 0, 0, GL_SRGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, NeverSupported, AlwaysSupported);
AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_RGBA, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, RequireExt<&Extensions::sRGB>, AlwaysSupported); AddRGBAFormat(&map, GL_SRGB_ALPHA_EXT, false, 8, 8, 8, 8, 0, GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, true, RequireExt<&Extensions::sRGB>, RequireExt<&Extensions::sRGB>, AlwaysSupported);
AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported); AddRGBAFormat(&map, GL_BGRA_EXT, false, 8, 8, 8, 8, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureFormatBGRA8888>, RequireExt<&Extensions::textureFormatBGRA8888>, AlwaysSupported);
// Unsized integer formats // Unsized integer formats
// |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture | Renderable | Filterable | // |Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture | Renderable | Filterable |
......
...@@ -6139,10 +6139,10 @@ bool ValidateGenerateMipmap(Context *context, TextureType target) ...@@ -6139,10 +6139,10 @@ bool ValidateGenerateMipmap(Context *context, TextureType target)
} }
// ES3 and WebGL grant mipmap generation for sRGBA (with alpha) textures but GL_EXT_sRGB does // ES3 and WebGL grant mipmap generation for sRGBA (with alpha) textures but GL_EXT_sRGB does
// not. // not. Differentiate the ES3 format from the extension format by checking if the format is
bool supportsSRGBMipmapGeneration = // sized, GL_EXT_sRGB does not add any sized formats.
context->getClientVersion() >= ES_3_0 || context->getExtensions().webglCompatibility; bool supportsSRGBMipmapGeneration = context->getExtensions().webglCompatibility;
if (!supportsSRGBMipmapGeneration && format.colorEncoding == GL_SRGB) if (!supportsSRGBMipmapGeneration && !format.sized && format.colorEncoding == GL_SRGB)
{ {
ANGLE_VALIDATION_ERR(context, InvalidOperation(), GenerateMipmapNotAllowed); ANGLE_VALIDATION_ERR(context, InvalidOperation(), GenerateMipmapNotAllowed);
return false; return false;
......
...@@ -118,14 +118,7 @@ TEST_P(SRGBTextureTest, SRGBAValidation) ...@@ -118,14 +118,7 @@ TEST_P(SRGBTextureTest, SRGBAValidation)
EXPECT_GL_NO_ERROR(); EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
if (getClientMajorVersion() == 2) EXPECT_GL_ERROR(GL_INVALID_OPERATION);
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
else
{
EXPECT_GL_NO_ERROR();
}
} }
else else
{ {
...@@ -135,6 +128,30 @@ TEST_P(SRGBTextureTest, SRGBAValidation) ...@@ -135,6 +128,30 @@ TEST_P(SRGBTextureTest, SRGBAValidation)
glDeleteTextures(1, &tex); glDeleteTextures(1, &tex);
} }
// Test that sized SRGBA formats allow generating mipmaps
TEST_P(SRGBTextureTest, SRGBASizedValidation)
{
// TODO(fjhenigman): Figure out why this fails on Ozone Intel.
ANGLE_SKIP_TEST_IF(IsOzone() && IsIntel() && IsOpenGLES());
// ES3 required for sized SRGB textures
ANGLE_SKIP_TEST_IF(getClientMajorVersion() < 3);
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex);
GLubyte pixel[4] = {0};
glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB8_ALPHA8, 1, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
EXPECT_GL_NO_ERROR();
glGenerateMipmap(GL_TEXTURE_2D);
EXPECT_GL_NO_ERROR();
}
TEST_P(SRGBTextureTest, SRGBARenderbuffer) TEST_P(SRGBTextureTest, SRGBARenderbuffer)
{ {
bool supported = extensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3; bool supported = extensionEnabled("GL_EXT_sRGB") || getClientMajorVersion() == 3;
......
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