Backends: Vulkan: Don't skip drawing when there's no vertexes to ensure that user callbacks are still processed.
diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt
index ad30932..7048018 100644
--- a/docs/CHANGELOG.txt
+++ b/docs/CHANGELOG.txt
@@ -49,6 +49,8 @@
- Backends: Win32: Support for #define NOGDI, won't try to call GetDeviceCaps(). (#3137, #2327)
- Backends: OpenGL: Fixed handling of GL 4.5+ glClipControl(GL_UPPER_LEFT) by inverting the
projection matrix top and bottom values. (#3143, #3146) [@u3shit]
+- Backends: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData
+ structure didn't have any vertices. (#2697) [@kudaba]
-----------------------------------------------------------------------
diff --git a/examples/imgui_impl_vulkan.cpp b/examples/imgui_impl_vulkan.cpp
index 095a7f2..72866dd 100644
--- a/examples/imgui_impl_vulkan.cpp
+++ b/examples/imgui_impl_vulkan.cpp
@@ -22,6 +22,7 @@
// CHANGELOG
// (minor and older changes stripped away, please see git history for details)
+// 2020-04-26: Vulkan: Fixed edge case where render callbacks wouldn't be called if the ImDrawData didn't have vertices.
// 2019-08-01: Vulkan: Added support for specifying multisample count. Set ImGui_ImplVulkan_InitInfo::MSAASamples to one of the VkSampleCountFlagBits values to use, default is non-multisampled as before.
// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag.
// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
@@ -274,6 +275,7 @@
}
// Bind Vertex And Index Buffer:
+ if (draw_data->TotalVtxCount > 0)
{
VkBuffer vertex_buffers[1] = { rb->VertexBuffer };
VkDeviceSize vertex_offset[1] = { 0 };
@@ -314,7 +316,7 @@
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x);
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y);
- if (fb_width <= 0 || fb_height <= 0 || draw_data->TotalVtxCount == 0)
+ if (fb_width <= 0 || fb_height <= 0)
return;
ImGui_ImplVulkan_InitInfo* v = &g_VulkanInitInfo;
@@ -343,6 +345,7 @@
CreateOrResizeBuffer(rb->IndexBuffer, rb->IndexBufferMemory, rb->IndexBufferSize, index_size, VK_BUFFER_USAGE_INDEX_BUFFER_BIT);
// Upload vertex/index data into a single contiguous GPU buffer
+ if (vertex_size > 0)
{
ImDrawVert* vtx_dst = NULL;
ImDrawIdx* idx_dst = NULL;