15 #include <vsg/core/Object.h>
16 #include <vsg/vk/Fence.h>
17 #include <vsg/vk/Queue.h>
26 void submitCommandsToQueue(CommandPool* commandPool, Fence* fence, uint64_t timeout, Queue* queue, F
function)
28 auto commandBuffer = commandPool->allocate();
30 VkCommandBufferBeginInfo beginInfo = {};
31 beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
32 beginInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
34 vkBeginCommandBuffer(*commandBuffer, &beginInfo);
36 function(*commandBuffer);
38 vkEndCommandBuffer(*commandBuffer);
40 VkSubmitInfo submitInfo = {};
41 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
42 submitInfo.commandBufferCount = 1;
43 submitInfo.pCommandBuffers = commandBuffer->data();
48 queue->submit(submitInfo, fence);
49 if (timeout > 0) fence->wait(timeout);
53 queue->submit(submitInfo, VK_NULL_HANDLE);
60 void submitCommandsToQueue(CommandPool* commandPool, Queue* queue, F
function)
62 submitCommandsToQueue(commandPool,
nullptr, 0, queue,
function);