Implementing Commandbuffers
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user