diff --git a/xo-imgui/example/ex4a/VulkanApp.cpp b/xo-imgui/example/ex4a/VulkanApp.cpp index 0ec3a6c3..3e3810a6 100644 --- a/xo-imgui/example/ex4a/VulkanApp.cpp +++ b/xo-imgui/example/ex4a/VulkanApp.cpp @@ -422,11 +422,32 @@ MinimalImGuiVulkan::init_imgui() //ImGui_ImplVulkan_Init(&init_info, render_pass_); // Upload Fonts - VkCommandBuffer command_buffer = beginSingleTimeCommands(); + VkCommandBuffer command_buffer = begin_single_time_commands(); ImGui_ImplVulkan_CreateFontsTexture(); endSingleTimeCommands(command_buffer); //ImGui_ImplVulkan_DestroyFontUploadObjects(); } +VkCommandBuffer +MinimalImGuiVulkan::begin_single_time_commands() +{ + VkCommandBufferAllocateInfo alloc_info{}; + alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; + alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; + alloc_info.commandPool = command_pool_; + alloc_info.commandBufferCount = 1; + + VkCommandBuffer cmdbuf; + vkAllocateCommandBuffers(device_, &alloc_info, &cmdbuf); + + VkCommandBufferBeginInfo begin_info{}; + begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + begin_info.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; + + vkBeginCommandBuffer(cmdbuf, &begin_info); + + return cmdbuf; +} + /* end VulkanApp.cpp */ diff --git a/xo-imgui/example/ex4a/VulkanApp.hpp b/xo-imgui/example/ex4a/VulkanApp.hpp index 77b431fc..1bffd1b2 100644 --- a/xo-imgui/example/ex4a/VulkanApp.hpp +++ b/xo-imgui/example/ex4a/VulkanApp.hpp @@ -93,24 +93,10 @@ private: /* setup imgui "framework" */ void init_imgui(); - VkCommandBuffer beginSingleTimeCommands() { - VkCommandBufferAllocateInfo allocInfo{}; - allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; - allocInfo.commandPool = command_pool_; - allocInfo.commandBufferCount = 1; - - VkCommandBuffer commandBuffer; - vkAllocateCommandBuffers(device_, &allocInfo, &commandBuffer); - - VkCommandBufferBeginInfo beginInfo{}; - beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT; - - vkBeginCommandBuffer(commandBuffer, &beginInfo); - - return commandBuffer; - } + /* Allocate buffer for 'single-time' commands (to be run once?). + * Pair with call to end_single_time_commands() + */ + VkCommandBuffer begin_single_time_commands(); void endSingleTimeCommands(VkCommandBuffer commandBuffer) { vkEndCommandBuffer(commandBuffer);