|
@@ -21,8 +21,12 @@
|
|
|
#define GLFW_INCLUDE_NONE
|
|
|
#define GLFW_INCLUDE_VULKAN
|
|
|
#include <GLFW/glfw3.h>
|
|
|
-#include <vulkan/vulkan.h>
|
|
|
-//#include <vulkan/vulkan_beta.h>
|
|
|
+
|
|
|
+// Volk headers
|
|
|
+#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
|
+#define VOLK_IMPLEMENTATION
|
|
|
+#include <Volk/volk.h>
|
|
|
+#endif
|
|
|
|
|
|
// [Win32] Our example includes a copy of glfw3.lib pre-compiled with VS2010 to maximize ease of testing and compatibility with old VS compilers.
|
|
|
// 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()
|
|
|
static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|
|
{
|
|
|
VkResult err;
|
|
|
+#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
|
+ volkInitialize();
|
|
|
+#endif
|
|
|
|
|
|
// Create Vulkan Instance
|
|
|
{
|
|
@@ -151,17 +158,20 @@ static void SetupVulkan(ImVector<const char*> instance_extensions)
|
|
|
create_info.ppEnabledExtensionNames = instance_extensions.Data;
|
|
|
err = vkCreateInstance(&create_info, g_Allocator, &g_Instance);
|
|
|
check_vk_result(err);
|
|
|
+#ifdef IMGUI_IMPL_VULKAN_USE_VOLK
|
|
|
+ volkLoadInstance(g_Instance);
|
|
|
+#endif
|
|
|
|
|
|
// Setup the debug report callback
|
|
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
|
|
- auto vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
|
|
- IM_ASSERT(vkCreateDebugReportCallbackEXT != nullptr);
|
|
|
+ auto f_vkCreateDebugReportCallbackEXT = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkCreateDebugReportCallbackEXT");
|
|
|
+ IM_ASSERT(f_vkCreateDebugReportCallbackEXT != nullptr);
|
|
|
VkDebugReportCallbackCreateInfoEXT debug_report_ci = {};
|
|
|
debug_report_ci.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
|
|
|
debug_report_ci.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
|
|
debug_report_ci.pfnCallback = debug_report;
|
|
|
debug_report_ci.pUserData = nullptr;
|
|
|
- err = vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
|
|
+ err = f_vkCreateDebugReportCallbackEXT(g_Instance, &debug_report_ci, g_Allocator, &g_DebugReport);
|
|
|
check_vk_result(err);
|
|
|
#endif
|
|
|
}
|
|
@@ -277,8 +287,8 @@ static void CleanupVulkan()
|
|
|
|
|
|
#ifdef APP_USE_VULKAN_DEBUG_REPORT
|
|
|
// Remove the debug report callback
|
|
|
- auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
|
|
- vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
|
|
+ auto f_vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
|
|
|
+ f_vkDestroyDebugReportCallbackEXT(g_Instance, g_DebugReport, g_Allocator);
|
|
|
#endif // APP_USE_VULKAN_DEBUG_REPORT
|
|
|
|
|
|
vkDestroyDevice(g_Device, g_Allocator);
|