Commit 25b53ceb by Gert Wollny Committed by Commit Bot

Revert "Change to module directory when loading swiftshader ICD."

This reverts commit 3b10dda6. Bug: angleproject:5954 Change-Id: I6199dc099dbf42605bbfc549e39cb6477e67442c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2891771 Commit-Queue: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent 9a219a14
......@@ -107,9 +107,6 @@ config("internal_config") {
if (is_win) {
defines += [ "ANGLE_IS_WIN" ]
if (angle_is_winuwp) {
defines += [ "ANGLE_IS_WINUWP" ]
}
} else if (is_linux || is_chromeos) {
defines += [ "ANGLE_IS_LINUX" ]
}
......
......@@ -19,7 +19,7 @@ namespace angle
std::string GetExecutableName();
std::string GetExecutablePath();
std::string GetExecutableDirectory();
std::string GetModuleDirectory();
std::string GetHelperExecutableDir();
const char *GetSharedLibraryExtension();
const char *GetExecutableExtension();
char GetPathSeparator();
......
......@@ -56,7 +56,7 @@ const char *GetPathSeparatorForEnvironmentVar()
return ":";
}
std::string GetModuleDirectory()
std::string GetHelperExecutableDir()
{
std::string directory;
static int placeholderSymbol = 0;
......@@ -107,7 +107,7 @@ Library *OpenSharedLibrary(const char *libraryName, SearchType searchType)
// On iOS, shared libraries must be loaded from within the app bundle.
directory = GetExecutableDirectory() + "/Frameworks/";
#else
directory = GetModuleDirectory();
directory = GetHelperExecutableDir();
#endif
}
......
......@@ -15,37 +15,21 @@
namespace angle
{
namespace
{
std::string GetPath(HMODULE module)
std::string GetExecutablePath()
{
std::array<char, MAX_PATH> executableFileBuf;
DWORD executablePathLen = GetModuleFileNameA(module, executableFileBuf.data(),
DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(),
static_cast<DWORD>(executableFileBuf.size()));
return (executablePathLen > 0 ? std::string(executableFileBuf.data()) : "");
}
std::string GetDirectory(HMODULE module)
std::string GetExecutableDirectory()
{
std::string executablePath = GetPath(module);
std::string executablePath = GetExecutablePath();
size_t lastPathSepLoc = executablePath.find_last_of("\\/");
return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : "";
}
} // anonymous namespace
std::string GetExecutablePath()
{
return GetPath(nullptr);
}
std::string GetExecutableDirectory()
{
return GetDirectory(nullptr);
}
const char *GetSharedLibraryExtension()
{
return "dll";
......@@ -117,20 +101,8 @@ char GetPathSeparator()
return '\\';
}
std::string GetModuleDirectory()
std::string GetHelperExecutableDir()
{
// GetModuleHandleEx is unavailable on UWP
#if !defined(ANGLE_IS_WINUWP)
static int placeholderSymbol = 0;
HMODULE module = nullptr;
if (GetModuleHandleEx(
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCWSTR>(&placeholderSymbol), &module))
{
return GetDirectory(module);
}
#endif
return GetDirectory(nullptr);
return "";
}
} // namespace angle
......@@ -51,9 +51,12 @@ namespace
!defined(ANGLE_PLATFORM_GGP)
const std::string WrapICDEnvironment(const char *icdEnvironment)
{
// The libraries are bundled into the module directory
std::string ret = angle::GetModuleDirectory() + GetPathSeparator() + icdEnvironment;
# if defined(ANGLE_PLATFORM_APPLE)
// On MacOS the libraries are bundled into the application directory
std::string ret = angle::GetHelperExecutableDir() + icdEnvironment;
return ret;
# endif // defined(ANGLE_PLATFORM_APPLE)
return icdEnvironment;
}
constexpr char kLoaderLayersPathEnv[] = "VK_LAYER_PATH";
......@@ -143,9 +146,9 @@ ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers
}
else
{
mPreviousCWD = cwd.value();
std::string moduleDir = angle::GetModuleDirectory();
mChangedCWD = angle::SetCWD(moduleDir.c_str());
mPreviousCWD = cwd.value();
std::string exeDir = angle::GetExecutableDirectory();
mChangedCWD = angle::SetCWD(exeDir.c_str());
if (!mChangedCWD)
{
ERR() << "Error setting CWD for Vulkan layers init.";
......
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