2020-03-24 21:05:32 +01:00
|
|
|
#include "VulkanGraphicsResources.h"
|
|
|
|
|
#include "VulkanInitializer.h"
|
|
|
|
|
#include "VulkanGraphics.h"
|
|
|
|
|
#include "VulkanGraphicsEnums.h"
|
2020-04-12 15:47:19 +02:00
|
|
|
#include "VulkanCommandBuffer.h"
|
2020-03-24 21:05:32 +01:00
|
|
|
|
|
|
|
|
using namespace Seele;
|
|
|
|
|
using namespace Seele::Vulkan;
|
|
|
|
|
|
2020-04-01 02:17:49 +02:00
|
|
|
Semaphore::Semaphore(PGraphics graphics)
|
2020-03-24 21:05:32 +01:00
|
|
|
: graphics(graphics)
|
|
|
|
|
{
|
|
|
|
|
VkSemaphoreCreateInfo info =
|
|
|
|
|
init::SemaphoreCreateInfo();
|
|
|
|
|
VK_CHECK(vkCreateSemaphore(graphics->getDevice(), &info, nullptr, &handle));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Semaphore::~Semaphore()
|
|
|
|
|
{
|
2020-04-12 15:47:19 +02:00
|
|
|
graphics = nullptr;
|
2020-04-01 02:17:49 +02:00
|
|
|
vkDestroySemaphore(graphics->getDevice(), handle, nullptr);
|
2020-04-12 15:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Fence::Fence(PGraphics graphics)
|
2021-04-01 16:40:14 +02:00
|
|
|
: graphics(graphics)
|
2021-11-14 20:36:53 +01:00
|
|
|
, signaled("Fence")
|
2020-04-12 15:47:19 +02:00
|
|
|
{
|
|
|
|
|
VkFenceCreateInfo info =
|
|
|
|
|
init::FenceCreateInfo(0);
|
|
|
|
|
VK_CHECK(vkCreateFence(graphics->getDevice(), &info, nullptr, &fence));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Fence::~Fence()
|
|
|
|
|
{
|
|
|
|
|
vkDestroyFence(graphics->getDevice(), fence, nullptr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Fence::isSignaled()
|
|
|
|
|
{
|
|
|
|
|
if (signaled)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
VkResult res = vkGetFenceStatus(graphics->getDevice(), fence);
|
|
|
|
|
switch (res)
|
|
|
|
|
{
|
|
|
|
|
case VK_SUCCESS:
|
2021-11-14 20:36:53 +01:00
|
|
|
signaled.raise();
|
2020-04-12 15:47:19 +02:00
|
|
|
return true;
|
|
|
|
|
case VK_NOT_READY:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Fence::reset()
|
|
|
|
|
{
|
|
|
|
|
if (signaled)
|
|
|
|
|
{
|
|
|
|
|
vkResetFences(graphics->getDevice(), 1, &fence);
|
2021-11-14 20:36:53 +01:00
|
|
|
signaled.reset();
|
2020-04-12 15:47:19 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Fence::wait(uint32 timeout)
|
|
|
|
|
{
|
|
|
|
|
VkFence fences[] = {fence};
|
|
|
|
|
VkResult r = vkWaitForFences(graphics->getDevice(), 1, fences, true, timeout * 1000ull);
|
|
|
|
|
switch (r)
|
|
|
|
|
{
|
|
|
|
|
case VK_SUCCESS:
|
2021-11-14 20:36:53 +01:00
|
|
|
signaled.raise();
|
2020-04-12 15:47:19 +02:00
|
|
|
break;
|
|
|
|
|
case VK_TIMEOUT:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
VK_CHECK(r);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-03 11:00:10 +02:00
|
|
|
|
|
|
|
|
VertexDeclaration::VertexDeclaration(const Array<Gfx::VertexElement>& elementList)
|
|
|
|
|
: elementList(elementList)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VertexDeclaration::~VertexDeclaration()
|
|
|
|
|
{
|
|
|
|
|
}
|