Skip to content

Commit fa9eff3

Browse files
phuangCommit Bot
authored andcommitted
Disable GL_EXT_semaphore_fd for Mesa version < 19.3.5 on AMD GPUs
Bug: chromium:1053516 Change-Id: Idfc271ac70c8ded7d05a258beb4a7578a5a652c3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2062162 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com>
1 parent 123fd97 commit fa9eff3

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

include/platform/FeaturesGL.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ struct FeaturesGL : FeatureSetBase
419419
Feature avoidDXT1sRGBTextureFormat = {
420420
"avoid_dxt1_srgb_texture_format", FeatureCategory::OpenGLWorkarounds,
421421
"Replaces DXT1 sRGB with DXT1 sRGB Alpha as a driver bug workaround.", &members};
422+
423+
// GL_EXT_semaphore_fd doesn't work properly with Mesa 19.3.4 and earlier versions.
424+
Feature disableSemaphoreFd = {"disable_semaphore_fd", FeatureCategory::OpenGLWorkarounds,
425+
"Disable GL_EXT_semaphore_fd extension", &members,
426+
"https://crbug.com/1046462"};
422427
};
423428

424429
inline FeaturesGL::FeaturesGL() = default;

src/libANGLE/renderer/gl/renderergl_utils.cpp

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "libANGLE/renderer/gl/renderergl_utils.h"
1111

12+
#include <array>
1213
#include <limits>
1314

1415
#include "common/mathutil.h"
@@ -86,6 +87,30 @@ uint32_t GetDeviceID(const FunctionsGL *functions)
8687
return 0;
8788
}
8889

90+
bool IsMesa(const FunctionsGL *functions, std::array<int, 3> *version)
91+
{
92+
ASSERT(version);
93+
94+
if (functions->standard != STANDARD_GL_DESKTOP)
95+
{
96+
return false;
97+
}
98+
99+
std::string nativeVersionString(
100+
reinterpret_cast<const char *>(functions->getString(GL_VERSION)));
101+
size_t pos = nativeVersionString.find("Mesa");
102+
if (pos == std::string::npos)
103+
{
104+
return false;
105+
}
106+
107+
int *data = version->data();
108+
data[0] = data[1] = data[2] = 0;
109+
std::sscanf(nativeVersionString.c_str() + pos, "Mesa %d.%d.%d", data, data + 1, data + 2);
110+
111+
return true;
112+
}
113+
89114
namespace nativegl_gl
90115
{
91116

@@ -1471,8 +1496,9 @@ void GenerateCaps(const FunctionsGL *functions,
14711496
functions->hasGLESExtension("GL_EXT_semaphore");
14721497
extensions->memoryObjectFd = functions->hasGLExtension("GL_EXT_memory_object_fd") ||
14731498
functions->hasGLESExtension("GL_EXT_memory_object_fd");
1474-
extensions->semaphoreFd = functions->hasGLExtension("GL_EXT_semaphore_fd") ||
1475-
functions->hasGLESExtension("GL_EXT_semaphore_fd");
1499+
extensions->semaphoreFd = !features.disableSemaphoreFd.enabled &&
1500+
(functions->hasGLExtension("GL_EXT_semaphore_fd") ||
1501+
functions->hasGLESExtension("GL_EXT_semaphore_fd"));
14761502
extensions->gpuShader5EXT = functions->isAtLeastGL(gl::Version(4, 0)) ||
14771503
functions->isAtLeastGLES(gl::Version(3, 2)) ||
14781504
functions->hasGLExtension("GL_ARB_gpu_shader5") ||
@@ -1488,6 +1514,9 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
14881514
bool isNvidia = IsNvidia(vendor);
14891515
bool isQualcomm = IsQualcomm(vendor);
14901516

1517+
std::array<int, 3> mesaVersion = {0, 0, 0};
1518+
bool isMesa = IsMesa(functions, &mesaVersion);
1519+
14911520
// Don't use 1-bit alpha formats on desktop GL with AMD drivers.
14921521
ANGLE_FEATURE_CONDITION(features, avoid1BitAlphaTextureFormats,
14931522
functions->standard == STANDARD_GL_DESKTOP && isAMD);
@@ -1653,6 +1682,10 @@ void InitializeFeatures(const FunctionsGL *functions, angle::FeaturesGL *feature
16531682

16541683
// Workaround for incorrect sampling from DXT1 sRGB textures in Intel OpenGL on Windows.
16551684
ANGLE_FEATURE_CONDITION(features, avoidDXT1sRGBTextureFormat, IsWindows() && isIntel);
1685+
1686+
ANGLE_FEATURE_CONDITION(
1687+
features, disableSemaphoreFd,
1688+
IsLinux() && isAMD && isMesa && mesaVersion < (std::array<int, 3>{19, 3, 5}));
16561689
}
16571690

16581691
void InitializeFrontendFeatures(const FunctionsGL *functions, angle::FrontendFeatures *features)

0 commit comments

Comments
 (0)