|
@@ -1,6 +1,8 @@
|
|
|
// dear imgui: Renderer for Vulkan
|
|
|
// This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..)
|
|
|
|
|
|
+// Implemented features:
|
|
|
+// [X] Renderer: Support for large meshes (64k+ vertices) with 16-bits indices.
|
|
|
// Missing features:
|
|
|
// [ ] Renderer: User texture binding. Changes of ImTextureID aren't supported by this binding! See https://github.com/ocornut/imgui/pull/914
|
|
|
|
|
@@ -20,6 +22,7 @@
|
|
|
|
|
|
// CHANGELOG
|
|
|
// (minor and older changes stripped away, please see git history for details)
|
|
|
+// 2019-05-29: Vulkan: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_HasVtxOffset flag.
|
|
|
// 2019-04-30: Vulkan: Added support for special ImDrawCallback_ResetRenderState callback to reset render state.
|
|
|
// 2019-04-04: *BREAKING CHANGE*: Vulkan: Added ImageCount/MinImageCount fields in ImGui_ImplVulkan_InitInfo, required for initialization (was previously a hard #define IMGUI_VK_QUEUED_FRAMES 2). Added ImGui_ImplVulkan_SetMinImageCount().
|
|
|
// 2019-04-04: Vulkan: Added VkInstance argument to ImGui_ImplVulkanH_CreateWindow() optional helper.
|
|
@@ -375,8 +378,9 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|
|
ImVec2 clip_scale = draw_data->FramebufferScale; // (1,1) unless using retina display which are often (2,2)
|
|
|
|
|
|
// Render command lists
|
|
|
- int vtx_offset = 0;
|
|
|
- int idx_offset = 0;
|
|
|
+ // (Because we merged all buffers into a single one, we maintain our own offset into them)
|
|
|
+ int global_vtx_offset = 0;
|
|
|
+ int global_idx_offset = 0;
|
|
|
for (int n = 0; n < draw_data->CmdListsCount; n++)
|
|
|
{
|
|
|
const ImDrawList* cmd_list = draw_data->CmdLists[n];
|
|
@@ -418,12 +422,12 @@ void ImGui_ImplVulkan_RenderDrawData(ImDrawData* draw_data, VkCommandBuffer comm
|
|
|
vkCmdSetScissor(command_buffer, 0, 1, &scissor);
|
|
|
|
|
|
// Draw
|
|
|
- vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, idx_offset, vtx_offset, 0);
|
|
|
+ vkCmdDrawIndexed(command_buffer, pcmd->ElemCount, 1, pcmd->IdxOffset + global_idx_offset, pcmd->VtxOffset + global_vtx_offset, 0);
|
|
|
}
|
|
|
}
|
|
|
- idx_offset += pcmd->ElemCount;
|
|
|
}
|
|
|
- vtx_offset += cmd_list->VtxBuffer.Size;
|
|
|
+ global_idx_offset += cmd_list->IdxBuffer.Size;
|
|
|
+ global_vtx_offset += cmd_list->VtxBuffer.Size;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -801,6 +805,7 @@ bool ImGui_ImplVulkan_Init(ImGui_ImplVulkan_InitInfo* info, VkRenderPass rend
|
|
|
{
|
|
|
ImGuiIO& io = ImGui::GetIO();
|
|
|
io.BackendRendererName = "imgui_impl_vulkan";
|
|
|
+ io.BackendFlags |= ImGuiBackendFlags_HasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
|
|
|
|
|
IM_ASSERT(info->Instance != VK_NULL_HANDLE);
|
|
|
IM_ASSERT(info->PhysicalDevice != VK_NULL_HANDLE);
|