#include "utils.h" #include "renderer.h" VkCommandBuffer begin_single_command(struct vlkn_renderer *ren) { VkCommandBufferAllocateInfo alloc_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO, .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY, .commandPool = ren->command.pool, .commandBufferCount = 1 }; VkCommandBuffer buffer; vkAllocateCommandBuffers(ren->gpu.device, &alloc_info, &buffer); VkCommandBufferBeginInfo begin_info = { .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO, .flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT }; vkBeginCommandBuffer(buffer, &begin_info); return buffer; } void end_single_command(struct vlkn_renderer *ren, VkCommandBuffer buffer) { vkEndCommandBuffer(buffer); VkSubmitInfo submit_info = { .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO, .commandBufferCount = 1, .pCommandBuffers = &buffer }; vkQueueSubmit(ren->gpu.gfx_queue, 1, &submit_info, VK_NULL_HANDLE); vkQueueWaitIdle(ren->gpu.gfx_queue); vkFreeCommandBuffers(ren->gpu.device, ren->command.pool, 1, &buffer); }