diff --git a/xo-imgui/example/ex4a/VulkanApp.cpp b/xo-imgui/example/ex4a/VulkanApp.cpp index 3e3810a6..18bce2d1 100644 --- a/xo-imgui/example/ex4a/VulkanApp.cpp +++ b/xo-imgui/example/ex4a/VulkanApp.cpp @@ -424,7 +424,7 @@ MinimalImGuiVulkan::init_imgui() // Upload Fonts VkCommandBuffer command_buffer = begin_single_time_commands(); ImGui_ImplVulkan_CreateFontsTexture(); - endSingleTimeCommands(command_buffer); + this->end_single_time_commands(command_buffer); //ImGui_ImplVulkan_DestroyFontUploadObjects(); } @@ -450,4 +450,20 @@ MinimalImGuiVulkan::begin_single_time_commands() return cmdbuf; } +void +MinimalImGuiVulkan::end_single_time_commands(VkCommandBuffer commandBuffer) +{ + vkEndCommandBuffer(commandBuffer); + + VkSubmitInfo submit_info{}; + submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; + submit_info.commandBufferCount = 1; + submit_info.pCommandBuffers = &commandBuffer; + + vkQueueSubmit(graphics_queue_, 1, &submit_info, VK_NULL_HANDLE); + vkQueueWaitIdle(graphics_queue_); + + vkFreeCommandBuffers(device_, command_pool_, 1, &commandBuffer); +} + /* end VulkanApp.cpp */ diff --git a/xo-imgui/example/ex4a/VulkanApp.hpp b/xo-imgui/example/ex4a/VulkanApp.hpp index 1bffd1b2..87524eec 100644 --- a/xo-imgui/example/ex4a/VulkanApp.hpp +++ b/xo-imgui/example/ex4a/VulkanApp.hpp @@ -98,19 +98,10 @@ private: */ VkCommandBuffer begin_single_time_commands(); - void endSingleTimeCommands(VkCommandBuffer commandBuffer) { - vkEndCommandBuffer(commandBuffer); - - VkSubmitInfo submitInfo{}; - submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &commandBuffer; - - vkQueueSubmit(graphics_queue_, 1, &submitInfo, VK_NULL_HANDLE); - vkQueueWaitIdle(graphics_queue_); - - vkFreeCommandBuffers(device_, command_pool_, 1, &commandBuffer); - } + /* complete command buffer begun with begin_single_time_commands(); + * also submit, wait for completion + cleanup + */ + void end_single_time_commands(VkCommandBuffer commandBuffer); void main_loop() { SDL_Event event;