Commit 011e0ad1 by Kenneth Russell Committed by Commit Bot

Promote RGBA4444 and RGB565 to RGB[A]8 on macOS with AMD GPUs.

There are bugs in Apple's OpenGL driver when uploading to textures of these formats via pixel buffer objects. Because automatic graphics switching might activate the AMD GPU at any time, use this workaround on dual-GPU MacBook Pros even if the Intel GPU is active. Fixes the following WebGL 2.0 conformance tests: deqp/functional/gles3/texturespecification/ teximage2d_pbo_2d_00.html teximage2d_pbo_2d_01.html texsubimage2d_pbo_2d_00.html texsubimage2d_pbo_2d_01.html texsubimage2d_pbo_cube_01.html Bug: angleproject:5469 Change-Id: I7d65dc5f664159b4b59d46400a8d9c492f67040b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2595245 Commit-Queue: Kenneth Russell <kbr@chromium.org> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 653f6196
...@@ -505,6 +505,13 @@ struct FeaturesGL : FeatureSetBase ...@@ -505,6 +505,13 @@ struct FeaturesGL : FeatureSetBase
"set_zero_level_before_generating_mipmap", FeatureCategory::OpenGLWorkarounds, "set_zero_level_before_generating_mipmap", FeatureCategory::OpenGLWorkarounds,
"glGenerateMipmap fails if the zero texture level is not set on some Mac drivers.", "glGenerateMipmap fails if the zero texture level is not set on some Mac drivers.",
&members}; &members};
// On macOS with AMD GPUs, packed color formats like RGB565 and RGBA4444 are buggy. Promote them
// to 8 bit per channel formats.
Feature promotePackedFormatsTo8BitPerChannel = {
"promote_packed_formats_to_8_bit_per_channel", FeatureCategory::OpenGLWorkarounds,
"Packed color formats are buggy on Macs with AMD GPUs", &members,
"http://anglebug.com/5469"};
}; };
inline FeaturesGL::FeaturesGL() = default; inline FeaturesGL::FeaturesGL() = default;
......
...@@ -495,16 +495,18 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions, ...@@ -495,16 +495,18 @@ static GLenum GetNativeInternalFormat(const FunctionsGL *functions,
result = GL_RGBA8; result = GL_RGBA8;
} }
if (features.rgba4IsNotSupportedForColorRendering.enabled && if (internalFormat.sizedInternalFormat == GL_RGBA4 &&
internalFormat.sizedInternalFormat == GL_RGBA4) (features.rgba4IsNotSupportedForColorRendering.enabled ||
features.promotePackedFormatsTo8BitPerChannel.enabled))
{ {
// Use an 8-bit format instead // Use an 8-bit format instead
result = GL_RGBA8; result = GL_RGBA8;
} }
if (internalFormat.sizedInternalFormat == GL_RGB565 && if (internalFormat.sizedInternalFormat == GL_RGB565 &&
!functions->isAtLeastGL(gl::Version(4, 1)) && ((!functions->isAtLeastGL(gl::Version(4, 1)) &&
!functions->hasGLExtension("GL_ARB_ES2_compatibility")) !functions->hasGLExtension("GL_ARB_ES2_compatibility")) ||
features.promotePackedFormatsTo8BitPerChannel.enabled))
{ {
// GL_RGB565 is required for basic ES2 functionality but was not added to desktop GL // GL_RGB565 is required for basic ES2 functionality but was not added to desktop GL
// until 4.1. // until 4.1.
......
...@@ -1631,6 +1631,7 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -1631,6 +1631,7 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
bool isNvidia = IsNvidia(vendor); bool isNvidia = IsNvidia(vendor);
bool isQualcomm = IsQualcomm(vendor); bool isQualcomm = IsQualcomm(vendor);
bool isVMWare = IsVMWare(vendor); bool isVMWare = IsVMWare(vendor);
bool hasAMD = systemInfo.hasAMDGPU();
std::array<int, 3> mesaVersion = {0, 0, 0}; std::array<int, 3> mesaVersion = {0, 0, 0};
bool isMesa = IsMesa(functions, &mesaVersion); bool isMesa = IsMesa(functions, &mesaVersion);
...@@ -1881,6 +1882,8 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature ...@@ -1881,6 +1882,8 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
ANGLE_FEATURE_CONDITION(features, keepBufferShadowCopy, !CanMapBufferForRead(functions)); ANGLE_FEATURE_CONDITION(features, keepBufferShadowCopy, !CanMapBufferForRead(functions));
ANGLE_FEATURE_CONDITION(features, setZeroLevelBeforeGenerateMipmap, IsApple()); ANGLE_FEATURE_CONDITION(features, setZeroLevelBeforeGenerateMipmap, IsApple());
ANGLE_FEATURE_CONDITION(features, promotePackedFormatsTo8BitPerChannel, IsApple() && hasAMD);
} }
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