Skip to content

Commit 890ead6

Browse files
committed
Backends: Vulkan: Added ApiVersion field in ImGui_ImplVulkan_InitInfo. Dynamic rendering path loads "vkCmdBeginRendering/vkCmdEndRendering" without -KHR on API 1.3. (ocornut#8326, ocornut#8365)
1 parent f94a5f0 commit 890ead6

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

backends/imgui_impl_vulkan.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
// CHANGELOG
2828
// (minor and older changes stripped away, please see git history for details)
29+
// 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)
2930
// 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)
3031
// 2025-01-06: Vulkan: Added more ImGui_ImplVulkanH_XXXX helper functions to simplify our examples.
3132
// 2024-12-11: Vulkan: Fixed setting VkSwapchainCreateInfoKHR::preTransform for platforms not supporting VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR. (#8222)
@@ -1082,9 +1083,11 @@ void ImGui_ImplVulkan_DestroyDeviceObjects()
10821083
#ifdef IMGUI_IMPL_VULKAN_HAS_DYNAMIC_RENDERING
10831084
static void ImGui_ImplVulkan_LoadDynamicRenderingFunctions(PFN_vkVoidFunction(*loader_func)(const char* function_name, void* user_data), void* user_data)
10841085
{
1085-
// Manually load those two (see #5446)
1086-
ImGuiImplVulkanFuncs_vkCmdBeginRenderingKHR = reinterpret_cast<PFN_vkCmdBeginRenderingKHR>(loader_func("vkCmdBeginRenderingKHR", user_data));
1087-
ImGuiImplVulkanFuncs_vkCmdEndRenderingKHR = reinterpret_cast<PFN_vkCmdEndRenderingKHR>(loader_func("vkCmdEndRenderingKHR", user_data));
1086+
// 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));
10881091
}
10891092
#endif
10901093

@@ -1155,6 +1158,8 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info)
11551158
IM_ASSERT(info->RenderPass != VK_NULL_HANDLE);
11561159

11571160
bd->VulkanInitInfo = *info;
1161+
if (bd->VulkanInitInfo.ApiVersion == 0)
1162+
bd->VulkanInitInfo.ApiVersion = VK_HEADER_VERSION_COMPLETE;
11581163

11591164
ImGui_ImplVulkan_CreateDeviceObjects();
11601165

backends/imgui_impl_vulkan.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,17 @@
7575
// - When using dynamic rendering, set UseDynamicRendering=true and fill PipelineRenderingCreateInfo structure.
7676
struct ImGui_ImplVulkan_InitInfo
7777
{
78+
uint32_t ApiVersion; // Fill with API version of Instance, e.g. VK_API_VERSION_1_3, which might be lower than header version (VK_HEADER_VERSION_COMPLETE)
7879
VkInstance Instance;
7980
VkPhysicalDevice PhysicalDevice;
8081
VkDevice Device;
8182
uint32_t QueueFamily;
8283
VkQueue Queue;
83-
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
84-
VkRenderPass RenderPass; // Ignored if using dynamic rendering
85-
uint32_t MinImageCount; // >= 2
86-
uint32_t ImageCount; // >= MinImageCount
87-
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
84+
VkDescriptorPool DescriptorPool; // See requirements in note above; ignored if using DescriptorPoolSize > 0
85+
VkRenderPass RenderPass; // Ignored if using dynamic rendering
86+
uint32_t MinImageCount; // >= 2
87+
uint32_t ImageCount; // >= MinImageCount
88+
VkSampleCountFlagBits MSAASamples; // 0 defaults to VK_SAMPLE_COUNT_1_BIT
8889

8990
// (Optional)
9091
VkPipelineCache PipelineCache;
@@ -103,7 +104,7 @@ struct ImGui_ImplVulkan_InitInfo
103104
// (Optional) Allocation, Debugging
104105
const VkAllocationCallbacks* Allocator;
105106
void (*CheckVkResultFn)(VkResult err);
106-
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
107+
VkDeviceSize MinAllocationSize; // Minimum allocation size. Set to 1024*1024 to satisfy zealous best practices validation layer and waste a little memory.
107108
};
108109

109110
// Follow "Getting Started" link and check examples/ folder to learn about using backends!

docs/CHANGELOG.txt

+4
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ Other changes:
8080
- Backends: SDL2, SDL3: Using SDL_OpenURL() in platform_io.Platform_OpenInShellFn
8181
handler. (#7660) [@achabense]
8282
- Backends: Metal: Fixed a crash on application resources. (#8367, #7419) [@anszom]
83+
- Backends: Vulkan: Added ApiVersion field in ImGui_ImplVulkan_InitInfo.
84+
Default to header version if unspecified. (#8326, #8365) [@mklefrancois]
85+
- Backends: Vulkan: Dynamic rendering path loads "vkCmdBeginRendering/vkCmdEndRendering"
86+
(without -KHR suffix) on API 1.3. (#8326, #8365) [@mklefrancois]
8387
- Backends: WebGPU: Fix for DAWN API rename WGPUProgrammableStageDescriptor -> WGPUComputeState.
8488
[@PhantomCloak] (#8369)
8589

0 commit comments

Comments
 (0)