Commit 81ee4d29 by shrekshao Committed by Commit Bot

Workaround EXT_texture_norm16 for OpenGL ES drivers

Implement a workaround for widespread bugs calling glReadPixels with RGBA/UNSIGNED_SHORT against R16/RG16 color attachments. Read back the data using the GL_IMPLEMENTATION_COLOR_READ_FORMAT, and then rearrange the read back pixels to fit the RGBA layout. Also skip RGB16/RGB16_SNORM texture sample test on Nexus 5X/Nexus 6P due to a another driver bug. Bug: chromium:1000354, angleproject:4214, angleproject:4215, angleproject:4245 Change-Id: Iedea6f4136878cac5ad0dec3757c77b73502e1cd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1952166Reviewed-by: 's avatarKenneth Russell <kbr@chromium.org> Commit-Queue: Shrek Shao <shrekshao@google.com>
parent de97fb4a
...@@ -386,6 +386,14 @@ struct FeaturesGL : FeatureSetBase ...@@ -386,6 +386,14 @@ struct FeaturesGL : FeatureSetBase
"All Mac drivers do not handle struct scopes correctly. This workaround overwrites a struct" "All Mac drivers do not handle struct scopes correctly. This workaround overwrites a struct"
"name with a unique prefix.", "name with a unique prefix.",
&members, "http://crbug.com/403957"}; &members, "http://crbug.com/403957"};
// Quite some OpenGL ES drivers don't implement readPixels for RGBA/UNSIGNED_SHORT from
// EXT_texture_norm16 correctly
Feature readPixelsUsingImplementationColorReadFormatForNorm16 = {
"read_pixels_using_implementation_color_read_format", FeatureCategory::OpenGLWorkarounds,
"Quite some OpenGL ES drivers don't implement readPixels for RGBA/UNSIGNED_SHORT from "
"EXT_texture_norm16 correctly",
&members, "http://anglebug.com/4214"};
}; };
inline FeaturesGL::FeaturesGL() = default; inline FeaturesGL::FeaturesGL() = default;
......
...@@ -992,8 +992,10 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap() ...@@ -992,8 +992,10 @@ static InternalFormatInfoMap BuildInternalFormatInfoMap()
// | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer | // | Internal format |sized | R | G | B | A |S | Format | Type | Component type | SRGB | Texture supported | Filterable | Texture attachment | Renderbuffer |
AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported); AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_RED, false, 8, 0, 0, 0, 0, GL_RED, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RED, false, 16, 0, 0, 0, 0, GL_RED, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, RequireExt<&Extensions::textureNorm16>, NeverSupported);
AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported); AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureRG>, AlwaysSupported, RequireExt<&Extensions::textureRG>, NeverSupported);
AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_RG, false, 8, 8, 0, 0, 0, GL_RG, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
AddRGBAFormat(&map, GL_RG, false, 16, 16, 0, 0, 0, GL_RG, GL_UNSIGNED_SHORT, GL_UNSIGNED_NORMALIZED, false, RequireExt<&Extensions::textureNorm16>, AlwaysSupported, RequireExt<&Extensions::textureNorm16>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported); AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_UNSIGNED_BYTE, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported); AddRGBAFormat(&map, GL_RGB, false, 5, 6, 5, 0, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, GL_UNSIGNED_NORMALIZED, false, AlwaysSupported, AlwaysSupported, RequireES<2, 0>, NeverSupported);
AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported); AddRGBAFormat(&map, GL_RGB, false, 8, 8, 8, 0, 0, GL_RGB, GL_BYTE, GL_SIGNED_NORMALIZED, false, NeverSupported, NeverSupported, NeverSupported, NeverSupported);
......
...@@ -101,6 +101,7 @@ class FramebufferGL : public FramebufferImpl ...@@ -101,6 +101,7 @@ class FramebufferGL : public FramebufferImpl
angle::Result readPixelsRowByRow(const gl::Context *context, angle::Result readPixelsRowByRow(const gl::Context *context,
const gl::Rectangle &area, const gl::Rectangle &area,
GLenum originalReadFormat,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelPackState &pack, const gl::PixelPackState &pack,
...@@ -108,6 +109,7 @@ class FramebufferGL : public FramebufferImpl ...@@ -108,6 +109,7 @@ class FramebufferGL : public FramebufferImpl
angle::Result readPixelsAllAtOnce(const gl::Context *context, angle::Result readPixelsAllAtOnce(const gl::Context *context,
const gl::Rectangle &area, const gl::Rectangle &area,
GLenum originalReadFormat,
GLenum format, GLenum format,
GLenum type, GLenum type,
const gl::PixelPackState &pack, const gl::PixelPackState &pack,
......
...@@ -655,9 +655,17 @@ static GLenum GetNativeReadType(const FunctionsGL *functions, ...@@ -655,9 +655,17 @@ static GLenum GetNativeReadType(const FunctionsGL *functions,
static GLenum GetNativeReadFormat(const FunctionsGL *functions, static GLenum GetNativeReadFormat(const FunctionsGL *functions,
const angle::FeaturesGL &features, const angle::FeaturesGL &features,
GLenum format) GLenum attachmentReadFormat,
GLenum format,
GLenum type)
{ {
GLenum result = format; GLenum result = format;
if (features.readPixelsUsingImplementationColorReadFormatForNorm16.enabled &&
type == GL_UNSIGNED_SHORT && format == GL_RGBA &&
(attachmentReadFormat == GL_RED || attachmentReadFormat == GL_RG))
{
result = attachmentReadFormat;
}
return result; return result;
} }
...@@ -736,11 +744,12 @@ RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions, ...@@ -736,11 +744,12 @@ RenderbufferFormat GetRenderbufferFormat(const FunctionsGL *functions,
} }
ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions, ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions,
const angle::FeaturesGL &features, const angle::FeaturesGL &features,
GLenum attachmentReadFormat,
GLenum format, GLenum format,
GLenum type) GLenum type)
{ {
ReadPixelsFormat result; ReadPixelsFormat result;
result.format = GetNativeReadFormat(functions, features, format); result.format = GetNativeReadFormat(functions, features, attachmentReadFormat, format, type);
result.type = GetNativeReadType(functions, features, type); result.type = GetNativeReadType(functions, features, type);
return result; return result;
} }
......
...@@ -131,6 +131,7 @@ struct ReadPixelsFormat ...@@ -131,6 +131,7 @@ struct ReadPixelsFormat
}; };
ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions, ReadPixelsFormat GetReadPixelsFormat(const FunctionsGL *functions,
const angle::FeaturesGL &features, const angle::FeaturesGL &features,
GLenum readAttachmentFormat,
GLenum format, GLenum format,
GLenum type); GLenum type);
} // namespace nativegl } // namespace nativegl
......
...@@ -1623,6 +1623,12 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -1623,6 +1623,12 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
// Ported from gpu_driver_bug_list.json (#184) // Ported from gpu_driver_bug_list.json (#184)
ANGLE_FEATURE_CONDITION(features, preAddTexelFetchOffsets, IsApple() && isIntel); ANGLE_FEATURE_CONDITION(features, preAddTexelFetchOffsets, IsApple() && isIntel);
// Workaround for the widespread OpenGL ES driver implementaion bug
ANGLE_FEATURE_CONDITION(features, readPixelsUsingImplementationColorReadFormatForNorm16,
functions->standard == STANDARD_GL_ES &&
functions->isAtLeastGLES(gl::Version(3, 1)) &&
functions->hasGLESExtension("GL_EXT_texture_norm16"));
} }
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features) void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)
......
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