summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineVulkan
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-12-07 22:17:17 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-12-07 22:17:17 +0000
commit983e76d57b2748796b62b114446f9337f3709ff5 (patch)
treed1de3a22fc28e0b84b70c6b28677d5d70757a91f /Graphics/GraphicsEngineVulkan
parentFixed run_tests.bat (diff)
downloadDiligentCore-983e76d57b2748796b62b114446f9337f3709ff5.tar.gz
DiligentCore-983e76d57b2748796b62b114446f9337f3709ff5.zip
Reworked API Unit test to use run-time DLL loading to avoid apparent issue with missing Vulkan library on appveyor; improved implementation of DLL loading on Windows
Diffstat (limited to 'Graphics/GraphicsEngineVulkan')
-rw-r--r--Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h54
1 files changed, 10 insertions, 44 deletions
diff --git a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
index 2b3381ba..c50649b1 100644
--- a/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
+++ b/Graphics/GraphicsEngineVulkan/interface/EngineFactoryVk.h
@@ -34,18 +34,19 @@
#include "../../GraphicsEngine/interface/SwapChain.h"
#if PLATFORM_ANDROID || PLATFORM_LINUX || PLATFORM_MACOS || PLATFORM_IOS || (PLATFORM_WIN32 && !defined(_MSC_VER))
-
// https://gcc.gnu.org/wiki/Visibility
# define API_QUALIFIER __attribute__((visibility("default")))
-
#elif PLATFORM_WIN32
-
# define API_QUALIFIER
-
#else
# error Unsupported platform
#endif
+#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER)
+# include "../../GraphicsEngine/interface/LoadEngineDll.h"
+# define EXPLICITLY_LOAD_ENGINE_VK_DLL 1
+#endif
+
namespace Diligent
{
@@ -74,50 +75,15 @@ public:
};
-#if ENGINE_DLL && PLATFORM_WIN32 && defined(_MSC_VER)
-
-# define EXPLICITLY_LOAD_ENGINE_VK_DLL 1
+#if EXPLICITLY_LOAD_ENGINE_VK_DLL
-typedef IEngineFactoryVk* (*GetEngineFactoryVkType)();
+using GetEngineFactoryVkType = IEngineFactoryVk* (*)();
static bool LoadGraphicsEngineVk(GetEngineFactoryVkType& GetFactoryFunc)
{
- GetFactoryFunc = nullptr;
- std::string LibName = "GraphicsEngineVk_";
-
-# if _WIN64
- LibName += "64";
-# else
- LibName += "32";
-# endif
-
-# ifdef _DEBUG
- LibName += "d";
-# else
- LibName += "r";
-# endif
-
- LibName += ".dll";
- auto hModule = LoadLibraryA(LibName.c_str());
- if (hModule == NULL)
- {
- std::stringstream ss;
- ss << "Failed to load " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
- return false;
- }
-
- GetFactoryFunc = reinterpret_cast<GetEngineFactoryVkType>(GetProcAddress(hModule, "GetEngineFactoryVk"));
- if (GetFactoryFunc == NULL)
- {
- std::stringstream ss;
- ss << "Failed to load GetEngineFactoryVk() from " << LibName << " library.\n";
- OutputDebugStringA(ss.str().c_str());
- FreeLibrary(hModule);
- return false;
- }
-
- return true;
+ auto ProcAddress = LoadEngineDll("GraphicsEngineVk", "GetEngineFactoryVk");
+ GetFactoryFunc = reinterpret_cast<GetEngineFactoryVkType>(ProcAddress);
+ return GetFactoryFunc != nullptr;
}
#else