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; mDriverType = angle::GLESDriverType::SystemWGL;
#else #else
mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion); mGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion);
mEntryPointsLib.reset( mEntryPointsLib.reset(angle::OpenSharedLibraryWithExtension(
angle::OpenSharedLibraryWithExtension(angle::GetNativeEGLLibraryNameWithExtension())); angle::GetNativeEGLLibraryNameWithExtension(), angle::SearchType::SystemDir));
mDriverType = angle::GLESDriverType::SystemEGL; mDriverType = angle::GLESDriverType::SystemEGL;
#endif // defined(ANGLE_PLATFORM_WINDOWS) #endif // defined(ANGLE_PLATFORM_WINDOWS)
} }

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

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

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

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

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

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

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

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

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

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

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

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