SpiecsEngine
 
Loading...
Searching...
No Matches
VulkanImage.h
Go to the documentation of this file.
1/**
2* @file VulkanImage.h.
3* @brief The VulkanImage Class Definitions.
4* @author Spices & Khronos Vulkan Tutorial.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "VulkanUtils.h"
10#include <ktxvulkan.h>
11
12namespace Spices {
13
14 /**
15 * @breif VulkanImage is a wrapper of VkImage.
16 * It's a basic object of Vulkan.
17 * @todo Wrapper by Texture.
18 */
20 {
21 public:
22
23 /**
24 * @brief Constructor Function.
25 * Init class variable.
26 * Init a empty VulkanImage, used in TextureLoad.
27 * @param[in] vulkanState The VulkanObject in used this frame.
28 */
30 VulkanState& vulkanState
31 )
32 : VulkanObject(vulkanState)
33 {}
34
35 /**
36 * @breif Constructor Function.
37 * Init class variable.
38 * Create the vkImage by specific parameters.
39 * @param[in] vulkanState The VulkanObject in used this frame.
40 * @param[in] name Image's name.
41 * @param[in] type Image's type.
42 * @param[in] width Image's width.
43 * @param[in] height Image's height.
44 * @param[in] layers Image's layers(texture cube).
45 * @param[in] numSamples Image's MSAA sample num.(8 if enable MSAA).
46 * @param[in] format Image's format.
47 * @param[in] tiling Image's tilling.
48 * @param[in] usage Image's used stage.
49 * @param[in] flags Image's used flags.
50 * @param[in] properties Image's data memory requirement.
51 * @param[in] mipLevels Image's mip num, if need.
52 */
54 VulkanState& vulkanState ,
55 const std::string& name ,
56 VkImageType type ,
57 uint32_t width ,
58 uint32_t height ,
59 uint32_t layers ,
60 VkSampleCountFlagBits numSamples ,
61 VkFormat format ,
62 VkImageTiling tiling ,
63 VkImageUsageFlags usage ,
64 VkImageCreateFlags flags ,
65 VkMemoryPropertyFlags properties ,
66 uint32_t mipLevels
67 );
68
69 /**
70 * @brief Destructor Function.
71 */
72 virtual ~VulkanImage() override;
73
74 /**
75 * @breif Get VkImageView of this VkImage.
76 * Need Create before call this API.
77 * @param[in] mipLevel Specific mipmap.
78 * @return Returns VkImageView reference.
79 */
80 VkImageView& GetView(uint32_t mipLevel = 0) { return m_ImageViews[mipLevel]; }
81
82 /**
83 * @breif Get this VkImage.
84 * @return Returns VkImage reference.
85 */
86 VkImage& GetImage() { return m_Image; }
87
88 /**
89 * @brief Get this Layers.
90 * @return Returns the m_Layers.
91 */
92 uint32_t GetLayers() const { return m_Layers; }
93
94 /**
95 * @brief Get this Height.
96 * @return Returns the m_Height.
97 */
98 uint32_t GetHeight() const { return m_Height; }
99
100 /**
101 * @brief Get this Width.
102 * @return Returns the m_Height.
103 */
104 uint32_t GetWidth() const { return m_Width; }
105
106 /**
107 * @brief Get this Format.
108 * @return Returns the m_Format.
109 */
110 VkFormat GetFormat() const { return m_Format; }
111
112 /**
113 * @brief Get this MipLevels.
114 * @return Returns the m_MipLevels.
115 */
116 uint32_t GetMipLevels() const { return m_MipLevels; }
117
118 public:
119
120 /**
121 * @breif Get VkDescriptorImageInfo.
122 * @param[in] imageLayout Usually is VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, also support custom layout.
123 * @param[in] mipLevel Which mipmap info.
124 * @return Returns VkDescriptorImageInfo row pointer, avoiding copy, use pointer here.
125 * fell free to using row pointer here.
126 */
130 );
131
132 /**
133 * @breif Transform this VkImage's layout.
134 * @param[in] format This VkImage's format, see m_Format.
135 * @param[in] oldLayout The original layout, pass VK_IMAGE_LAYOUT_UNDEFINED if don't known the actual layout.
136 * @param[in] newLayout The new layout.
137 */
139 VkFormat format ,
140 VkImageLayout oldLayout ,
141 VkImageLayout newLayout
142 );
143
144 /**
145 * @brief Wrapper of Call vkCmdImageBarrier.
146 * @param[in] commandBuffer .
147 * @param[in] srcAccessMask .
148 * @param[in] dstAccessMask .
149 * @param[in] srcStageMask .
150 * @param[in] dstStageMask .
151 * @param[in] srcQueueFamilyIndex .
152 * @param[in] dstQueueFamilyIndex .
153 */
154 void Barrier(
155 VkCommandBuffer commandBuffer ,
156 VkAccessFlags srcAccessMask ,
157 VkAccessFlags dstAccessMask ,
158 VkPipelineStageFlags srcStageMask ,
159 VkPipelineStageFlags dstStageMask ,
160 uint32_t srcQueueFamilyIndex ,
161 uint32_t dstQueueFamilyIndex
162 ) const;
163
164 /**
165 * @brief Copy the Buffer's data to this VkImage.
166 * @param[in] buffer The buffer we want copy from.
167 * @param[in] image The image we want copy to, usually this VkImage Object.
168 * @param[in] width The image's width.
169 * @param[in] height The image's height.
170 */
172 VkBuffer buffer ,
173 VkImage image ,
174 uint32_t width ,
175 uint32_t height
176 ) const;
177
178 /**
179 * @brief Copy the Buffer's data to this VkImage.
180 * Used to create image data (include mipmaps), which owns a compressed format.
181 * @param[in] buffer The buffer we want copy from.
182 * @param[in] image The image we want copy to, usually this VkImage Object.
183 * @param[in] width The image's width.
184 * @param[in] height The image's height.
185 * @param[in] regions Specific Regions.
186 */
188 VkBuffer buffer ,
189 VkImage image ,
190 uint32_t width ,
191 uint32_t height ,
192 const std::vector<VkBufferImageCopy>& regions
193 ) const;
194
195 /**
196 * @brief Copy the Memory's data to this VkImage.
197 * Used to create image data (include mipmaps), which owns a compressed format.
198 * @param[in] copies The copy information.
199 */
201 const std::vector<VkMemoryToImageCopyEXT>& copies
202 ) const;
203
204 /**
205 * @brief Copy the Memory's data to this VkImage.
206 * @param[in] data Memory data.
207 */
208 void CopyMemoryToImageHost(const void* data) const;
209
210 /**
211 * @breif Copy one texel data from a VkImage.
212 * @param[in] x The sampled position x.
213 * @param[in] y The sampled position y.
214 * @param[in] out_rgba The sampled data.
215 */
217 uint32_t x ,
218 uint32_t y ,
219 void* out_rgba
220 );
221
222 /**
223 * @breif Copy data from a VkImage.
224 * @param[in] dstBuffer The Dst Buffer.
225 * @param[in] regions Specific Regions.
226 */
228 VkBuffer dstBuffer,
229 const std::vector<VkBufferImageCopy>& regions
230 );
231
232 /**
233 * @breif Copy memory from a VkImage.
234 * @param[in] data Out data.
235 */
236 void CopyImageToMemoryHost(void* data) const;
237
238 /**
239 * @breif Copy memory from a VkImage.
240 * @param[in] copies Copy Information.
241 */
242 void CopyImageToMemoryHost(const std::vector<VkImageToMemoryCopyEXT>& copies) const;
243
244 /**
245 * @brief Generate mipmaps with the VkImage.
246 * @param[in] imageFormat VkFormat.
247 * @param[in] texWidth The Image Width.
248 * @param[in] texHeight The Image Height.
249 */
250 void GenerateMipmaps(
251 VkFormat imageFormat ,
252 int32_t texWidth ,
253 int32_t texHeight
254 ) const;
255
256 /**
257 * @brief Create Image View.
258 * @param[in] format VkFormat.
259 * @param[in] viewType VkImageViewType.
260 * @param[in] aspectFlags VkImageAspectFlags.
261 * @param[in] isCreateMipmapView True if needs create imageview for all mipmaps.
262 */
263 void CreateImageView(
264 VkFormat format ,
265 VkImageViewType viewType ,
266 VkImageAspectFlags aspectFlags ,
267 bool isCreateMipmapView = false
268 );
269
270 /**
271 * @brief Create a Sampler.
272 */
273 void CreateSampler();
274
275 /**
276 * @breif Create a VkImage.
277 * @param[in] vulkanState The VulkanObject in used this frame.
278 * @param[in] name Image's name.
279 * @param[in] type Image's type.
280 * @param[in] width Image's width.
281 * @param[in] height Image's height.
282 * @param[in] layers Image's layers(texture cube).
283 * @param[in] numSamples Image's MSAA sample num.(8 if enable MSAA).
284 * @param[in] format Image's format.
285 * @param[in] tiling Image's tilling.
286 * @param[in] usage Image's used stage.
287 * @param[in] flags Image's used flags.
288 * @param[in] properties Image's data memory requirement.
289 * @param[in] mipLevels Image's mip num, if need.
290 */
291 void CreateImage(
292 VulkanState& vulkanState ,
293 const std::string& name ,
294 VkImageType type ,
295 uint32_t width ,
296 uint32_t height ,
297 uint32_t layers ,
298 VkSampleCountFlagBits numSamples ,
299 VkFormat format ,
300 VkImageTiling tiling ,
301 VkImageUsageFlags usage ,
302 VkImageCreateFlags flags ,
303 VkMemoryPropertyFlags properties ,
304 uint32_t mipLevels
305 );
306
307 /**
308 * @brief Create DescriptorSet with single image.
309 * @param[in] binding Which binding will be use.
310 */
311 void CreateDescriptorSet(uint32_t binding);
312
313 /**
314 * @brief Get VkDescriptorSet.
315 * @return Returns the VkDescriptorSet.
316 */
317 inline VkDescriptorSet& GetDescriptorSet() { return m_DescriptorSet; }
318
319 /**
320 * @brief Check if this image format can copy from host to gpu directly.
321 * @return Returns true if can do that.
322 */
323 bool IsHostCopyable() const;
324
325 /**
326 * @brief Check if this image format can copy from host to gpu directly.
327 * @param[in] state VulkanState.
328 * @param[in] format VkFormat.
329 * @return Returns true if can do that.
330 */
331 static bool IsHostCopyable(VulkanState& state, VkFormat format);
332
333 private:
334
335 /**
336 * @brief Destroy the DescriptorSetLayout if Created a DescriptorSet.
337 */
338 void DestroyDescriptorSetLayout() const;
339
340 private:
341
342 /**
343 * @brief Image width.
344 */
345 int m_Width = 0;
346
347 /**
348 * @brief Image height.
349 */
350 int m_Height = 0;
351
352 /**
353 * @brief Image layer(texture cube: 6).
354 */
355 uint32_t m_Layers = 1;
356
357 /**
358 * @brief Image mipmaps num.
359 */
360 uint32_t m_MipLevels = 1;
361
362 /**
363 * @brief Image Type.
364 */
366
367 /**
368 * @brief The image format.
369 */
371
372 /**
373 * @brief The VkImage this Class Wrapped.
374 */
376
377 /**
378 * @brief VMA allocation.
379 */
381
382 /**
383 * @brief The image video memory.
384 */
386
387 /**
388 * @brief The image view.
389 */
391
392 /**
393 * @brief The image sampler.
394 */
396
397 /**
398 * @brief VkDescriptorImageInfo.
399 */
401
402 /**
403 * @brief True if Called Create DescriptorSet.
404 */
405 bool m_IsCreateSet = false;
406
407 /**
408 * @brief VkDescriptorSetLayout.
409 */
411
412 /**
413 * @brief VkDescriptorSet.
414 */
416
417 /**
418 * @brief Allow access all data.
419 */
420 friend class TextureLoader;
421 friend class Transcoder;
422 };
423}
#define EVENT_CLASS_TYPE(type)
Defines Event type.
Definition Event.h:74
#define EVENT_CLASS_CATEGORY(category)
Defines Event category.
Definition Event.h:82
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define SPICES_PROFILE_VK_ZONE(cmdbuf, name)
#define SPICES_PROFILE_FRAME
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
Definition VulkanUtils.h:68
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
virtual std::string ToString() const override
Serialize this Event Class to string.
Definition WorldEvent.h:60
MeshAddedWorldEvent()=default
Constructor Function.
virtual ~MeshAddedWorldEvent() override=default
Destructor Function.
This Class is inherited from Event Class.
Definition WorldEvent.h:43
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.
TextureLoader Class. This class only defines static function for load data from image file.
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
Transcoder of Texture Container format and Transform format and GPU compress format.
Definition Transcoder.h:17
virtual ~VulkanCommandBuffer() override=default
Destructor Function. VkCommandBuffer is created by VkCommandPool, we do not need destroy it here manu...
VulkanCommandBuffer(VulkanState &vulkanState)
Constructor Function. Create VkCommandBuffer.
static void CustomGraphicCmd(VulkanState &vulkanState, T func)
Create a new command buffer and record custom cmd, submit to graphic queue, execute it immediately.
VulkanCommandBuffer Class. This class defines the VulkanCommandBuffer behaves. This class is just a w...
int m_GraphicThreadId
Thread Unique Graphic ThreadId.
int m_ComputeThreadId
Thread Unique Compute ThreadId.
static VulkanCommandPoolThreadWrapper & GetInst()
Get this instance.
virtual ~VulkanCommandPoolThreadWrapper()
Destructor Function.
VulkanCommandPoolThreadWrapper()
Constructor Function.
Wrapper of Instance/Delete VkCommandPool in thread.
static std::vector< VkCommandPool > m_ThreadGraphicCommandPool
Thread Graphic VkCommandPool map.
static VkCommandPool & GetThreadComputeCommandPool()
Get Thread Compute VkCommandPool by thread id.
static bool m_IsPoolActive
True if this Pool is actived.
VulkanCommandPool(VulkanState &vulkanState)
Constructor Function. Create VkCommandPool.
virtual ~VulkanCommandPool() override
Destructor Function.
static std::mutex m_ComputeCommandPoolMutex
Mutex for GraphicCommandPool.
static VkCommandPool & GetThreadGraphicCommandPool()
Get Thread Graphic VkCommandPool by thread id.
static std::mutex m_GraphicCommandPoolMutex
Mutex for GraphicCommandPool.
static std::vector< VkCommandPool > m_ThreadComputeCommandPool
Thread Compute VkCommandPool map.
VulkanCommandPool Class. This class defines the VulkanCommandPool behaves. This class is just a wrapp...
VulkanDescriptorPool Class. This class is the wrapper of VkDescriptorPool.
VkSampleCountFlagBits GetMaxUsableSampleCount() const
Get device's max usable sample count.
bool IsQueueMeetDemand(const VkPhysicalDevice &device, const VkSurfaceKHR &surface)
Check all Queue we need meet;.
static SwapChainSupportDetails QuerySwapChainSupport(const VkPhysicalDevice &device, const VkSurfaceKHR &surface, GLFWwindow *window)
Query physical device's SwapChainSupport.
const SwapChainSupportDetails & GetSwapChainSupport()
Get SwapChain Utils.
static VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV & GetDGCProperties()
Get DeviceGeneratedCommandsPropertiesNV.
QueueHelper m_QueueHelper
QueueHelper.
static VkPhysicalDeviceFeatures m_DeviceFeatures
Selected Physical Device Features.
static VkPhysicalDeviceProperties & GetDeviceProperties()
Get VkPhysicalDeviceProperties.
virtual ~VulkanDevice() override
Destructor Function.
static VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_RayTracingProperties
Device RayTracing Properties.
static VkPhysicalDeviceFeatures & GetDeviceFeatures()
Get VkPhysicalDeviceFeatures.
bool IsPropertyMeetDemand(const VkPhysicalDevice &device)
Check all Property we need meet.
static VkPhysicalDeviceRayTracingPipelinePropertiesKHR & GetRTPipelineProperties()
Get RayTracingPipelineProperties.
bool IsFeatureMeetDemand(const VkPhysicalDevice &device)
Check all Feature we need meet.
void GetExtensionRequirements()
Get all physical device extension requirements our engine needed. Source 1 : user Setting.
static VkPhysicalDeviceProperties m_DeviceProperties
Selected Physical Device Properties.
static VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV m_DGCProperties
Device DGC Properties.
VulkanDevice(VulkanState &vulkanState)
Constructor Function. Create vkDevice.
bool SelectPhysicalDevice(const VkInstance &instance, const VkSurfaceKHR &surface, GLFWwindow *window)
select a suitable physical device.
SwapChainSupportDetails m_SwapChainSupportDetails
SwapChainSupportDetails.
bool IsExtensionMeetDemand(const VkPhysicalDevice &device)
Check all Extension we need meet;.
std::vector< const char * > m_ExtensionProperties
Device Extension Properties.
void RequerySwapChainSupport()
Requery device's SwapChainSupportDetails. Mainly VkExtent2D.
const QueueHelper & GetQueueHelper() const
Get QueueHelper variable.
VulkanInstance Class. This class defines the VulkanDevice behave. This class is just a wrapper of vkd...
VkImage & GetImage()
Definition VulkanImage.h:86
VkImageType m_ImageType
Image Type.
void CopyImageToMemoryHost(const std::vector< VkImageToMemoryCopyEXT > &copies) const
int m_Width
Image width.
VkFormat m_Format
The image format.
bool IsHostCopyable() const
Check if this image format can copy from host to gpu directly.
static bool IsHostCopyable(VulkanState &state, VkFormat format)
Check if this image format can copy from host to gpu directly.
uint32_t GetWidth() const
Get this Width.
VkDescriptorSet & GetDescriptorSet()
Get VkDescriptorSet.
void CreateDescriptorSet(uint32_t binding)
Create DescriptorSet with single image.
VmaAllocation m_Alloc
VMA allocation.
void CopyImageToMemoryHost(void *data) const
VkDescriptorImageInfo * GetImageInfo(VkImageLayout imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, uint32_t mipLevel=0)
void CopyMemoryToImageHost(const void *data) const
Copy the Memory's data to this VkImage.
void CreateSampler()
Create a Sampler.
void CopyImageToBuffer(VkBuffer dstBuffer, const std::vector< VkBufferImageCopy > &regions)
void CopyImageTexelToBuffer(uint32_t x, uint32_t y, void *out_rgba)
VkDescriptorSetLayout m_DescriptorSetLayout
VkDescriptorSetLayout.
void CreateImage(VulkanState &vulkanState, const std::string &name, VkImageType type, uint32_t width, uint32_t height, uint32_t layers, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkMemoryPropertyFlags properties, uint32_t mipLevels)
void DestroyDescriptorSetLayout() const
Destroy the DescriptorSetLayout if Created a DescriptorSet.
VkDeviceMemory m_ImageMemory
The image video memory.
void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, const std::vector< VkBufferImageCopy > &regions) const
Copy the Buffer's data to this VkImage. Used to create image data (include mipmaps),...
uint32_t GetMipLevels() const
Get this MipLevels.
void CopyMemoryToImageHost(const std::vector< VkMemoryToImageCopyEXT > &copies) const
Copy the Memory's data to this VkImage. Used to create image data (include mipmaps),...
VkSampler m_TextureSampler
The image sampler.
bool m_IsCreateSet
True if Called Create DescriptorSet.
virtual ~VulkanImage() override
Destructor Function.
VulkanImage(VulkanState &vulkanState, const std::string &name, VkImageType type, uint32_t width, uint32_t height, uint32_t layers, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkMemoryPropertyFlags properties, uint32_t mipLevels)
uint32_t m_MipLevels
Image mipmaps num.
void CreateImageView(VkFormat format, VkImageViewType viewType, VkImageAspectFlags aspectFlags, bool isCreateMipmapView=false)
Create Image View.
int m_Height
Image height.
void Barrier(VkCommandBuffer commandBuffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex, uint32_t dstQueueFamilyIndex) const
Wrapper of Call vkCmdImageBarrier.
VkDescriptorImageInfo m_ImageInfo
VkDescriptorImageInfo.
VkDescriptorSet m_DescriptorSet
VkDescriptorSet.
void TransitionImageLayout(VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout)
void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height) const
Copy the Buffer's data to this VkImage.
VkImageView & GetView(uint32_t mipLevel=0)
Definition VulkanImage.h:80
uint32_t GetLayers() const
Get this Layers.
Definition VulkanImage.h:92
std::vector< VkImageView > m_ImageViews
The image view.
VulkanImage(VulkanState &vulkanState)
Constructor Function. Init class variable. Init a empty VulkanImage, used in TextureLoad.
Definition VulkanImage.h:29
uint32_t GetHeight() const
Get this Height.
Definition VulkanImage.h:98
VkImage m_Image
The VkImage this Class Wrapped.
uint32_t m_Layers
Image layer(texture cube: 6).
VkFormat GetFormat() const
Get this Format.
void GenerateMipmaps(VkFormat imageFormat, int32_t texWidth, int32_t texHeight) const
Generate mipmaps with the VkImage.
void SetVulkanDebugCallbackFuncPointer()
Set Vulkan's debug message callback function pointer. Working with DEBUG mode.
virtual ~VulkanInstance() override
Destructor Function.
VkDebugUtilsMessengerCreateInfoEXT m_DebugMessengerCreateInfo
Debug Utils Messages used to execute message callback function. Also debug vkInstance create.
void CreateVulkanSurface() const
Create a Surface Object.
std::vector< const char * > m_LayerProperties
Instance Layer Properties.
VulkanInstance(VulkanState &vulkanState, const std::string &name, const std::string &engineName)
Constructor Function. Create vkInstance and vkSurface.
std::vector< const char * > m_ExtensionProperties
Instance Extension Properties.
bool CheckExtensionRequirementsSatisfied()
Iter all our extensions, check whether all satisfied or not.
VkDebugUtilsMessengerEXT m_DebugMessenger
Parameter for Create/Destroy DebugUtilsMessengerEXT.
void FillDebugMessengerCreateInfo()
Set m_DebugMessengerCreateInfo variable.
void GetExtensionRequirements()
Get all instance extension requirements our engine needed. Source 1 : glfw requirements....
bool ChecklayerRequirementsSatisfied()
Iter all our layers, check whether all satisfied or not.
void GetLayerRequirements()
Get all instance layer requirements our engine needed. Source 1 : user Setting.
VulkanInstance Class. This class defines the VulkanInstance behaves. This class is just a wrapper of ...
virtual ~VulkanMemoryAllocator() override
Destructor Function.
VulkanMemoryAllocator(VulkanState &vulkanState)
Constructor Function. Create Specific ThreadPool.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
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.
virtual ~VulkanRenderPass() override
Destructor Function.
VkRenderPass m_RenderPass
The RenderPass this class mainly manage.
VulkanRenderPass(VulkanState &vulkanState, const std::string &passName, std::shared_ptr< VulkanDevice > vulkanDevice, VkRenderPassCreateInfo &createInfo, std::vector< VkImageView > &imageViews, uint32_t layers, bool isUseSwapChianImage)
Constructor Function. Create VkRenderPass and VkFramebuffer.
VkFramebuffer & GetFramebuffer(uint32_t index)
Get Framebuffer by index.
std::array< VkFramebuffer, MaxFrameInFlight > m_SwapChainFramebuffers
The FrameBuffers.
std::shared_ptr< VulkanDevice > m_VulkanDevice
The shared pointer of VulkanDevice.
VkRenderPass & Get()
Get VkRenderPass.
VulkanRenderPass Class. This class defines the VulkanRenderPass behaves. This class is just a wrapper...
VulkanSwapChain(VulkanState &vulkanState, std::shared_ptr< VulkanDevice > vulkanDevice)
Constructor Function. Create vkInstance and vkSurface.
void DestroySyncObjects() const
Destroy Sync Objects.
static VkFormat FindDepthFormat(const VkPhysicalDevice &physicalDevice)
Check whether Depth Image's Format is supported by physical device.
void Destroy() const
Destroy this.
std::shared_ptr< VulkanDevice > m_VulkanDevice
The shared pointer of VulkanDevice.
void Create() const
Create this.
static VkFormat findSupportedFormat(const VkPhysicalDevice &physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
Check whether specific formats is supported by physical device.
virtual ~VulkanSwapChain() override
Destructor Function.
void CreateSyncObjects() const
Create Sync Objects.
VulkanSwapChain Class. This class defines the VulkanSwapChain behaves. This class is just a wrapper o...
static void Destroy()
Destroy all ThreadQueue.
static scl::thread_queue< std::shared_ptr< VulkanThreadQueue > > m_ComputeQueues
Compute VulkanThreadQueue.
static void CreateGraphic(VulkanState &vulkanState, VkQueue queue)
Create Graphic VulkanThreadQueue.
VkQueue m_Queue
This Thread VkQueue.
void Submit(VkCommandBuffer commandBuffer) const
Submit the CommandBuffer in this Queue.
void Wait() const
Wait for queue execute.
static void PushToGraphic(std::shared_ptr< VulkanThreadQueue > &queue)
Push queue to Graphic ThreadQueue.
static std::shared_ptr< VulkanThreadQueue > FetchGraphicQueue()
Fetch valid Graphic Queue.
static std::shared_ptr< VulkanThreadQueue > FetchComputeQueue()
Fetch valid Compute Queue.
static void CreateCompute(VulkanState &vulkanState, VkQueue queue)
Create Compute VulkanThreadQueue.
virtual ~VulkanThreadQueue() override
Destructor Function.
static void PushToCompute(std::shared_ptr< VulkanThreadQueue > &queue)
Push queue to Compute ThreadQueue.
static scl::thread_queue< std::shared_ptr< VulkanThreadQueue > > m_GraphicQueues
Graphic VulkanThreadQueue.
VulkanThreadQueue(VulkanState &vulkanState, VkQueue queue)
Constructor Function.
VulkanThreadQueue Class. This class is a wrapper of Thread VkQueue.
VulkanWindows(VulkanState &vulkanState, const WindowInfo &initInfo)
Constructor Function. Create Windows.
bool m_WindowsResized
True if viewPort is resized.
virtual ~VulkanWindows() override
Destructor Function.
void SetInternalCallBack() const
Set all needed GLFW events call back.
void SetResized(bool isResized)
Set m_WindowsResized variable.
WindowInfo m_WindowInfo
Window's info. not viewport's info.
bool IsResized() const
Get m_WindowsResized variable.
VulkanWindows Class. This class defines the windows behaves.
virtual ~WorldEvent() override=default
Destructor Function.
WorldEvent()=default
Constructor Function.
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...
void Push(T &&item)
Push a item to this queue.
Definition ThreadQueue.h:77
std::mutex m_Mutex
Mutex of this queue.
Definition ThreadQueue.h:58
thread_queue()
Constructor Function.
Definition ThreadQueue.h:23
T Pop()
Pop a item from this queue.
Definition ThreadQueue.h:88
void Clear()
Clear this queue.
std::atomic_int m_Count
Count of tasks.
Definition ThreadQueue.h:68
std::condition_variable m_NotEmpty
Not empty condition.
Definition ThreadQueue.h:63
bool IsEmpty() const
Is this queue is empty. @reutrn Returns true if empty.
Definition ThreadQueue.h:46
virtual ~thread_queue()=default
Destructor Function.
std::queue< T > m_Queue
This wrapped queue.
Definition ThreadQueue.h:73
Thread safe Queue.
Definition ThreadQueue.h:17
VMAMemoryPropertyFlagExtendBits
Map to VmaAllocationCreateFlagBits while use VMA for memory create.
@ VMA_MEMORY_PROPERTY_DEDICATED_MEMORY_BIT
VkMemoryPropertyFlagBits.
@ EventCategoryWorld
Definition Event.h:68
@ MeshAdded
World Event.
static constexpr int NThreadQueue
Thread Queue Count.
RendererType
Definition FrameInfo.h:22
std::optional< uint32_t > graphicqueuefamily
The graphic queue's in used identify.
std::optional< uint32_t > presentqueuefamily
The present queue's in used identify.
std::optional< uint32_t > transferqueuefamily
The transfer queue's in used identify.
std::optional< uint32_t > computequeuefamily
The compute queue's in used identify.
bool isComplete() const
Whether all queues that we need is valid.
This struct contains all queues's identify we need.
VkExtent2D surfaceSize
The VkSurface Size.
std::vector< VkSurfaceFormatKHR > formats
All supported VkSurfaceFormatKHR.
VkSurfaceFormatKHR format
The selected VkSurfaceFormatKHR.
VkSurfaceCapabilitiesKHR capabilities
VkSurfaceCapabilitiesKHR.
VkPresentModeKHR presentMode
The selected VkPresentModeKHR.
VkExtent2D viewPortSize
The ViewPort Size. Init value. Reset by resize event.
std::vector< VkPresentModeKHR > presentModes
All supported VkPresentModeKHR.
SwapChain Utils. Queried from device.
This struct contains all Vulkan object in used global.
Definition VulkanUtils.h:74
GLFWimage image
GLFWimage.
WindowIcon(const std::string &iconPath)
Constructor Function. Load the icon file immediately.
virtual ~WindowIcon()
Destructor Function.
This struct helps load the icon of window.
std::shared_ptr< WindowIcon > icon
Window's icon.
std::string name
Window's name.
int width
Window's width.
int height
Window's height.
This struct defines the basic information of window.