diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-10-26 23:30:47 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-10-26 23:30:47 +0100 |
commit | 9000db505ed9ca31134df5c35af7302ed5acce85 (patch) | |
tree | f77dd9c270c34373d1941c4cb144f3bde2f080ab /thirdparty/vulkan/loader | |
parent | 7b27dccbe0832e1231ff842a3a2c6e97a76660f3 (diff) |
vulkan: Re-add Windows patch to fix static library use
Fixes #43105.
Diffstat (limited to 'thirdparty/vulkan/loader')
-rw-r--r-- | thirdparty/vulkan/loader/loader.c | 2 | ||||
-rw-r--r-- | thirdparty/vulkan/loader/loader.h | 3 | ||||
-rw-r--r-- | thirdparty/vulkan/loader/vk_loader_platform.h | 16 |
3 files changed, 20 insertions, 1 deletions
diff --git a/thirdparty/vulkan/loader/loader.c b/thirdparty/vulkan/loader/loader.c index 418b88e30a..a6b5522cd4 100644 --- a/thirdparty/vulkan/loader/loader.c +++ b/thirdparty/vulkan/loader/loader.c @@ -7849,7 +7849,7 @@ out: return result; } -#if defined(_WIN32) +#if defined(_WIN32) && defined(LOADER_DYNAMIC_LIB) BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, LPVOID reserved) { switch (reason) { case DLL_PROCESS_ATTACH: diff --git a/thirdparty/vulkan/loader/loader.h b/thirdparty/vulkan/loader/loader.h index 621eb0be3b..a3c1f6b635 100644 --- a/thirdparty/vulkan/loader/loader.h +++ b/thirdparty/vulkan/loader/loader.h @@ -428,6 +428,9 @@ static inline void loader_init_dispatch(void *obj, const void *data) { // Global variables used across files extern struct loader_struct loader; extern THREAD_LOCAL_DECL struct loader_instance *tls_instance; +#if defined(_WIN32) && !defined(LOADER_DYNAMIC_LIB) +extern LOADER_PLATFORM_THREAD_ONCE_DEFINITION(once_init); +#endif extern loader_platform_thread_mutex loader_lock; extern loader_platform_thread_mutex loader_json_lock; extern loader_platform_thread_mutex loader_preload_icd_lock; diff --git a/thirdparty/vulkan/loader/vk_loader_platform.h b/thirdparty/vulkan/loader/vk_loader_platform.h index e227bf07b2..b7664f50a1 100644 --- a/thirdparty/vulkan/loader/vk_loader_platform.h +++ b/thirdparty/vulkan/loader/vk_loader_platform.h @@ -368,9 +368,25 @@ typedef HANDLE loader_platform_thread; // The once init functionality is not used when building a DLL on Windows. This is because there is no way to clean up the // resources allocated by anything allocated by once init. This isn't a problem for static libraries, but it is for dynamic // ones. When building a DLL, we use DllMain() instead to allow properly cleaning up resources. +#if defined(LOADER_DYNAMIC_LIB) #define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) #define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) #define LOADER_PLATFORM_THREAD_ONCE(ctl, func) +#else +#define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) INIT_ONCE var = INIT_ONCE_STATIC_INIT; +#define LOADER_PLATFORM_THREAD_ONCE_DEFINITION(var) INIT_ONCE var; +#define LOADER_PLATFORM_THREAD_ONCE(ctl, func) loader_platform_thread_once_fn(ctl, func) +static BOOL CALLBACK InitFuncWrapper(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) { + void (*func)(void) = (void (*)(void))Parameter; + func(); + return TRUE; +} +static void loader_platform_thread_once_fn(void *ctl, void (*func)(void)) { + assert(func != NULL); + assert(ctl != NULL); + InitOnceExecuteOnce((PINIT_ONCE)ctl, InitFuncWrapper, (void *)func, NULL); +} +#endif // Thread IDs: typedef DWORD loader_platform_thread_id; |