Files
Seele/src/Engine/Graphics/Vulkan/Queue.cpp
T

63 lines
1.7 KiB
C++
Raw Normal View History

2023-10-26 18:37:29 +02:00
#include "Queue.h"
#include "Graphics.h"
#include "Allocator.h"
2023-11-15 17:42:57 +01:00
#include "Command.h"
2020-03-24 21:05:32 +01:00
using namespace Seele;
using namespace Seele::Vulkan;
2020-04-12 15:47:19 +02:00
Queue::Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex)
2021-04-01 16:40:14 +02:00
: graphics(graphics)
, familyIndex(familyIndex)
, queueType(queueType)
2020-05-05 01:51:13 +02:00
{
2020-03-24 21:05:32 +01:00
vkGetDeviceQueue(graphics->getDevice(), familyIndex, queueIndex, &queue);
}
Queue::~Queue()
{
2020-04-12 15:47:19 +02:00
}
2023-11-15 17:42:57 +01:00
void Queue::submitCommandBuffer(PCommand command, uint32 numSignalSemaphores, VkSemaphore *signalSemaphores)
2020-04-12 15:47:19 +02:00
{
2023-11-15 17:42:57 +01:00
std::unique_lock lock(queueLock);
assert(command->state == Command::State::End);
2023-11-15 17:42:57 +01:00
PFence fence = command->fence;
assert(!fence->isSignaled());
2023-11-15 17:42:57 +01:00
VkCommandBuffer cmdHandle = command->handle;
Array<VkSemaphore> waitSemaphores;
2023-11-15 17:42:57 +01:00
if (command->waitSemaphores.size() > 0)
2020-04-12 15:47:19 +02:00
{
2023-11-15 17:42:57 +01:00
for (PSemaphore semaphore : command->waitSemaphores)
2020-04-12 15:47:19 +02:00
{
waitSemaphores.add(semaphore->getHandle());
2020-04-12 15:47:19 +02:00
}
}
2023-11-15 17:42:57 +01:00
VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.pNext = nullptr,
.waitSemaphoreCount = static_cast<uint32>(command->waitSemaphores.size()),
.pWaitSemaphores = waitSemaphores.data(),
.pWaitDstStageMask = command->waitFlags.data(),
.commandBufferCount = 1,
.pCommandBuffers = &cmdHandle,
.signalSemaphoreCount = static_cast<uint32>(numSignalSemaphores),
.pSignalSemaphores = signalSemaphores,
};
VK_CHECK(vkQueueSubmit(queue, 1, &submitInfo, fence->getHandle()));
2023-11-15 17:42:57 +01:00
command->state = Command::State::Submit;
command->waitFlags.clear();
command->waitSemaphores.clear();
if (Gfx::waitIdleOnSubmit)
{
fence->wait(200 * 1000ull);
}
2023-11-15 17:42:57 +01:00
command->checkFence();
2020-03-24 21:05:32 +01:00
}