xo-imgui: refactor ex4a: begin_single_time_commands()

This commit is contained in:
Roland Conybeare 2025-11-11 10:53:58 -05:00
commit 876d90a816
2 changed files with 26 additions and 19 deletions

View file

@ -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 */

View file

@ -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);