SpiecsEngine
 
Loading...
Searching...
No Matches
VulkanRenderBackend.h
Go to the documentation of this file.
1/**
2* @file VulkanRenderBackend.h.
3* @brief The VulkanRenderBackend Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "VulkanUtils.h"
10
11#include "Render/FrameInfo.h"
12#include "Core/Event/WindowEvent.h"
13#include "Core/Event/SlateEvent.h"
14#include "Core/Event/WorldEvent.h"
15
16#include "VulkanWindows.h"
17#include "VulkanInstance.h"
18#include "VulkanDevice.h"
25
26namespace Spices {
27
28 /**
29 * @brief Forward Declare.
30 */
32
33 /**
34 * @brief This class defines the render backend behaves of Vulkan.
35 */
37 {
38 public:
39
40 /**
41 * @brief Constructor Function.
42 */
44
45 /**
46 * @brief Destructor Function.
47 */
48 virtual ~VulkanRenderBackend();
49
50 /**
51 * @brief Copy Constructor Function.
52 * @note This Class not allowed copy behaves.
53 */
55
56 /**
57 * @brief Copy Assignment Operation.
58 * @note This Class not allowed copy behaves.
59 */
61
62 /**
63 * @brief Determine whether window is closed.
64 * @return Returns True if closed.
65 */
66 bool isWindowClosed() { return glfwWindowShouldClose(m_VulkanState.m_Windows); }
67
68 /**
69 * @brief Start record a new frame with vulkan render backend.
70 * @param[in] frameInfo FrameInfo.
71 */
72 void BeginFrame(FrameInfo& frameInfo);
73
74 /**
75 * @brief End record the frame with vulkan render backend.
76 * @param[in] frameInfo FrameInfo.
77 */
78 void EndFrame(FrameInfo& frameInfo);
79
80 /**
81 * @brief Draw World.
82 * @param[in] ts TimeStep.
83 * @param[in] frameInfo FrameInfo.
84 */
85 void RenderFrame(TimeStep& ts, FrameInfo& frameInfo);
86
87 /**
88 * @brief This function is called on global event function is called.
89 * @param[in] event Event.
90 */
91 void OnEvent(Event& event);
92
93 /**
94 * @brief Get VulkanState in use.
95 * @return Returns the VulkanState in use.
96 */
97 inline static VulkanState& GetState() { return m_VulkanState; }
98
99 /**
100 * @brief Get DescriptorPool in use.
101 * @return Returns the shared pointer of VulkanDescriptorPool in use.
102 */
103 inline static std::shared_ptr<VulkanDescriptorPool> GetDescriptorPool() { return m_VulkanDescriptorPool; }
104
105 /**
106 * @brief Get RendererResourcePool in use.
107 * @return Returns the shared pointer of RendererResourcePool in use.
108 */
109 inline static std::shared_ptr<RendererResourcePool> GetRendererResourcePool() { return m_RendererResourcePool; }
110
111 private:
112
113 /**
114 * @brief This function is called on window is resized over.
115 * @param[in] event WindowResizeOverEvent.
116 * @return Returns true if need block event.
117 * @attention: Minimize Window registry OnWindowResizeOver, OnSlateResize will not be registry.
118 */
120
121 /**
122 * @brief This function is called on viewport is resized.
123 * @param[in] event SlateResizeEvent.
124 * @return Returns true if need block event.
125 */
126 bool OnSlateResize(SlateResizeEvent& event);
127
128 /**
129 * @brief This function is called on world mark query tick.
130 * @param[in] event WorldEvent.
131 * @return Returns true if need block event.
132 */
134
135 /**
136 * @brief Called OnSlateResize.
137 */
138 void RecreateSwapChain();
139
140 private:
141
142 /**
143 * @brief The VulkanState in use.
144 */
146
147 /**
148 * @brief The VulkanDescriptorPool in use.
149 */
151
152 /**
153 * @brief The RendererResourcePool in use.
154 */
156
157 /**
158 * @brief VulkanWindows.
159 */
161
162 /**
163 * @brief VulkanInstance.
164 */
166
167 /**
168 * @brief VulkanDevice.
169 */
170 std::shared_ptr<VulkanDevice> m_VulkanDevice;
171
172 /**
173 * @brief VulkanMemoryAllocator.
174 */
176
177 /**
178 * @brief VulkanCommandPool.
179 */
181
182 /**
183 * @brief VulkanCommandBuffer.
184 */
186
187 /**
188 * @brief VulkanSwapChain.
189 */
191 };
192}
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define SPICES_PROFILE_FRAME
virtual ~Application()
Destructor Function.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
Definition Application.h:20
This Class is the basic Event Class. Inherit from it and create specific event class.
Definition Event.h:96
uint32_t m_PickMaterial
Identify of selected material.
Definition FrameInfo.h:89
FrameInfo(const FrameInfo &)=delete
Copy Constructor Function.
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
Definition FrameInfo.h:69
FrameInfo & operator=(const FrameInfo &)=delete
Copy Assignment Operation.
virtual ~FrameInfo()=default
Destructor Function.
static FrameInfo & Get()
Get FrameInfo.
Definition FrameInfo.cpp:14
std::shared_ptr< World > m_World
The shared pointer of specific world.
Definition FrameInfo.h:94
scl::linked_unordered_map< int, std::string > m_PickEntityID
Definition FrameInfo.h:82
RendererType m_RendererType
The renderer type of current world.
Definition FrameInfo.h:99
FrameInfo()=default
Constructor Function.
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
Definition FrameInfo.h:75
FrameInfo Class. This class defines the FrameInfo data.
Definition FrameInfo.h:32
static void Init()
Init Log.
Definition Log.cpp:24
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
NativeScriptSystem Class. This class defines the specific behaves of NativeScriptSystem.
ResourceSystem Class. This class defines the specific behaves of RenderSystem.
RendererResourcePool Class. This class is a pool of all framebuffer's attachment.
ResourceSystem Class. Handles resource load/unload event.
This Class is inherited from Event Class. Called by Viewport Resize.
Definition SlateEvent.h:18
SlateSystem Class. This class defines the specific behaves of SlateSystem.
Definition SlateSystem.h:21
SystemManager()
Constructor Function.
static SystemManager & Get()
Get Static SystemManager.
SystemManager & PopSystem(const std::string &systemName)
Push a system to this manager.
SystemManager Class. This class defines the behave of SystemManager.
void Flush()
Refresh time in each engine loop.
Definition TimeStep.cpp:26
const uint64_t & fs() const
Get frames count.
Definition TimeStep.h:63
This Class handles our engine time step during frames. Global Unique.
Definition TimeStep.h:22
VulkanDescriptorPool Class. This class is the wrapper of VkDescriptorPool.
VulkanInstance Class. This class defines the VulkanDevice behave. This class is just a wrapper of vkd...
void EndFrame(FrameInfo &frameInfo)
End record the frame with vulkan render backend.
void RecreateSwapChain()
Called OnSlateResize.
std::shared_ptr< VulkanMemoryAllocator > m_VmaAllocator
VulkanMemoryAllocator.
std::unique_ptr< VulkanSwapChain > m_VulkanSwapChain
VulkanSwapChain.
virtual ~VulkanRenderBackend()
Destructor Function.
std::unique_ptr< VulkanCommandPool > m_VulkanCommandPool
VulkanCommandPool.
VulkanRenderBackend()
Constructor Function.
static std::shared_ptr< VulkanDescriptorPool > GetDescriptorPool()
Get DescriptorPool in use.
static VulkanState m_VulkanState
The VulkanState in use.
std::unique_ptr< VulkanCommandBuffer > m_VulkanCommandBuffer
VulkanCommandBuffer.
bool isWindowClosed()
Determine whether window is closed.
static std::shared_ptr< VulkanDescriptorPool > m_VulkanDescriptorPool
The VulkanDescriptorPool in use.
static std::shared_ptr< RendererResourcePool > m_RendererResourcePool
The RendererResourcePool in use.
static VulkanState & GetState()
Get VulkanState in use.
std::unique_ptr< VulkanWindows > m_VulkanWindows
VulkanWindows.
bool OnMeshAddedWorldEvent(WorldEvent &event)
This function is called on world mark query tick.
void RenderFrame(TimeStep &ts, FrameInfo &frameInfo)
Draw World.
void OnEvent(Event &event)
This function is called on global event function is called.
static std::shared_ptr< RendererResourcePool > GetRendererResourcePool()
Get RendererResourcePool in use.
void BeginFrame(FrameInfo &frameInfo)
Start record a new frame with vulkan render backend.
VulkanRenderBackend & operator=(const VulkanRenderBackend &)=delete
Copy Assignment Operation.
bool OnWindowResizeOver(WindowResizeOverEvent &event)
This function is called on window is resized over.
std::shared_ptr< VulkanDevice > m_VulkanDevice
VulkanDevice.
std::unique_ptr< VulkanInstance > m_VulkanInstance
VulkanInstance.
bool OnSlateResize(SlateResizeEvent &event)
This function is called on viewport is resized.
VulkanRenderBackend(const VulkanRenderBackend &)=delete
Copy Constructor Function.
This class defines the render backend behaves of Vulkan.
This Class is inherited from Event Class. Inherit from it and create specific KeyEvent class....
Definition WorldEvent.h:20
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
RendererType
Definition FrameInfo.h:22
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74