Implementing Commandbuffers

This commit is contained in:
Dynamitos
2020-03-24 21:05:32 +01:00
parent fda46a7ab8
commit ae92439164
27 changed files with 779 additions and 311 deletions
@@ -1,38 +1,90 @@
#pragma once
#include "VulkanGraphicsResources.h"
#include "VulkanQueue.h"
namespace Seele
{
namespace Vulkan
{
class CmdBufferBase : public RenderCommandBase
DECLARE_REF(RenderPass);
DECLARE_REF(Framebuffer);
class CmdBufferBase : public Gfx::RenderCommandBase
{
public:
private:
CmdBufferBase(WGraphics graphics, VkCommandPool cmdPool);
virtual ~CmdBufferBase();
inline VkCommandBuffer getHandle()
{
return handle;
}
void reset();
VkViewport currentViewport;
VkRect2D currentScissor;
protected:
WGraphics graphics;
VkCommandBuffer handle;
VkCommandPool owner;
};
DEFINE_REF(CmdBuffer);
DEFINE_REF(CmdBufferBase);
DECLARE_REF(SecondaryCmdBuffer);
class CmdBuffer : public CmdBufferBase
{
public:
CmdBuffer(WGraphics graphics, VkCommandPool cmdPool);
virtual ~CmdBuffer();
void begin();
void end();
void beginRenderPass(WRenderPass renderPass, WFramebuffer framebuffer);
void endRenderPass();
void executeCommands(Array<WSecondaryCmdBuffer> secondaryCommands);
void addWaitSemaphore(VkPipelineStageFlags stages, PSemaphore waitSemaphore);
enum State
{
ReadyBegin,
InsideBegin,
RenderPassActive,
Ended,
Submitted,
};
private:
WRenderPass renderPass;
WFramebuffer framebuffer;
uint32 subpassIndex;
State state;
friend class SecondaryCmdBuffer;
};
DEFINE_REF(CmdBuffer);
class SecondaryCmdBuffer : public CmdBufferBase
{
public:
SecondaryCmdBuffer(WGraphics graphics, VkCommandPool cmdPool);
virtual ~SecondaryCmdBuffer();
void begin(WCmdBuffer parent);
void end();
private:
};
DEFINE_REF(SecondaryCmdBuffer);
class CommandBufferManager
{
public:
CommandBufferManager(Vulkan::PGraphics graphics, PVulkanQueue queue);
CommandBufferManager(WGraphics graphics, WQueue queue);
virtual ~CommandBufferManager();
PCmdBuffer getCommands();
PSecondaryCommandBuffer createSecondaryCmdBuffer();
PSecondaryCmdBuffer createSecondaryCmdBuffer();
void submitCommands(PSemaphore signalSemaphore = nullptr);
void waitForBuffer(PCommandbuffer cmdBuffer, float timeToWait = 1.0f);
void waitForCommands(PCmdBuffer cmdBuffer, float timeToWait = 1.0f);
private:
WGraphics graphics;
VkCommandPool commandPool;
QueueType queueType;
WQueue queue;
uint32 queueFamilyIndex;
Array<Vulkan::PCmdBuffer> allocatedBuffers;
PCmdBuffer activeCmdBuffer;
Array<PCmdBuffer> allocatedBuffers;
};
DEFINE_REF(VulkanCommandBufferManager);
DEFINE_REF(CommandBufferManager);
}
}