| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

CommandBuffer.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "FlingVulkan.h"
4
5 namespace Fling
6 {
7 class LogicalDevice;
8 class FrameBuffer;
9
10 // #TODO Pipeline state class definition (just grab it from the official vulkan samples)
11 // #TODO Resource binding state class definition
12
17 class CommandBuffer
18 {
19 public:
20 enum class ResetMode
21 {
22 ResetPool,
23 ResetIndividually,
24 AlwaysAllocate,
25 };
26
27 enum class State
28 {
29 Invalid,
30 Initial,
31 Recording,
32 Executable,
33 };
34
35 CommandBuffer(const LogicalDevice* t_Device, VkCommandPool t_CmdPool);
36 ~CommandBuffer();
37
38 inline VkCommandBuffer GetHandle() const { return m_Handle; }
39 inline const LogicalDevice* GetDevice() const { return m_Device; }
40 inline const VkCommandPool& GetPoolHandle() const { return m_Pool; }
41
43 void Begin(VkCommandBufferUsageFlagBits t_Usage = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT);
44
45 void BeginRenderPass(FrameBuffer& t_frameBuf, const std::vector<VkClearValue>& t_ClearVales);
46
47 void NextSubpass();
48
49 void BindPipeline(VkPipelineBindPoint t_BindPoint, VkPipeline t_Pipeline);
50
51 void SetViewport(UINT32 first_viewport, const std::vector<VkViewport>& viewports);
52
53 void SetScissor(UINT32 first_scissor, const std::vector<VkRect2D> &scissors);
54
55 void EndRenderPass();
56
58 void End();
59
60 inline bool IsRecording() const { return m_State == State::Recording; }
61
62 private:
63 const LogicalDevice* m_Device;
64
65 const VkCommandPool m_Pool;
66
67 VkCommandBuffer m_Handle = VK_NULL_HANDLE;
68
69 // Keep track of the state of this command buffer
70 State m_State = State::Initial;
71
72 };
73 } // namespace Fling
Fling::CommandBuffer::End
void End()
Stop recording commands to the command buffer.
Definition: CommandBuffer.cpp:97
Fling::CommandBuffer::m_Device
const LogicalDevice * m_Device
Definition: CommandBuffer.h:63
FlingVulkan.h
Fling::CommandBuffer::ResetMode
ResetMode
Definition: CommandBuffer.h:20
Fling::CommandBuffer::State::Recording
Fling::CommandBuffer
Encapsulates functionality of a Vulkan Command buffer.
Definition: CommandBuffer.h:17
Fling::LogicalDevice
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
Fling::CommandBuffer::IsRecording
bool IsRecording() const
Definition: CommandBuffer.h:60
Fling::CommandBuffer::~CommandBuffer
~CommandBuffer()
Definition: CommandBuffer.cpp:28
Fling::CommandBuffer::CommandBuffer
CommandBuffer(const LogicalDevice *t_Device, VkCommandPool t_CmdPool)
Definition: CommandBuffer.cpp:9
Fling::CommandBuffer::SetScissor
void SetScissor(UINT32 first_scissor, const std::vector< VkRect2D > &scissors)
Definition: CommandBuffer.cpp:87
Fling::CommandBuffer::GetPoolHandle
const VkCommandPool & GetPoolHandle() const
Definition: CommandBuffer.h:40
Fling::CommandBuffer::GetDevice
const LogicalDevice * GetDevice() const
Definition: CommandBuffer.h:39
Fling::CommandBuffer::m_Pool
const VkCommandPool m_Pool
Definition: CommandBuffer.h:65
Fling::CommandBuffer::m_Handle
VkCommandBuffer m_Handle
Definition: CommandBuffer.h:67
Fling::CommandBuffer::ResetMode::AlwaysAllocate
Fling::CommandBuffer::BeginRenderPass
void BeginRenderPass(FrameBuffer &t_frameBuf, const std::vector< VkClearValue > &t_ClearVales)
Definition: CommandBuffer.cpp:51
Fling::CommandBuffer::ResetMode::ResetPool
Fling::FrameBuffer
Definition: FrameBuffer.h:67
Fling::CommandBuffer::BindPipeline
void BindPipeline(VkPipelineBindPoint t_BindPoint, VkPipeline t_Pipeline)
Definition: CommandBuffer.cpp:77
Fling::CommandBuffer::State::Initial
Fling::CommandBuffer::m_State
State m_State
Definition: CommandBuffer.h:70
Fling::CommandBuffer::NextSubpass
void NextSubpass()
Definition: CommandBuffer.cpp:70
Fling::CommandBuffer::SetViewport
void SetViewport(UINT32 first_viewport, const std::vector< VkViewport > &viewports)
Definition: CommandBuffer.cpp:82
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling::CommandBuffer::EndRenderPass
void EndRenderPass()
Definition: CommandBuffer.cpp:92
Fling
Definition: Engine.h:29
Fling::CommandBuffer::GetHandle
VkCommandBuffer GetHandle() const
Definition: CommandBuffer.h:38
Fling::CommandBuffer::ResetMode::ResetIndividually
Fling::CommandBuffer::State
State
Definition: CommandBuffer.h:27
Fling::CommandBuffer::Begin
void Begin(VkCommandBufferUsageFlagBits t_Usage=VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT)
Begin recording for this command buffer.
Definition: CommandBuffer.cpp:38