Skip to content

Commit 65113bf

Browse files
committed
ImGui: Make ImGui work with volk loader
ImGui defines vulkan function pointers globally and those names conflict with function pointers defined by volk library (violation of single definition rule). This leads to runtime crash when some compilation units have a chance to use imgui's version of function pointer which is not initialized by imgui (because we use volk for initialization and do not invoke imgui function loader functionality).
1 parent 4b68b54 commit 65113bf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

third-party/imgui/impl/imgui_impl_vulkan.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,12 @@ void ImGui_ImplVulkanH_CreateWindowCommandBuffers(VkPhysicalDevice physical_devi
123123

124124
// Vulkan prototypes for use with custom loaders
125125
// (see description of IMGUI_IMPL_VULKAN_NO_PROTOTYPES in imgui_impl_vulkan.h
126-
#ifdef VK_NO_PROTOTYPES
126+
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_HEADER_VERSION)
127127
static bool g_FunctionsLoaded = false;
128128
#else
129129
static bool g_FunctionsLoaded = true;
130130
#endif
131-
#ifdef VK_NO_PROTOTYPES
131+
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_HEADER_VERSION)
132132
#define IMGUI_VULKAN_FUNC_MAP(IMGUI_VULKAN_FUNC_MAP_MACRO) \
133133
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateCommandBuffers) \
134134
IMGUI_VULKAN_FUNC_MAP_MACRO(vkAllocateDescriptorSets) \
@@ -1011,7 +1011,7 @@ bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const ch
10111011
// You can use the default Vulkan loader using:
10121012
// ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
10131013
// But this would be equivalent to not setting VK_NO_PROTOTYPES.
1014-
#ifdef VK_NO_PROTOTYPES
1014+
#if defined(VK_NO_PROTOTYPES) && !defined(VOLK_HEADER_VERSION)
10151015
#define IMGUI_VULKAN_FUNC_LOAD(func) \
10161016
func = reinterpret_cast<decltype(func)>(loader_func(#func, user_data)); \
10171017
if (func == NULL) \

third-party/imgui/impl/imgui_impl_vulkan.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#if defined(IMGUI_IMPL_VULKAN_NO_PROTOTYPES) && !defined(VK_NO_PROTOTYPES)
4141
#define VK_NO_PROTOTYPES
4242
#endif
43-
#include <vulkan/vulkan.h>
43+
#include "volk/volk.h"
4444

4545
// Initialization data, for ImGui_ImplVulkan_Init()
4646
// [Please zero-clear before use!]

0 commit comments

Comments
 (0)