vulkan_loader.h (2231B)
1 // SPDX-FileCopyrightText: 2019-2024 Connor McLaughlin <stenzek@gmail.com> 2 // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) 3 4 #pragma once 5 6 class Error; 7 8 #define VK_NO_PROTOTYPES 9 10 #ifdef _WIN32 11 #define VK_USE_PLATFORM_WIN32_KHR 12 13 // vulkan.h pulls in windows.h on Windows, so we need to include our replacement header first 14 #include "common/windows_headers.h" 15 #elif defined(__APPLE__) 16 #define VK_USE_PLATFORM_METAL_EXT 17 #elif defined(__ANDROID__) 18 #define VK_USE_PLATFORM_ANDROID_KHR 19 #else 20 #ifdef ENABLE_X11 21 #define VK_USE_PLATFORM_XLIB_KHR 22 #endif 23 24 #ifdef ENABLE_WAYLAND 25 #define VK_USE_PLATFORM_WAYLAND_KHR 26 #endif 27 #endif 28 29 #include "vulkan/vulkan.h" 30 31 #if defined(ENABLE_X11) 32 33 // This breaks a bunch of our code. They shouldn't be #defines in the first place. 34 #ifdef None 35 #undef None 36 #endif 37 #ifdef Always 38 #undef Always 39 #endif 40 #ifdef Status 41 #undef Status 42 #endif 43 #ifdef CursorShape 44 #undef CursorShape 45 #endif 46 #ifdef KeyPress 47 #undef KeyPress 48 #endif 49 #ifdef KeyRelease 50 #undef KeyRelease 51 #endif 52 #ifdef FocusIn 53 #undef FocusIn 54 #endif 55 #ifdef FocusOut 56 #undef FocusOut 57 #endif 58 #ifdef FontChange 59 #undef FontChange 60 #endif 61 #ifdef Expose 62 #undef Expose 63 #endif 64 #ifdef Unsorted 65 #undef Unsorted 66 #endif 67 #ifdef Bool 68 #undef Bool 69 #endif 70 71 #endif 72 73 #include "vulkan_entry_points.h" 74 75 // We include vk_mem_alloc globally, so we don't accidentally include it before the vulkan header somewhere. 76 #ifdef __clang__ 77 #pragma clang diagnostic push 78 #pragma clang diagnostic ignored "-Wnullability-completeness" 79 #pragma clang diagnostic ignored "-Wunused-variable" 80 #pragma clang diagnostic ignored "-Wmissing-field-initializers" 81 #pragma clang diagnostic ignored "-Wunused-function" 82 #elif defined(_MSC_VER) 83 #pragma warning(push, 0) 84 #endif 85 86 #define VMA_STATIC_VULKAN_FUNCTIONS 1 87 #define VMA_DYNAMIC_VULKAN_FUNCTIONS 0 88 #define VMA_STATS_STRING_ENABLED 0 89 #include "vulkan/vk_mem_alloc.h" 90 91 #ifdef __clang__ 92 #pragma clang diagnostic pop 93 #elif defined(_MSC_VER) 94 #pragma warning(pop) 95 #endif 96 97 namespace Vulkan { 98 bool IsVulkanLibraryLoaded(); 99 bool LoadVulkanLibrary(Error* error); 100 bool LoadVulkanInstanceFunctions(VkInstance instance); 101 bool LoadVulkanDeviceFunctions(VkDevice device); 102 void UnloadVulkanLibrary(); 103 void ResetVulkanLibraryFunctionPointers(); 104 } // namespace Vulkan