Fling Engine  0.00.1
Fling Engine is a game engine written in Vulkan
GeometrySubpass.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Subpass.h"
4 
7 #include "Lighting/Lighting.hpp"
8 
9 namespace Fling
10 {
11  class CommandBuffer;
12  class LogicalDevice;
13  class FrameBuffer;
14  class MeshRenderer;
15  class Swapchain;
16  class GraphicsPipeline;
17  class Model;
18  class Buffer;
19  class FirstPersonCamera;
20 
27  {
29  static const UINT32 MaxDirectionalLights = 8;
30 
32  static const UINT32 MaxPointLights = 128;
33  };
34 
36  struct LightingUbo
37  {
38  alignas(4) UINT32 DirLightCount = 0;
39  alignas(4) UINT32 PointLightCount = 0;
40 
42 
43  alignas(16) PointLight PointLightBuffer[DeferredLightSettings::MaxPointLights] = {};
44  };
45 
47  {
48  glm::mat4 Projection;
49  glm::mat4 ModelView;
50  glm::vec4 CamPos = {};
51  float Gamma = 2.2f;
52  float Exposure = 4.5f;
53  };
54 
61  class GeometrySubpass : public Subpass
62  {
63  public:
65  const LogicalDevice* t_Dev,
66  const Swapchain* t_Swap,
67  entt::registry& t_reg,
68  VkRenderPass t_GlobalRenderPass,
69  FirstPersonCamera* t_Cam,
70  FrameBuffer* t_OffscreenDep,
71  std::shared_ptr<Fling::Shader> t_Vert,
72  std::shared_ptr<Fling::Shader> t_Frag
73  );
74 
75  virtual ~GeometrySubpass();
76 
77  void Draw(CommandBuffer& t_CmdBuf, VkFramebuffer t_PresentFrameBuf, UINT32 t_ActiveFrameInFlight, entt::registry& t_reg, float DeltaTime) override;
78 
79  void CreateDescriptorSets(VkDescriptorPool t_Pool, entt::registry& t_reg) override;
80 
84  void CreateGraphicsPipeline() override;
85 
86  private:
87 
88  void OnPointLightAdded(entt::entity t_Ent, entt::registry& t_Reg, PointLight& t_Light);
89 
90  void UpdateLightingUBO(entt::registry& t_Reg, UINT32 t_ActiveFrame);
91 
92  // Global render pass for frame buffer writes
93  std::shared_ptr<Model> m_QuadModel;
94 
95  VkRenderPass m_GlobalRenderPass = VK_NULL_HANDLE;
96 
98 
100  FrameBuffer* m_OffscreenFrameBuf = nullptr;
101 
102  // Descriptor sets and Uniform buffers -- one per swap image
103  std::vector<VkDescriptorSet> m_DescriptorSets;
104  std::vector<Buffer*> m_LightingUboBuffers;
105  std::vector<Buffer*> m_CameraUboBuffers;
106 
107  std::vector<Buffer*> m_QuadUboBuffer;
108 
109  LightingUbo m_LightingUBO = {};
110 
111  CameraInfoUbo m_CamInfoUBO = {};
112  };
113 } // namespace Fling
The geometry subpass is in charge of sending the geometry portion of the Deferred pipeline to the GPU...
Definition: GeometrySubpass.h:61
glm::mat4 ModelView
Definition: GeometrySubpass.h:49
A subpass represents one part of a RenderPipeline.
Definition: Subpass.h:25
A simple first person camera.
Definition: FirstPersonCamera.h:9
std::shared_ptr< Model > m_QuadModel
Definition: GeometrySubpass.h:93
std::vector< Buffer * > m_QuadUboBuffer
Definition: GeometrySubpass.h:107
Simple representation of a point light in Light Vox.
Definition: PointLight.hpp:12
Uniform buffer for passing lights to our final screen pass.
Definition: GeometrySubpass.h:36
Encapsulates functionality of a Vulkan Command buffer.
Definition: CommandBuffer.h:17
std::vector< Buffer * > m_CameraUboBuffers
Definition: GeometrySubpass.h:105
A logical device represents the application view of the device.
Definition: LogicalDevice.h:13
Represents a swap chain that can be used throughout the program.
Definition: SwapChain.h:21
Simple representation of a directional light for Fling.
Definition: DirectionalLight.hpp:12
Definition: FrameBuffer.h:67
glm::mat4 Projection
Definition: GeometrySubpass.h:48
static const UINT32 MaxDirectionalLights
Dir Lights.
Definition: GeometrySubpass.h:29
Definition: GeometrySubpass.h:46
std::vector< VkDescriptorSet > m_DescriptorSets
Definition: GeometrySubpass.h:103
Settings for the max directional lights and max point lights.
Definition: GeometrySubpass.h:26
const FirstPersonCamera * m_Camera
Definition: GeometrySubpass.h:97
uint32_t UINT32
Definition: FlingTypes.h:13
Definition: Engine.h:29
std::vector< Buffer * > m_LightingUboBuffers
Definition: GeometrySubpass.h:104
void CreateDescriptorSets(MeshRenderer &t_MeshRend, Lighting &t_Lighting, VkDescriptorSetLayout t_DescriptorLayout)
Definition: ShaderProgramReflections.cpp:4
static const UINT32 MaxPointLights
Point Lights.
Definition: GeometrySubpass.h:32