Lots of shader changes, basic primitive writing
This commit is contained in:
@@ -47,6 +47,7 @@ void Queue::submitCommandBuffer(PCommand command, const Array<VkSemaphore>& sign
|
||||
};
|
||||
|
||||
VK_CHECK(vkQueueSubmit(queue, 1, &submitInfo, command->fence->getHandle()));
|
||||
command->fence->submit();
|
||||
command->state = Command::State::Submit;
|
||||
command->waitFlags.clear();
|
||||
command->waitSemaphores.clear();
|
||||
|
||||
@@ -20,38 +20,40 @@ Semaphore::Semaphore(PGraphics graphics)
|
||||
|
||||
Semaphore::~Semaphore()
|
||||
{
|
||||
//graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle);
|
||||
// graphics->getDestructionManager()->queueSemaphore(graphics->getGraphicsCommands()->getCommands(), handle);
|
||||
}
|
||||
|
||||
|
||||
Fence::Fence(PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
, signaled(false)
|
||||
: graphics(graphics), status(Status::Ready)
|
||||
{
|
||||
VkFenceCreateInfo info = {
|
||||
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.flags = 0
|
||||
};
|
||||
.flags = 0};
|
||||
VK_CHECK(vkCreateFence(graphics->getDevice(), &info, nullptr, &fence));
|
||||
}
|
||||
|
||||
Fence::~Fence()
|
||||
{
|
||||
vkWaitForFences(graphics->getDevice(), 1, &fence, true, 100000);
|
||||
vkWaitForFences(graphics->getDevice(), 1, &fence, true, 10000000);
|
||||
vkDestroyFence(graphics->getDevice(), fence, nullptr);
|
||||
}
|
||||
|
||||
void Fence::submit()
|
||||
{
|
||||
status = Status::InUse;
|
||||
}
|
||||
|
||||
bool Fence::isSignaled()
|
||||
{
|
||||
if (signaled)
|
||||
if (status == Status::Signalled)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
VkResult r = vkGetFenceStatus(graphics->getDevice(), fence);
|
||||
if (r == VK_SUCCESS)
|
||||
{
|
||||
signaled = true;
|
||||
status = Status::Signalled;
|
||||
return true;
|
||||
}
|
||||
if (r == VK_NOT_READY)
|
||||
@@ -67,11 +69,14 @@ bool Fence::isSignaled()
|
||||
|
||||
void Fence::reset()
|
||||
{
|
||||
if (signaled)
|
||||
while (status == Status::InUse)
|
||||
{
|
||||
wait(1000000);
|
||||
}
|
||||
if (status == Status::Signalled)
|
||||
{
|
||||
VK_CHECK(vkResetFences(graphics->getDevice(), 1, &fence));
|
||||
//std::cout << vkGetFenceStatus(graphics->getDevice(), fence) << std::endl;
|
||||
signaled = false;
|
||||
status = Status::Ready;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +86,7 @@ void Fence::wait(uint64 timeout)
|
||||
VkResult r = vkWaitForFences(graphics->getDevice(), 1, fences, true, timeout);
|
||||
if (r == VK_SUCCESS)
|
||||
{
|
||||
signaled = true;
|
||||
status = Status::Signalled;
|
||||
}
|
||||
else if (r == VK_TIMEOUT)
|
||||
{
|
||||
@@ -111,7 +116,7 @@ void DestructionManager::notifyCommandComplete()
|
||||
{
|
||||
for (size_t i = 0; i < resources.size(); ++i)
|
||||
{
|
||||
if(!resources[i]->isCurrentlyBound())
|
||||
if (!resources[i]->isCurrentlyBound())
|
||||
{
|
||||
resources.removeAt(i, false);
|
||||
i--;
|
||||
@@ -131,9 +136,9 @@ SamplerHandle::~SamplerHandle()
|
||||
}
|
||||
|
||||
Sampler::Sampler(PGraphics graphics, VkSamplerCreateInfo createInfo)
|
||||
: graphics(graphics)
|
||||
, handle(new SamplerHandle(graphics, createInfo))
|
||||
{}
|
||||
: graphics(graphics), handle(new SamplerHandle(graphics, createInfo))
|
||||
{
|
||||
}
|
||||
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ class Fence
|
||||
public:
|
||||
Fence(PGraphics graphics);
|
||||
~Fence();
|
||||
void submit();
|
||||
bool isSignaled();
|
||||
void reset();
|
||||
constexpr VkFence getHandle() const
|
||||
@@ -46,7 +47,13 @@ public:
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
bool signaled;
|
||||
enum class Status
|
||||
{
|
||||
Ready,
|
||||
InUse,
|
||||
Signalled,
|
||||
};
|
||||
Status status;
|
||||
VkFence fence;
|
||||
};
|
||||
DEFINE_REF(Fence)
|
||||
|
||||
@@ -114,9 +114,9 @@ void Window::pollInput()
|
||||
|
||||
void Window::beginFrame()
|
||||
{
|
||||
imageAvailableFences[currentSemaphoreIndex]->wait(10000000000);
|
||||
imageAvailableFences[currentSemaphoreIndex]->reset();
|
||||
vkAcquireNextImageKHR(graphics->getDevice(), swapchain, std::numeric_limits<uint64>::max(), imageAvailableSemaphores[currentSemaphoreIndex]->getHandle(), imageAvailableFences[currentSemaphoreIndex]->getHandle(), ¤tImageIndex);
|
||||
imageAvailableFences[currentSemaphoreIndex]->submit();
|
||||
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user