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
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 
80  };
81 }
virtual void PrepareAttachments()
Add any attachments to a frame buffer that this subpass may need.
Definition: Subpass.h:33
virtual void CleanUp(entt::registry &t_reg)
Cleanup any allocated resources that you may need a registry for.
Definition: Subpass.h:40
virtual void Draw(CommandBuffer &t_CmdBuf, VkFramebuffer t_PresentFrameBuf, UINT32 t_ActiveFrameInFlight, entt::registry &t_reg, float DeltaTime)=0
A subpass represents one part of a RenderPipeline.
Definition: Subpass.h:25
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...
GraphicsPipeline * GetGraphicsPipeline() const noexcept
Definition: Subpass.h:62
Definition: GraphicsPipeline.h:9
GraphicsPipeline * m_GraphicsPipeline
Layouts created in the constructor via shader reflection.
Definition: Subpass.h:79
Encapsulates functionality of a Vulkan Command buffer.
Definition: CommandBuffer.h:17
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
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
virtual ~Subpass()
Definition: Subpass.cpp:37
Represents a swap chain that can be used throughout the program.
Definition: SwapChain.h:21
const Swapchain * m_SwapChain
Definition: Subpass.h:69
virtual void CreateGraphicsPipeline()=0
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
std::shared_ptr< Fling::Shader > m_FragShader
Definition: Subpass.h:73
std::shared_ptr< Fling::Shader > m_VertexShader
Definition: Subpass.h:71
Class that removes the copy operator and constructor.
Definition: NonCopyable.hpp:10
const LogicalDevice * m_Device
Definition: Subpass.h:68
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_t UINT32
Definition: FlingTypes.h:13
Definition: Engine.h:29
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
const std::vector< VkClearValue > & GetClearValues() const
Definition: Subpass.h:63