Light culling crashes, so i remove it for now

This commit is contained in:
Dynamitos
2023-11-17 16:53:37 +01:00
parent 1b2760a4ef
commit a36939eab8
15 changed files with 31 additions and 3476 deletions
+1 -1
View File
@@ -164,7 +164,7 @@ typedef uint32 KeyModifierFlags;
namespace Gfx
{
static constexpr bool useAsyncCompute = true;
static constexpr bool waitIdleOnSubmit = true;
static constexpr bool waitIdleOnSubmit = false;
static constexpr bool useMeshShading = true;
static constexpr uint32 numFramesBuffered = 3;
+1 -1
View File
@@ -24,7 +24,7 @@ struct GraphicsInitializer
: applicationName("SeeleEngine")
, engineName("SeeleEngine")
, windowLayoutFile(nullptr)
, layers{"VK_LAYER_KHRONOS_validation"}
, layers{"VK_LAYER_KHRONOS_validation", "VK_LAYER_LUNARG_monitor"}
, instanceExtensions{}
, deviceExtensions{"VK_KHR_swapchain"}
, windowHandle(nullptr)
+16 -9
View File
@@ -7,7 +7,6 @@
#include "Pipeline.h"
#include "Descriptor.h"
#include "Window.h"
#include <vulkan/vulkan_core.h>
using namespace Seele;
using namespace Seele::Vulkan;
@@ -28,7 +27,9 @@ Command::Command(PGraphics graphics, VkCommandPool cmdPool, PCommandPool pool)
VK_CHECK(vkAllocateCommandBuffers(graphics->getDevice(), &allocInfo, &handle))
fence = new Fence(graphics);
signalSemaphore = new Semaphore(graphics);
state = State::Init;
//std::cout << "Cmd " << handle << " semaphore " << signalSemaphore->getHandle() << std::endl;
}
Command::~Command()
@@ -98,6 +99,7 @@ void Command::executeCommands(const Array<Gfx::PRenderCommand>& commands)
for(auto& descriptor : command->boundDescriptors)
{
boundDescriptors.add(descriptor);
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
}
cmdBuffers[i] = command->getHandle();
}
@@ -119,6 +121,7 @@ void Command::executeCommands(const Array<Gfx::PComputeCommand>& commands)
for(auto& descriptor : command->boundDescriptors)
{
boundDescriptors.add(descriptor);
//std::cout << "Cmd " << handle << " bound descriptor " << descriptor->getHandle() << std::endl;
}
cmdBuffers[i] = command->getHandle();
}
@@ -129,6 +132,7 @@ void Command::waitForSemaphore(VkPipelineStageFlags flags, PSemaphore semaphore)
{
waitSemaphores.add(semaphore);
waitFlags.add(flags);
//std::cout << "Cmd " << handle << " wait for " << semaphore->getHandle() << std::endl;
}
void Command::checkFence()
@@ -136,6 +140,7 @@ void Command::checkFence()
assert(state == State::Submit || !fence->isSignaled());
if (fence->isSignaled())
{
//std::cout << "Cmd " << handle << " was signaled" << std::endl;
vkResetCommandBuffer(handle, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT);
fence->reset();
for(auto& command : executingComputes)
@@ -151,7 +156,7 @@ void Command::checkFence()
for(auto& descriptor : boundDescriptors)
{
descriptor->unbind();
//std::cout << "Unbinding descriptor " << descriptor.cast<DescriptorSet>()->getHandle() << " to cmd " << handle << std::endl;
//std::cout << "Cmd " << handle << " unbind " << descriptor->getHandle() << std::endl;
}
boundDescriptors.clear();
graphics->getDestructionManager()->notifyCmdComplete(this);
@@ -286,7 +291,6 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
assert(descriptorSet->writeDescriptors.size() == 0);
descriptorSet->bind();
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
boundDescriptors.add(descriptorSet.getHandle());
sets[descriptorSet->getSetIndex()] = descriptorSet->getHandle();
}
@@ -321,6 +325,7 @@ void RenderCommand::pushConstants(Gfx::PPipelineLayout layout, Gfx::SeShaderStag
void RenderCommand::draw(uint32 vertexCount, uint32 instanceCount, int32 firstVertex, uint32 firstInstance)
{
graphics->setCheckpointMarker(handle, "Fuck");
assert(threadId == std::this_thread::get_id());
vkCmdDraw(handle, vertexCount, instanceCount, firstVertex, firstInstance);
}
@@ -516,15 +521,15 @@ void CommandPool::submitCommands(PSemaphore signalSemaphore)
{
assert(command->state == Command::State::Begin); // Not in a renderpass
command->end();
Array<VkSemaphore> semaphores = { command->signalSemaphore->getHandle() };
if (signalSemaphore != nullptr)
{
queue->submitCommandBuffer(command, signalSemaphore->getHandle());
semaphores.add(signalSemaphore->getHandle());
}
else
{
queue->submitCommandBuffer(command);
}
queue->submitCommandBuffer(command, semaphores);
//std::cout << "Cmd " << command->getHandle() << " signalling " << command->signalSemaphore->getHandle() << std::endl;
PSemaphore waitSemaphore = command->signalSemaphore;
for (uint32 i = 0; i < allocatedBuffers.size(); ++i)
{
PCommand cmdBuffer = allocatedBuffers[i];
@@ -533,6 +538,7 @@ void CommandPool::submitCommands(PSemaphore signalSemaphore)
{
command = cmdBuffer;
command->begin();
command->waitForSemaphore(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, waitSemaphore);
return;
}
else
@@ -543,4 +549,5 @@ void CommandPool::submitCommands(PSemaphore signalSemaphore)
allocatedBuffers.add(new Command(graphics, commandPool, this));
command = allocatedBuffers.back();
command->begin();
command->waitForSemaphore(VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, waitSemaphore);
}
+1
View File
@@ -48,6 +48,7 @@ private:
PGraphics graphics;
PCommandPool pool;
OFence fence;
OSemaphore signalSemaphore;
State state;
VkViewport currentViewport;
VkRect2D currentScissor;
+5 -5
View File
@@ -57,7 +57,7 @@ public:
: setHandle(VK_NULL_HANDLE)
, graphics(graphics)
, owner(owner)
, currentlyBound(false)
, bindCount(0)
, currentlyInUse(false)
{
}
@@ -72,7 +72,7 @@ public:
constexpr bool isCurrentlyBound() const
{
return currentlyBound;
return bindCount > 0;
}
constexpr bool isCurrentlyInUse() const
{
@@ -80,11 +80,11 @@ public:
}
constexpr void bind()
{
currentlyBound = true;
bindCount++;
}
constexpr void unbind()
{
currentlyBound = false;
bindCount--;
}
constexpr void allocate()
{
@@ -111,7 +111,7 @@ private:
VkDescriptorSet setHandle;
PGraphics graphics;
PDescriptorPool owner;
bool currentlyBound;
uint32 bindCount;
bool currentlyInUse;
friend class DescriptorPool;
friend class Command;
+6 -9
View File
@@ -18,7 +18,7 @@ Queue::~Queue()
{
}
void Queue::submitCommandBuffer(PCommand command, uint32 numSignalSemaphores, VkSemaphore *signalSemaphores)
void Queue::submitCommandBuffer(PCommand command, const Array<VkSemaphore>& signalSemaphores)
{
std::unique_lock lock(queueLock);
assert(command->state == Command::State::End);
@@ -28,14 +28,11 @@ void Queue::submitCommandBuffer(PCommand command, uint32 numSignalSemaphores, Vk
VkCommandBuffer cmdHandle = command->handle;
Array<VkSemaphore> waitSemaphores;
if (command->waitSemaphores.size() > 0)
for (PSemaphore semaphore : command->waitSemaphores)
{
for (PSemaphore semaphore : command->waitSemaphores)
{
waitSemaphores.add(semaphore->getHandle());
}
waitSemaphores.add(semaphore->getHandle());
}
VkSubmitInfo submitInfo = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.pNext = nullptr,
@@ -44,8 +41,8 @@ void Queue::submitCommandBuffer(PCommand command, uint32 numSignalSemaphores, Vk
.pWaitDstStageMask = command->waitFlags.data(),
.commandBufferCount = 1,
.pCommandBuffers = &cmdHandle,
.signalSemaphoreCount = static_cast<uint32>(numSignalSemaphores),
.pSignalSemaphores = signalSemaphores,
.signalSemaphoreCount = static_cast<uint32>(signalSemaphores.size()),
.pSignalSemaphores = signalSemaphores.data(),
};
VK_CHECK(vkQueueSubmit(queue, 1, &submitInfo, command->fence->getHandle()));
+1 -5
View File
@@ -12,11 +12,7 @@ class Queue
public:
Queue(PGraphics graphics, Gfx::QueueType queueType, uint32 familyIndex, uint32 queueIndex);
virtual ~Queue();
void submitCommandBuffer(PCommand command, uint32 numSignalSemaphores = 0, VkSemaphore *signalSemaphore = nullptr);
void submitCommandBuffer(PCommand command, VkSemaphore signalSemaphore)
{
submitCommandBuffer(command, 1, &signalSemaphore);
}
void submitCommandBuffer(PCommand command, const Array<VkSemaphore>& signalSemaphore);
constexpr uint32 getFamilyIndex() const
{
return familyIndex;
-1
View File
@@ -33,7 +33,6 @@ void Window::render()
view->render();
}
gfxHandle->endFrame();
std::cout << "Render" << std::endl;
}
}