1 /*
2 *
3 * Copyright (c) 2015-2022 The Khronos Group Inc.
4 * Copyright (c) 2015-2022 Valve Corporation
5 * Copyright (c) 2015-2022 LunarG, Inc.
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: Ian Elliot <ian@lunarg.com>
20 * Author: Jon Ashburn <jon@lunarg.com>
21 * Author: Lenny Komow <lenny@lunarg.com>
22 * Author: Charles Giessen <charles@lunarg.com>
23 *
24 */
25 #pragma once
26
27 #if defined(__FreeBSD__) || defined(__OpenBSD__)
28 #include <sys/types.h>
29 #include <sys/select.h>
30 #endif
31
32 #if defined(_WIN32)
33 // WinSock2.h must be included *BEFORE* windows.h
34 #include <winsock2.h>
35 #endif // _WIN32
36
37 #include <assert.h>
38 #include <string.h>
39 #include <stdbool.h>
40 #include <stdint.h>
41
42 #if defined(__Fuchsia__)
43 #include "dlopen_fuchsia.h"
44 #endif // defined(__Fuchsia__)
45
46 #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
47 #include <unistd.h>
48 // Note: The following file is for dynamic loading:
49 #include <dlfcn.h>
50 #include <pthread.h>
51 #include <stdlib.h>
52 #include <libgen.h>
53
54 #elif defined(_WIN32) // defined(__linux__)
55 /* Windows-specific common code: */
56 // WinBase.h defines CreateSemaphore and synchapi.h defines CreateEvent
57 // undefine them to avoid conflicts with VkLayerDispatchTable struct members.
58 #ifdef CreateSemaphore
59 #undef CreateSemaphore
60 #endif
61 #ifdef CreateEvent
62 #undef CreateEvent
63 #endif
64 #include <stdio.h>
65 #include <io.h>
66 #include <shlwapi.h>
67 #include <direct.h>
68 #endif // defined(_WIN32)
69
70 #include "stack_allocation.h"
71
72 #if defined(__GNUC__) && __GNUC__ >= 4
73 #define LOADER_EXPORT __attribute__((visibility("default")))
74 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
75 #define LOADER_EXPORT __attribute__((visibility("default")))
76 #else
77 #define LOADER_EXPORT
78 #endif
79
80 #define MAX_STRING_SIZE 1024
81
82 // This is defined in vk_layer.h, but if there's problems we need to create the define
83 // here.
84 #ifndef MAX_NUM_UNKNOWN_EXTS
85 #define MAX_NUM_UNKNOWN_EXTS 250
86 #endif
87
88 // Environment Variable information
89 #define VK_ICD_FILENAMES_ENV_VAR "VK_ICD_FILENAMES" // Deprecated
90 #define VK_DRIVER_FILES_ENV_VAR "VK_DRIVER_FILES"
91 #define VK_ADDITIONAL_DRIVER_FILES_ENV_VAR "VK_ADD_DRIVER_FILES"
92 #define VK_LAYER_PATH_ENV_VAR "VK_LAYER_PATH"
93 #define VK_ADDITIONAL_LAYER_PATH_ENV_VAR "VK_ADD_LAYER_PATH"
94
95 // Override layer information
96 #define VK_OVERRIDE_LAYER_NAME "VK_LAYER_LUNARG_override"
97
98 #define LAYERS_PATH_ENV "VK_LAYER_PATH"
99 #define ENABLED_LAYERS_ENV "VK_INSTANCE_LAYERS"
100
101 #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
102 /* Linux-specific common code: */
103
104 // VK Library Filenames, Paths, etc.:
105 #define PATH_SEPARATOR ':'
106 #define DIRECTORY_SYMBOL '/'
107
108 #define VULKAN_DIR "vulkan/"
109 #define VULKAN_ICDCONF_DIR "icd.d"
110 #define VULKAN_ICD_DIR "icd"
111 #define VULKAN_SETTINGSCONF_DIR "settings.d"
112 #define VULKAN_ELAYERCONF_DIR "explicit_layer.d"
113 #define VULKAN_ILAYERCONF_DIR "implicit_layer.d"
114 #define VULKAN_LAYER_DIR "layer"
115
116 #define VK_DRIVERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ICDCONF_DIR
117 #define VK_SETTINGS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_SETTINGSCONF_DIR
118 #define VK_ELAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ELAYERCONF_DIR
119 #define VK_ILAYERS_INFO_RELATIVE_DIR VULKAN_DIR VULKAN_ILAYERCONF_DIR
120
121 #define VK_DRIVERS_INFO_REGISTRY_LOC ""
122 #define VK_SETTINGS_INFO_REGISTRY_LOC ""
123 #define VK_ELAYERS_INFO_REGISTRY_LOC ""
124 #define VK_ILAYERS_INFO_REGISTRY_LOC ""
125
126 #if defined(__QNXNTO__)
127 #define SYSCONFDIR "/etc"
128 #endif
129
130 // C99:
131 #define PRINTF_SIZE_T_SPECIFIER "%zu"
132
133 // Dynamic Loading of libraries:
134 typedef void *loader_platform_dl_handle;
135
136 // Threads:
137 typedef pthread_t loader_platform_thread;
138
139 // Thread IDs:
140 typedef pthread_t loader_platform_thread_id;
141
142 // Thread mutex:
143 typedef pthread_mutex_t loader_platform_thread_mutex;
144
145 typedef pthread_cond_t loader_platform_thread_cond;
146
147 #elif defined(_WIN32) // defined(__linux__)
148
149 // VK Library Filenames, Paths, etc.:
150 #define PATH_SEPARATOR ';'
151 #define DIRECTORY_SYMBOL '\\'
152 #define DEFAULT_VK_REGISTRY_HIVE HKEY_LOCAL_MACHINE
153 #define DEFAULT_VK_REGISTRY_HIVE_STR "HKEY_LOCAL_MACHINE"
154 #define SECONDARY_VK_REGISTRY_HIVE HKEY_CURRENT_USER
155 #define SECONDARY_VK_REGISTRY_HIVE_STR "HKEY_CURRENT_USER"
156
157 #define VK_DRIVERS_INFO_RELATIVE_DIR ""
158 #define VK_SETTINGS_INFO_RELATIVE_DIR ""
159 #define VK_ELAYERS_INFO_RELATIVE_DIR ""
160 #define VK_ILAYERS_INFO_RELATIVE_DIR ""
161
162 #ifdef _WIN64
163 #define HKR_VK_DRIVER_NAME API_NAME "DriverName"
164 #else
165 #define HKR_VK_DRIVER_NAME API_NAME "DriverNameWow"
166 #endif
167 #define VK_DRIVERS_INFO_REGISTRY_LOC "SOFTWARE\\Khronos\\" API_NAME "\\Drivers"
168 #define VK_SETTINGS_INFO_REGISTRY_LOC "SOFTWARE\\Khronos\\" API_NAME "\\Settings"
169 #define VK_ELAYERS_INFO_REGISTRY_LOC "SOFTWARE\\Khronos\\" API_NAME "\\ExplicitLayers"
170 #define VK_ILAYERS_INFO_REGISTRY_LOC "SOFTWARE\\Khronos\\" API_NAME "\\ImplicitLayers"
171
172 #define PRINTF_SIZE_T_SPECIFIER "%Iu"
173
174 // Dynamic Loading:
175 typedef HMODULE loader_platform_dl_handle;
176
177 // Threads:
178 typedef HANDLE loader_platform_thread;
179
180 // Thread IDs:
181 typedef DWORD loader_platform_thread_id;
182
183 // Thread mutex:
184 typedef CRITICAL_SECTION loader_platform_thread_mutex;
185
186 typedef CONDITION_VARIABLE loader_platform_thread_cond;
187
188 #else // defined(_WIN32)
189
190 #error The "vk_loader_platform.h" file must be modified for this OS.
191
192 // NOTE: In order to support another OS, an #elif needs to be added (above the
193 // "#else // defined(_WIN32)") for that OS, and OS-specific versions of the
194 // contents of this file must be created, or extend one of the existing OS specific
195 // sections with the necessary changes.
196
197 #endif // defined(_WIN32)
198
199 // Returns true if the DIRECTORY_SYMBOL is contained within path
loader_platform_is_path(const char * path)200 static inline bool loader_platform_is_path(const char *path) { return strchr(path, DIRECTORY_SYMBOL) != NULL; }
201
202 // The once init functionality is not used when building a DLL on Windows. This is because there is no way to clean up the
203 // resources allocated by anything allocated by once init. This isn't a problem for static libraries, but it is for dynamic
204 // ones. When building a DLL, we use DllMain() instead to allow properly cleaning up resources.
205
206 #if defined(__APPLE__) && defined(BUILD_STATIC_LOADER)
loader_platform_thread_once_fn(pthread_once_t * ctl,void (* func)(void))207 static inline void loader_platform_thread_once_fn(pthread_once_t *ctl, void (*func)(void)) {
208 assert(func != NULL);
209 assert(ctl != NULL);
210 pthread_once(ctl, func);
211 }
212 #define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var) pthread_once_t var = PTHREAD_ONCE_INIT;
213 #define LOADER_PLATFORM_THREAD_ONCE_EXTERN_DEFINITION(var) extern pthread_once_t var;
214 #define LOADER_PLATFORM_THREAD_ONCE(ctl, func) loader_platform_thread_once_fn(ctl, func);
215 #else
216 #define LOADER_PLATFORM_THREAD_ONCE_DECLARATION(var)
217 #define LOADER_PLATFORM_THREAD_ONCE_EXTERN_DEFINITION(var)
218 #define LOADER_PLATFORM_THREAD_ONCE(ctl, func)
219
220 #endif
221
222 #if defined(__linux__) || defined(__APPLE__) || defined(__Fuchsia__) || defined(__QNXNTO__) || defined(__FreeBSD__) || defined(__OpenBSD__)
223
224 // File IO
loader_platform_file_exists(const char * path)225 static inline bool loader_platform_file_exists(const char *path) {
226 if (access(path, F_OK))
227 return false;
228 else
229 return true;
230 }
231
232 // Returns true if the given string appears to be a relative or absolute
233 // path, as opposed to a bare filename.
loader_platform_is_path_absolute(const char * path)234 static inline bool loader_platform_is_path_absolute(const char *path) {
235 if (path[0] == '/')
236 return true;
237 else
238 return false;
239 }
240
loader_platform_dirname(char * path)241 static inline char *loader_platform_dirname(char *path) { return dirname(path); }
242
243 // loader_platform_executable_path finds application path + name.
244 // Path cannot be longer than 1024, returns NULL if it is greater than that.
245 #if defined(__linux__)
loader_platform_executable_path(char * buffer,size_t size)246 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
247 ssize_t count = readlink("/proc/self/exe", buffer, size);
248 if (count == -1) return NULL;
249 if (count == 0) return NULL;
250 buffer[count] = '\0';
251 return buffer;
252 }
253 #elif defined(__APPLE__) // defined(__linux__)
254 #include <libproc.h>
loader_platform_executable_path(char * buffer,size_t size)255 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
256 pid_t pid = getpid();
257 int ret = proc_pidpath(pid, buffer, size);
258 if (ret <= 0) return NULL;
259 buffer[ret] = '\0';
260 return buffer;
261 }
262 #elif defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__)
263 #include <sys/sysctl.h>
loader_platform_executable_path(char * buffer,size_t size)264 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
265 int mib[] = {
266 CTL_KERN,
267 #if defined(__NetBSD__)
268 KERN_PROC_ARGS,
269 -1,
270 KERN_PROC_PATHNAME,
271 #else
272 KERN_PROC,
273 KERN_PROC_PATHNAME,
274 -1,
275 #endif
276 };
277 if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buffer, &size, NULL, 0) < 0) {
278 return NULL;
279 }
280
281 return buffer;
282 }
283 #elif defined(__Fuchsia__) || defined(__OpenBSD__)
loader_platform_executable_path(char * buffer,size_t size)284 static inline char *loader_platform_executable_path(char *buffer, size_t size) { return NULL; }
285 #elif defined(__QNXNTO__)
286
287 #define SYSCONFDIR "/etc"
288
289 #include <fcntl.h>
290 #include <sys/stat.h>
291
loader_platform_executable_path(char * buffer,size_t size)292 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
293 int fd = open("/proc/self/exefile", O_RDONLY);
294 size_t rdsize;
295
296 if (fd == -1) {
297 return NULL;
298 }
299
300 rdsize = read(fd, buffer, size);
301 if (rdsize == size) {
302 return NULL;
303 }
304 buffer[rdsize] = 0x00;
305 close(fd);
306
307 return buffer;
308 }
309 #endif // defined (__QNXNTO__)
310
311 // Compatability with compilers that don't support __has_feature
312 #ifndef __has_feature
313 #define __has_feature(x) 0
314 #endif
315
316 #if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
317 #define LOADER_ADDRESS_SANITIZER // TODO: Add proper build flag for ASAN support
318 #endif
319
320 // When loading the library, we use RTLD_LAZY so that not all symbols have to be
321 // resolved at this time (which improves performance). Note that if not all symbols
322 // can be resolved, this could cause crashes later. Use the LD_BIND_NOW environment
323 // variable to force all symbols to be resolved here.
324 #define LOADER_DLOPEN_MODE (RTLD_LAZY | RTLD_LOCAL)
325
326 #if defined(__Fuchsia__)
loader_platform_open_driver(const char * libPath)327 static inline loader_platform_dl_handle loader_platform_open_driver(const char *libPath) {
328 return dlopen_fuchsia(libPath, LOADER_DLOPEN_MODE, true);
329 }
loader_platform_open_library(const char * libPath)330 static inline loader_platform_dl_handle loader_platform_open_library(const char *libPath) {
331 return dlopen_fuchsia(libPath, LOADER_DLOPEN_MODE, false);
332 }
333 #else
loader_platform_open_library(const char * libPath)334 static inline loader_platform_dl_handle loader_platform_open_library(const char *libPath) {
335 return dlopen(libPath, LOADER_DLOPEN_MODE);
336 }
337 #endif
338
loader_platform_open_library_error(const char * libPath)339 static inline const char *loader_platform_open_library_error(const char *libPath) {
340 #ifdef __Fuchsia__
341 return dlerror_fuchsia();
342 #else
343 return dlerror();
344 #endif
345 }
loader_platform_close_library(loader_platform_dl_handle library)346 static inline void loader_platform_close_library(loader_platform_dl_handle library) { dlclose(library); }
loader_platform_get_proc_address(loader_platform_dl_handle library,const char * name)347 static inline void *loader_platform_get_proc_address(loader_platform_dl_handle library, const char *name) {
348 assert(library);
349 assert(name);
350 return dlsym(library, name);
351 }
loader_platform_get_proc_address_error(const char * name)352 static inline const char *loader_platform_get_proc_address_error(const char *name) { return dlerror(); }
353
354 // Thread mutex:
loader_platform_thread_create_mutex(loader_platform_thread_mutex * pMutex)355 static inline void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_init(pMutex, NULL); }
loader_platform_thread_lock_mutex(loader_platform_thread_mutex * pMutex)356 static inline void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_lock(pMutex); }
loader_platform_thread_unlock_mutex(loader_platform_thread_mutex * pMutex)357 static inline void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_unlock(pMutex); }
loader_platform_thread_delete_mutex(loader_platform_thread_mutex * pMutex)358 static inline void loader_platform_thread_delete_mutex(loader_platform_thread_mutex *pMutex) { pthread_mutex_destroy(pMutex); }
359
360 #elif defined(_WIN32) // defined(__linux__)
361
362 // Get the key for the plug n play driver registry
363 // The string returned by this function should NOT be freed
LoaderPnpDriverRegistry()364 static inline const char *LoaderPnpDriverRegistry() {
365 BOOL is_wow;
366 IsWow64Process(GetCurrentProcess(), &is_wow);
367 return is_wow ? "VulkanDriverNameWow" : "VulkanDriverName";
368 }
LoaderPnpDriverRegistryWide()369 static inline const wchar_t *LoaderPnpDriverRegistryWide() {
370 BOOL is_wow;
371 IsWow64Process(GetCurrentProcess(), &is_wow);
372 return is_wow ? L"VulkanDriverNameWow" : L"VulkanDriverName";
373 }
374
375 // Get the key for the plug 'n play explicit layer registry
376 // The string returned by this function should NOT be freed
LoaderPnpELayerRegistry()377 static inline const char *LoaderPnpELayerRegistry() {
378 BOOL is_wow;
379 IsWow64Process(GetCurrentProcess(), &is_wow);
380 return is_wow ? "VulkanExplicitLayersWow" : "VulkanExplicitLayers";
381 }
LoaderPnpELayerRegistryWide()382 static inline const wchar_t *LoaderPnpELayerRegistryWide() {
383 BOOL is_wow;
384 IsWow64Process(GetCurrentProcess(), &is_wow);
385 return is_wow ? L"VulkanExplicitLayersWow" : L"VulkanExplicitLayers";
386 }
387
388 // Get the key for the plug 'n play implicit layer registry
389 // The string returned by this function should NOT be freed
LoaderPnpILayerRegistry()390 static inline const char *LoaderPnpILayerRegistry() {
391 BOOL is_wow;
392 IsWow64Process(GetCurrentProcess(), &is_wow);
393 return is_wow ? "VulkanImplicitLayersWow" : "VulkanImplicitLayers";
394 }
LoaderPnpILayerRegistryWide()395 static inline const wchar_t *LoaderPnpILayerRegistryWide() {
396 BOOL is_wow;
397 IsWow64Process(GetCurrentProcess(), &is_wow);
398 return is_wow ? L"VulkanImplicitLayersWow" : L"VulkanImplicitLayers";
399 }
400
401 // File IO
loader_platform_file_exists(const char * path)402 static bool loader_platform_file_exists(const char *path) {
403 int path_utf16_size = MultiByteToWideChar(CP_UTF8, 0, path, -1, NULL, 0);
404 if (path_utf16_size <= 0) {
405 return false;
406 }
407 wchar_t *path_utf16 = (wchar_t *)loader_stack_alloc(path_utf16_size * sizeof(wchar_t));
408 if (MultiByteToWideChar(CP_UTF8, 0, path, -1, path_utf16, path_utf16_size) != path_utf16_size) {
409 return false;
410 }
411 if (_waccess(path_utf16, 0) == -1)
412 return false;
413 else
414 return true;
415 }
416
417 // Returns true if the given string appears to be a relative or absolute
418 // path, as opposed to a bare filename.
loader_platform_is_path_absolute(const char * path)419 static bool loader_platform_is_path_absolute(const char *path) {
420 if (!path || !*path) {
421 return false;
422 }
423 if (*path == DIRECTORY_SYMBOL || path[1] == ':') {
424 return true;
425 }
426 return false;
427 }
428
429 // WIN32 runtime doesn't have dirname().
loader_platform_dirname(char * path)430 static inline char *loader_platform_dirname(char *path) {
431 char *current, *next;
432
433 // TODO/TBD: Do we need to deal with the Windows's ":" character?
434
435 for (current = path; *current != '\0'; current = next) {
436 next = strchr(current, DIRECTORY_SYMBOL);
437 if (next == NULL) {
438 if (current != path) *(current - 1) = '\0';
439 return path;
440 } else {
441 // Point one character past the DIRECTORY_SYMBOL:
442 next++;
443 }
444 }
445 return path;
446 }
447
loader_platform_executable_path(char * buffer,size_t size)448 static inline char *loader_platform_executable_path(char *buffer, size_t size) {
449 wchar_t *buffer_utf16 = (wchar_t *)loader_stack_alloc(size * sizeof(wchar_t));
450 DWORD ret = GetModuleFileNameW(NULL, buffer_utf16, (DWORD)size);
451 if (ret == 0) {
452 return NULL;
453 }
454 if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
455 return NULL;
456 }
457 int buffer_utf8_size = WideCharToMultiByte(CP_UTF8, 0, buffer_utf16, -1, NULL, 0, NULL, NULL);
458 if (buffer_utf8_size <= 0 || (size_t)buffer_utf8_size > size) {
459 return NULL;
460 }
461 if (WideCharToMultiByte(CP_UTF8, 0, buffer_utf16, -1, buffer, buffer_utf8_size, NULL, NULL) != buffer_utf8_size) {
462 return NULL;
463 }
464 return buffer;
465 }
466
467 // Dynamic Loading:
loader_platform_open_library(const char * lib_path)468 static loader_platform_dl_handle loader_platform_open_library(const char *lib_path) {
469 int lib_path_utf16_size = MultiByteToWideChar(CP_UTF8, 0, lib_path, -1, NULL, 0);
470 if (lib_path_utf16_size <= 0) {
471 return NULL;
472 }
473 wchar_t *lib_path_utf16 = (wchar_t *)loader_stack_alloc(lib_path_utf16_size * sizeof(wchar_t));
474 if (MultiByteToWideChar(CP_UTF8, 0, lib_path, -1, lib_path_utf16, lib_path_utf16_size) != lib_path_utf16_size) {
475 return NULL;
476 }
477 // Try loading the library the original way first.
478 loader_platform_dl_handle lib_handle = LoadLibraryW(lib_path_utf16);
479 if (lib_handle == NULL && GetLastError() == ERROR_MOD_NOT_FOUND) {
480 // If that failed, then try loading it with broader search folders.
481 lib_handle = LoadLibraryExW(lib_path_utf16, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
482 }
483 return lib_handle;
484 }
loader_platform_open_library_error(const char * libPath)485 static const char *loader_platform_open_library_error(const char *libPath) {
486 static char errorMsg[512];
487 (void)snprintf(errorMsg, 511, "Failed to open dynamic library \"%s\" with error %lu", libPath, GetLastError());
488 return errorMsg;
489 }
loader_platform_close_library(loader_platform_dl_handle library)490 static void loader_platform_close_library(loader_platform_dl_handle library) { FreeLibrary(library); }
loader_platform_get_proc_address(loader_platform_dl_handle library,const char * name)491 static void *loader_platform_get_proc_address(loader_platform_dl_handle library, const char *name) {
492 assert(library);
493 assert(name);
494 return (void *)GetProcAddress(library, name);
495 }
loader_platform_get_proc_address_error(const char * name)496 static const char *loader_platform_get_proc_address_error(const char *name) {
497 static char errorMsg[120];
498 (void)snprintf(errorMsg, 119, "Failed to find function \"%s\" in dynamic library", name);
499 return errorMsg;
500 }
501
502 // Thread mutex:
loader_platform_thread_create_mutex(loader_platform_thread_mutex * pMutex)503 static void loader_platform_thread_create_mutex(loader_platform_thread_mutex *pMutex) { InitializeCriticalSection(pMutex); }
loader_platform_thread_lock_mutex(loader_platform_thread_mutex * pMutex)504 static void loader_platform_thread_lock_mutex(loader_platform_thread_mutex *pMutex) { EnterCriticalSection(pMutex); }
loader_platform_thread_unlock_mutex(loader_platform_thread_mutex * pMutex)505 static void loader_platform_thread_unlock_mutex(loader_platform_thread_mutex *pMutex) { LeaveCriticalSection(pMutex); }
loader_platform_thread_delete_mutex(loader_platform_thread_mutex * pMutex)506 static void loader_platform_thread_delete_mutex(loader_platform_thread_mutex *pMutex) { DeleteCriticalSection(pMutex); }
507
508 #else // defined(_WIN32)
509
510 #error The "vk_loader_platform.h" file must be modified for this OS.
511
512 // NOTE: In order to support another OS, an #elif needs to be added (above the
513 // "#else // defined(_WIN32)") for that OS, and OS-specific versions of the
514 // contents of this file must be created.
515
516 // NOTE: Other OS-specific changes are also needed for this OS. Search for
517 // files with "WIN32" in it, as a quick way to find files that must be changed.
518
519 #endif // defined(_WIN32)
520