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

Subpass.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "Shader.h"
4 #include "NonCopyable.hpp"
5
6 #include <entt/entity/registry.hpp>
7 #include <entt/entity/helper.hpp>
8
9 namespace Fling
10 {
11 class CommandBuffer;
12 class LogicalDevice;
13 class FrameBuffer;
14 class Swapchain;
15 class GraphicsPipeline;
16
25 class Subpass : public NonCopyable
26 {
27 public:
28 Subpass(const LogicalDevice* t_Dev, const Swapchain* t_Swap, std::shared_ptr<Fling::Shader> t_Vert, std::shared_ptr<Fling::Shader> t_Frag);
29
30 virtual ~Subpass();
31
33 virtual void PrepareAttachments() {}
34
35 virtual void CreateGraphicsPipeline() = 0;
36
37 virtual void Draw(CommandBuffer& t_CmdBuf, VkFramebuffer t_PresentFrameBuf, UINT32 t_ActiveFrameInFlight, entt::registry& t_reg, float DeltaTime) = 0;
38
40 virtual void CleanUp(entt::registry& t_reg) {}
41
47 virtual void CreateDescriptorSets(VkDescriptorPool t_Pool, entt::registry& t_reg) = 0;
48
53 virtual void GatherPresentDependencies(std::vector<CommandBuffer*>& t_CmdBuffs, std::vector<VkSemaphore>& t_Deps, UINT32 t_ActiveFrameIndex, UINT32 t_CurrentFrameInFlight) {}
54
59 virtual void GatherPresentBuffers(std::vector<CommandBuffer*>& t_CmdBuffs, UINT32 t_ActiveFrameIndex) {}
60
61
62 inline GraphicsPipeline* GetGraphicsPipeline() const noexcept { return m_GraphicsPipeline; }
63 inline const std::vector<VkClearValue>& GetClearValues() const { return m_ClearValues; }
64
65 protected:
66
67 // Get default graphics Pipeline
68 const LogicalDevice* m_Device;
69 const Swapchain* m_SwapChain;
70
71 std::shared_ptr<Fling::Shader> m_VertexShader;
72
73 std::shared_ptr<Fling::Shader> m_FragShader;
74
76 std::vector<VkClearValue> m_ClearValues = std::vector<VkClearValue>(2);
77
79 GraphicsPipeline* m_GraphicsPipeline = nullptr;
80 };
81 }
Fling::Subpass::PrepareAttachments
virtual void PrepareAttachments()
Add any attachments to a frame buffer that this subpass may need.
Definition: Subpass.h:33
Fling::Subpass::CleanUp
virtual void CleanUp(entt::registry &t_reg)
Cleanup any allocated resources that you may need a registry for.
Definition: Subpass.h:40
Fling::Subpass::Draw
virtual void Draw(CommandBuffer &t_CmdBuf, VkFramebuffer t_PresentFrameBuf, UINT32 t_ActiveFrameInFlight, entt::registry &t_reg, float DeltaTime)=0
Fling::Subpass
A subpass represents one part of a RenderPipeline.
Definition: Subpass.h:25
Fling::Subpass::CreateDescriptorSets
virtual void CreateDescriptorSets(VkDescriptorPool t_Pool, entt::registry &t_reg)=0
Given the frame buffers and the registry, create any descriptor sets that we may need Assumes that th...
Fling::Subpass::GetGraphicsPipeline
GraphicsPipeline * GetGraphicsPipeline() const noexcept
Definition: Subpass.h:62
Fling::GraphicsPipeline
Definition: GraphicsPipeline.h:9
Fling::Subpass::m_GraphicsPipeline
GraphicsPipeline * m_GraphicsPipeline
Layouts created in the constructor via shader reflection.
Definition: Subpass.h:79
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::Subpass::GatherPresentDependencies
virtual void GatherPresentDependencies(std::vector< CommandBuffer *> &t_CmdBuffs, std::vector< VkSemaphore > &t_Deps, UINT32 t_ActiveFrameIndex, UINT32 t_CurrentFrameInFlight)
If a subpass has a command buffer that the final swap chain presentation is dependent on...
Definition: Subpass.h:53
Shader.h
Fling::Subpass::~Subpass
virtual ~Subpass()
Definition: Subpass.cpp:37
Fling::Swapchain
Represents a swap chain that can be used throughout the program.
Definition: SwapChain.h:21
Fling::Subpass::m_SwapChain
const Swapchain * m_SwapChain
Definition: Subpass.h:69
NonCopyable.hpp
Fling::Subpass::CreateGraphicsPipeline
virtual void CreateGraphicsPipeline()=0
Fling::Subpass::Subpass
Subpass(const LogicalDevice *t_Dev, const Swapchain *t_Swap, std::shared_ptr< Fling::Shader > t_Vert, std::shared_ptr< Fling::Shader > t_Frag)
Definition: Subpass.cpp:9
Fling::Subpass::m_FragShader
std::shared_ptr< Fling::Shader > m_FragShader
Definition: Subpass.h:73
Fling::Subpass::m_VertexShader
std::shared_ptr< Fling::Shader > m_VertexShader
Definition: Subpass.h:71
Fling::NonCopyable
Class that removes the copy operator and constructor.
Definition: NonCopyable.hpp:10
Fling::Subpass::m_Device
const LogicalDevice * m_Device
Definition: Subpass.h:68
Fling::Subpass::m_ClearValues
std::vector< VkClearValue > m_ClearValues
The clear values that will be used when building the command buffer to run this subpass.
Definition: Subpass.h:76
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling
Definition: Engine.h:29
Fling::Subpass::GatherPresentBuffers
virtual void GatherPresentBuffers(std::vector< CommandBuffer *> &t_CmdBuffs, UINT32 t_ActiveFrameIndex)
If a subpass has an additional command buffer to add to the final swap chain draw submission but it i...
Definition: Subpass.h:59
Fling::Subpass::GetClearValues
const std::vector< VkClearValue > & GetClearValues() const
Definition: Subpass.h:63