Lots of shader changes, basic primitive writing

This commit is contained in:
Dynamitos
2024-05-30 21:24:21 +02:00
parent f278afad66
commit 953c90f2de
18 changed files with 599 additions and 464 deletions
+1
View File
@@ -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();
+22 -17
View File
@@ -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()
{
+8 -1
View File
@@ -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)
+1 -1
View File
@@ -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(), &currentImageIndex);
imageAvailableFences[currentSemaphoreIndex]->submit();
graphics->getGraphicsCommands()->getCommands()->waitForSemaphore(VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, imageAvailableSemaphores[currentSemaphoreIndex]);
}