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+
89114namespace 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
16581691void InitializeFrontendFeatures (const FunctionsGL *functions, angle::FrontendFeatures *features)
0 commit comments