Add SearchType to OpenSharedLibraryWithExtension.

This fixes a bug in SystemInfo_vulkan where we were using the
System search path for the Vulkan loader when we prefer using the
custom ANGLE loader.

Bug: chromium:1219969
Change-Id: Iedf0fd11fe9ed8cc020b445ea9e12a7936937361
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2988791
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
This commit is contained in:
Jamie Madill 2021-06-25 09:10:42 -04:00 коммит произвёл Angle LUCI CQ
Родитель 971ba359fb
Коммит 18e99f4a2b
8 изменённых файлов: 20 добавлений и 18 удалений

Просмотреть файл

@ -120,8 +120,8 @@ SampleApplication::SampleApplication(std::string name,
mDriverType = angle::GLESDriverType::SystemWGL;
#else
mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion);
mEntryPointsLib.reset(
angle::OpenSharedLibraryWithExtension(angle::GetNativeEGLLibraryNameWithExtension()));
mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension(
angle::GetNativeEGLLibraryNameWithExtension(), angle::SearchType::SystemDir));
mDriverType = angle::GLESDriverType::SystemEGL;
#endif // defined(ANGLE_PLATFORM_WINDOWS)
}

Просмотреть файл

@ -79,7 +79,7 @@ enum class SearchType
};
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType);
Library *OpenSharedLibraryWithExtension(const char *libraryName);
Library *OpenSharedLibraryWithExtension(const char *libraryName, SearchType searchType);
// Returns true if the process is currently being debugged.
bool IsDebuggerAttached();

Просмотреть файл

@ -107,6 +107,12 @@ class PosixLibrary : public Library
};
Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
{
std::string nameWithExt = std::string(libraryName) + "." + GetSharedLibraryExtension();
return OpenSharedLibraryWithExtension(nameWithExt.c_str(), searchType);
}
Library *OpenSharedLibraryWithExtension(const char *libraryName, SearchType searchType)
{
std::string directory;
if (searchType == SearchType::ApplicationDir)
@ -125,17 +131,12 @@ Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
extraFlags = RTLD_NOLOAD;
}
std::string fullPath = directory + libraryName + "." + GetSharedLibraryExtension();
std::string fullPath = directory + libraryName;
#if ANGLE_PLATFORM_IOS
// On iOS, dlopen needs a suffix on the framework name to work.
fullPath = fullPath + "/" + libraryName;
#endif
return new PosixLibrary(fullPath, extraFlags);
}
Library *OpenSharedLibraryWithExtension(const char *libraryName)
{
return new PosixLibrary(libraryName, 0);
return new PosixLibrary(libraryName, extraFlags);
}
bool IsDirectory(const char *filename)

Просмотреть файл

@ -96,8 +96,8 @@ Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
}
}
Library *OpenSharedLibraryWithExtension(const char *libraryName)
Library *OpenSharedLibraryWithExtension(const char *libraryName, SearchType searchType)
{
return new Win32Library(libraryName, SearchType::SystemDir);
return new Win32Library(libraryName, searchType);
}
} // namespace angle

Просмотреть файл

@ -47,7 +47,7 @@ class VulkanLibrary final : NonCopyable
{
for (const char *libraryName : kLibVulkanNames)
{
mLibVulkan = OpenSharedLibraryWithExtension(libraryName);
mLibVulkan = OpenSharedLibraryWithExtension(libraryName, SearchType::ApplicationDir);
if (mLibVulkan)
{
if (mLibVulkan->getNative())

Просмотреть файл

@ -605,8 +605,8 @@ ANGLERenderTest::ANGLERenderTest(const std::string &name,
case angle::GLESDriverType::SystemEGL:
#if defined(ANGLE_USE_UTIL_LOADER) && !defined(ANGLE_PLATFORM_WINDOWS)
mGLWindow = EGLWindow::New(testParams.majorVersion, testParams.minorVersion);
mEntryPointsLib.reset(
angle::OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension(
GetNativeEGLLibraryNameWithExtension(), SearchType::SystemDir));
#else
std::cerr << "Not implemented." << std::endl;
mSkipTest = true;

Просмотреть файл

@ -1488,8 +1488,8 @@ Library *ANGLETestEnvironment::GetSystemEGLLibrary()
#if defined(ANGLE_USE_UTIL_LOADER)
if (!gSystemEGLLibrary)
{
gSystemEGLLibrary.reset(
OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
gSystemEGLLibrary.reset(OpenSharedLibraryWithExtension(
GetNativeEGLLibraryNameWithExtension(), SearchType::SystemDir));
}
#endif // defined(ANGLE_USE_UTIL_LOADER)
return gSystemEGLLibrary.get();

Просмотреть файл

@ -81,7 +81,8 @@ bool IsSystemEGLConfigSupported(const PlatformParameters &param, OSWindow *osWin
#if defined(ANGLE_USE_UTIL_LOADER)
std::unique_ptr<angle::Library> eglLibrary;
eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension()));
eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension(),
SearchType::SystemDir));
EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
ConfigParameters configParams;