Commit 68f92942 by Kenneth Russell Committed by Commit Bot

Emulate GL_EXT_sRGB on ES 3.0 devices without native support.

Translate the extension's internal formats and formats to values valid in core ES 3.0. Bug: angleproject:4655 Change-Id: Ie47d01fb2ebca7bab5058812c9f4217523f784a0 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2213262 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9047ce5b
...@@ -540,12 +540,24 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions, ...@@ -540,12 +540,24 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions,
// Workaround Adreno driver not supporting unsized EXT_texture_rg formats // Workaround Adreno driver not supporting unsized EXT_texture_rg formats
result = internalFormat.sizedInternalFormat; result = internalFormat.sizedInternalFormat;
} }
else if (features.unsizedsRGBReadPixelsDoesntTransform.enabled && else if (internalFormat.colorEncoding == GL_SRGB)
internalFormat.colorEncoding == GL_SRGB)
{ {
// Work around some Adreno driver bugs that don't read back SRGB data correctly when if (features.unsizedsRGBReadPixelsDoesntTransform.enabled)
// it's in unsized SRGB texture formats. {
result = internalFormat.sizedInternalFormat; // Work around some Adreno driver bugs that don't read back SRGB data correctly when
// it's in unsized SRGB texture formats.
result = internalFormat.sizedInternalFormat;
}
else if (!functions->hasGLESExtension("GL_EXT_sRGB"))
{
// Unsized sRGB internal formats are unlikely to be supported by the
// driver. Transform them to sized internal formats.
if (internalFormat.internalFormat == GL_SRGB ||
internalFormat.internalFormat == GL_SRGB_ALPHA_EXT)
{
result = internalFormat.sizedInternalFormat;
}
}
} }
} }
...@@ -585,14 +597,17 @@ static GLenum GetNativeFormat(const FunctionsGL *functions, ...@@ -585,14 +597,17 @@ static GLenum GetNativeFormat(const FunctionsGL *functions,
} }
else if (functions->isAtLeastGLES(gl::Version(3, 0))) else if (functions->isAtLeastGLES(gl::Version(3, 0)))
{ {
if (features.unsizedsRGBReadPixelsDoesntTransform.enabled) // Transform sRGB formats to RGB if either the GLES driver doesn't support GL_EXT_sRGB, or
// to work around Adreno driver bugs reading back unsized sRGB texture data.
if (!functions->hasGLESExtension("GL_EXT_sRGB") ||
features.unsizedsRGBReadPixelsDoesntTransform.enabled)
{ {
if (format == GL_SRGB) if (format == GL_SRGB)
{ {
result = GL_RGB; result = GL_RGB;
} }
if (format == GL_SRGB_ALPHA) if (format == GL_SRGB_ALPHA_EXT)
{ {
result = GL_RGBA; result = GL_RGBA;
} }
......
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