26
26
27
27
// CHANGELOG
28
28
// (minor and older changes stripped away, please see git history for details)
29
+ // 2025-02-14: *BREAKING CHANGE*: Added uint32_t api_version to ImGui_ImplVulkan_LoadFunctions().
29
30
// 2025-02-13: Vulkan: Added ApiVersion field in ImGui_ImplVulkan_InitInfo. Default to header version if unspecified. Dynamic rendering path loads "vkCmdBeginRendering/vkCmdEndRendering" (without -KHR suffix) on API 1.3. (#8326)
30
31
// 2025-01-09: Vulkan: Added IMGUI_IMPL_VULKAN_MINIMUM_IMAGE_SAMPLER_POOL_SIZE to clarify how many image sampler descriptors are expected to be available in descriptor pool. (#6642)
31
32
// 2025-01-06: Vulkan: Added more ImGui_ImplVulkanH_XXXX helper functions to simplify our examples.
@@ -1081,22 +1082,34 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
1081
1082
}
1082
1083
1083
1084
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
1084
- static void ImGui_ImplVulkan_LoadDynamicRenderingFunctions (PFN_vkVoidFunction(*loader_func)(const char * function_name, void * user_data), void* user_data)
1085
+ static void ImGui_ImplVulkan_LoadDynamicRenderingFunctions (uint32_t api_version, PFN_vkVoidFunction(*loader_func)(const char * function_name, void * user_data), void* user_data)
1085
1086
{
1086
1087
// Manually load those two (see #5446, #8326, #8365)
1087
- ImGui_ImplVulkan_Data* bd = ImGui_ImplVulkan_GetBackendData ();
1088
- ImGui_ImplVulkan_InitInfo* v = &bd->VulkanInitInfo ;
1089
- ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast <PFN_vkCmdBeginRenderingKHR>(loader_func (v->ApiVersion < VK_API_VERSION_1_3 ? " vkCmdBeginRenderingKHR" : " vkCmdBeginRendering" , user_data));
1090
- ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast <PFN_vkCmdEndRenderingKHR>(loader_func (v->ApiVersion < VK_API_VERSION_1_3 ? " vkCmdEndRenderingKHR" : " vkCmdEndRendering" , user_data));
1088
+ ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast <PFN_vkCmdBeginRenderingKHR>(loader_func (api_version < VK_API_VERSION_1_3 ? " vkCmdBeginRenderingKHR" : " vkCmdBeginRendering" , user_data));
1089
+ ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast <PFN_vkCmdEndRenderingKHR>(loader_func (api_version < VK_API_VERSION_1_3 ? " vkCmdEndRenderingKHR" : " vkCmdEndRendering" , user_data));
1091
1090
}
1092
1091
#endif
1093
1092
1094
- bool ImGui_ImplVulkan_LoadFunctions (PFN_vkVoidFunction(*loader_func)(const char * function_name, void * user_data), void* user_data)
1093
+ // If unspecified by user, assume that ApiVersion == HeaderVersion
1094
+ // We don't care about other versions than 1.3 for our checks, so don't need to make this exhaustive (e.g. with all #ifdef VK_VERSION_1_X checks)
1095
+ static uint32_t ImGui_ImplVulkan_GetDefaultApiVersion ()
1096
+ {
1097
+ #ifdef VK_HEADER_VERSION_COMPLETE
1098
+ return VK_HEADER_VERSION_COMPLETE;
1099
+ #else
1100
+ return VK_API_VERSION_1_0;
1101
+ #endif
1102
+ }
1103
+
1104
+ bool ImGui_ImplVulkan_LoadFunctions (uint32_t api_version, PFN_vkVoidFunction(*loader_func)(const char * function_name, void * user_data), void* user_data)
1095
1105
{
1096
1106
// Load function pointers
1097
1107
// You can use the default Vulkan loader using:
1098
- // ImGui_ImplVulkan_LoadFunctions([](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
1108
+ // ImGui_ImplVulkan_LoadFunctions(VK_API_VERSION_1_3, [](const char* function_name, void*) { return vkGetInstanceProcAddr(your_vk_isntance, function_name); });
1099
1109
// But this would be roughly equivalent to not setting VK_NO_PROTOTYPES.
1110
+ if (api_version == 0 )
1111
+ api_version = ImGui_ImplVulkan_GetDefaultApiVersion ();
1112
+
1100
1113
#ifdef IMGUI_IMPL_VULKAN_USE_LOADER
1101
1114
#define IMGUI_VULKAN_FUNC_LOAD (func ) \
1102
1115
func = reinterpret_cast <decltype (func)>(loader_func (#func, user_data)); \
@@ -1106,7 +1119,7 @@ bool ImGui_ImplVulkan_LoadFunctions(PFN_vkVoidFunction(*loader_func)(const ch
1106
1119
#undef IMGUI_VULKAN_FUNC_LOAD
1107
1120
1108
1121
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
1109
- ImGui_ImplVulkan_LoadDynamicRenderingFunctions (loader_func, user_data);
1122
+ ImGui_ImplVulkan_LoadDynamicRenderingFunctions (api_version, loader_func, user_data);
1110
1123
#endif
1111
1124
#else
1112
1125
IM_UNUSED (loader_func);
@@ -1121,11 +1134,14 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
1121
1134
{
1122
1135
IM_ASSERT (g_FunctionsLoaded && " Need to call ImGui_ImplVulkan_LoadFunctions() if IMGUI_IMPL_VULKAN_NO_PROTOTYPES or VK_NO_PROTOTYPES are set!" );
1123
1136
1137
+ if (info->ApiVersion == 0 )
1138
+ info->ApiVersion = ImGui_ImplVulkan_GetDefaultApiVersion ();
1139
+
1124
1140
if (info->UseDynamicRendering )
1125
1141
{
1126
1142
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
1127
1143
#ifndef IMGUI_IMPL_VULKAN_USE_LOADER
1128
- ImGui_ImplVulkan_LoadDynamicRenderingFunctions ([](const char * function_name, void * user_data) { return vkGetInstanceProcAddr ((VkInstance)user_data, function_name); }, (void *)info->Instance );
1144
+ ImGui_ImplVulkan_LoadDynamicRenderingFunctions (info-> ApiVersion , [](const char * function_name, void * user_data) { return vkGetInstanceProcAddr ((VkInstance)user_data, function_name); }, (void *)info->Instance );
1129
1145
#endif
1130
1146
IM_ASSERT (ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR != nullptr );
1131
1147
IM_ASSERT (ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR != nullptr );
@@ -1158,15 +1174,6 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
1158
1174
IM_ASSERT (info->RenderPass != VK_NULL_HANDLE);
1159
1175
1160
1176
bd->VulkanInitInfo = *info;
1161
- if (bd->VulkanInitInfo .ApiVersion == 0 )
1162
- {
1163
- // We don't care about other versions for now, so don't need to make this exhaustive (with #ifdef VK_VERSION_1_X checks)
1164
- #ifdef VK_HEADER_VERSION_COMPLETE
1165
- bd->VulkanInitInfo .ApiVersion = VK_HEADER_VERSION_COMPLETE;
1166
- #else
1167
- bd->VulkanInitInfo .ApiVersion = VK_API_VERSION_1_0;
1168
- #endif
1169
- }
1170
1177
1171
1178
ImGui_ImplVulkan_CreateDeviceObjects ();
1172
1179
0 commit comments