|
21 | 21 | #define GLFW_INCLUDE_NONE
|
22 | 22 | #define GLFW_INCLUDE_VULKAN
|
23 | 23 | #include <GLFW/glfw3.h>
|
24 |
| -#include <vulkan/vulkan.h> |
25 |
| -//#include <vulkan/vulkan_beta.h> |
| 24 | + |
| 25 | +// Volk headers |
| 26 | +#ifdef IMGUI_IMPL_VULKAN_USE_VOLK |
| 27 | +#define VOLK_IMPLEMENTATION |
| 28 | +#include <Volk/volk.h> |
| 29 | +#endif |
26 | 30 |
|
27 | 31 | // [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
28 | 32 | // To link with VS2010-era libraries, VS2015+ requires linking with legacy_stdio_definitions.lib, which we do using this pragma.
|
@@ -113,6 +117,9 @@ static VkPhysicalDevice SetupVulkan_SelectPhysicalDevice()
|
113 | 117 | static void SetupVulkan(ImVector<const char*> instance_extensions)
|
114 | 118 | {
|
115 | 119 | VkResult err;
|
| 120 | +#ifdef IMGUI_IMPL_VULKAN_USE_VOLK |
| 121 | + volkInitialize(); |
| 122 | +#endif |
116 | 123 |
|
117 | 124 | // Create Vulkan Instance
|
118 | 125 | {
|
@@ -151,17 +158,20 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
151 | 158 | create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
152 | 159 | err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
153 | 160 | check_vk_result(err);
|
| 161 | +#ifdef IMGUI_IMPL_VULKAN_USE_VOLK |
| 162 | + volkLoadInstance(g_Instance); |
| 163 | +#endif |
154 | 164 |
|
155 | 165 | // Setup the debug report callback
|
156 | 166 | #ifdef APP_USE_VULKAN_DEBUG_REPORT
|
157 |
| - auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT"); |
158 |
| - IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr); |
| 167 | + auto f_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT"); |
| 168 | + IM_ASSERT(f_vkCreateDebugReportCallbackEXT != nullptr); |
159 | 169 | VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
160 | 170 | debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
161 | 171 | debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
162 | 172 | debug_report_ci.pfnCallback = debug_report;
|
163 | 173 | debug_report_ci.pUserData = nullptr;
|
164 |
| - err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport); |
| 174 | + err = f_vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport); |
165 | 175 | check_vk_result(err);
|
166 | 176 | #endif
|
167 | 177 | }
|
@@ -277,8 +287,8 @@ static void CleanupVulkan()
|
277 | 287 |
|
278 | 288 | #ifdef APP_USE_VULKAN_DEBUG_REPORT
|
279 | 289 | // Remove the debug report callback
|
280 |
| - auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT"); |
281 |
| - vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator); |
| 290 | + auto f_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT"); |
| 291 | + f_vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator); |
282 | 292 | #endif // APP_USE_VULKAN_DEBUG_REPORT
|
283 | 293 |
|
284 | 294 | vkDestroyDevice(g_Device, g_Allocator);
|
|
0 commit comments