KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
VulkanDevice.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <vulkan/vulkan.h>
15
16namespace Karma
17{
19 class VulkanTexture;
22 class FVulkanSwapChain;
23 class VulkanShader;
24
33 {
34 public:
45 FVulkanDevice(FVulkanDynamicRHI* InRHI, VkPhysicalDevice InGpu);
46
55
62 void InitGPU();
63
69 void Destroy();
70
77 void WaitUntilIdle();
78
84 VkDevice GetLogicalDevice() const { return m_LogicalDevice; }
85
91 VkPhysicalDevice GetGPU() const { return m_GPU; }
92
98 VkCommandPool GetCommandPool() const { return m_CommandPool; }
99
101
114 void TransitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout);
115
129 void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height);
130
141 bool HasStencilComponent(VkFormat format);
142
143 void InitializeDefaultDescriptorSets(uint32_t MaxFramesInFlight);
144
146
152 inline VkQueue GetGraphicsQueue() const { return m_GraphicsQueue; }
153
159 inline FVulkanDynamicRHI* GetVulkanDynamicRHI() const { return m_VulkanDynamicRHI; }
160
166 inline FVulkanFenceManager& GetFenceManager() { return m_FenceManager; }
167
168 inline KarmaVector<FVulkanDescriptorSets*>& GetDefaultDescriptorSets() { return m_DefaultDescriptorSets; }
169
170 inline FVulkanDescriptorSetsLayout* GetDefaultDescriptorSetLayout() const { return m_DefaultDescriptorSetLayout; }
171
172 inline VulkanTexture* GetDefaultTexture() const { return m_DefaultTexture; }
173
174 inline VulkanShader* GetDefaultShader() const { return m_DefaultShader; }
175
176 private:
194 void PopulateWithDescriptorSetsLayout(FVulkanDescriptorSetsLayout& OutLayout);
195
196 private:
197 VkDevice m_LogicalDevice;
198 FVulkanDynamicRHI* m_VulkanDynamicRHI;
199
200 VkPhysicalDevice m_GPU;
201 VkQueue m_GraphicsQueue;
202 VkQueue m_PresentQueue;
203 VulkanTexture* m_DefaultTexture;
204 VulkanShader* m_DefaultShader;
205
206 // Additional members for managing queues, command pools, etc. can be added here.
207 VkCommandPool m_CommandPool;
208
209 // Default descriptor set layout for the device, which can be used for common resources like camera UBO and default texture sampler.
210 FVulkanDescriptorSetsLayout* m_DefaultDescriptorSetLayout;
211 KarmaVector<class FVulkanDescriptorPool*> m_DescriptorPool;
212 KarmaVector<FVulkanDescriptorSets*> m_DefaultDescriptorSets;
213 uint32_t m_MaxFramesInFlight = 0;
214
215 FVulkanFenceManager m_FenceManager;
216 };
217}
Header file for Vulkan synchronization primitives.
Definition VulkanDescriptorSets.h:126
FVulkanDevice(FVulkanDynamicRHI *InRHI, VkPhysicalDevice InGpu)
Constructor for FVulkanDevice.
Definition VulkanDevice.cpp:9
VkCommandPool GetCommandPool() const
Retrives the Vulkan command pool for the commandbuffers.
Definition VulkanDevice.h:98
~FVulkanDevice()
Destructor for FVulkanDevice.
Definition VulkanDevice.cpp:16
void TransitionImageLayout(VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout)
Transitions the layout of an image from oldLayout to newLayout.
Definition VulkanDevice.cpp:189
FVulkanFenceManager & GetFenceManager()
Getter for the default texture (unreal grid).
Definition VulkanDevice.h:166
VkDevice GetLogicalDevice() const
Retrieves the Vulkan logical device handle.
Definition VulkanDevice.h:84
bool HasStencilComponent(VkFormat format)
Checks if the given format has a stencil component.
Definition VulkanDevice.cpp:338
VkPhysicalDevice GetGPU() const
Retrieves the Vulkan physical device handle.
Definition VulkanDevice.h:91
void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height)
Copies data from a buffer to a Vulkan image.
Definition VulkanDevice.cpp:282
void WaitUntilIdle()
Waits on the host by blocking the calling CPU thread until the Vulkan logical device completes all pe...
Definition VulkanDevice.cpp:183
void Destroy()
Destroys the logical vkdevice by making Vulkan API call.
Definition VulkanDevice.cpp:21
FVulkanDynamicRHI * GetVulkanDynamicRHI() const
Getter for the present queue created in FVulkanDevice::InitGPU().
Definition VulkanDevice.h:159
VkQueue GetGraphicsQueue() const
Getter for the graphics queue created in FVulkanDevice::InitGPU().
Definition VulkanDevice.h:152
void InitGPU()
Creates the Vulkan logical device and default vulkan resources.
Definition VulkanDevice.cpp:37
Vulkan implementation of the Dynamic RHI.
Definition VulkanDynamicRHI.h:131
Definition VulkanSynchronization.h:26
Represents a Vulkan swapchain, managing the images used for rendering and presentation.
Definition VulkanSwapChain.h:49
Vulkan specific implementation of Shader class.
Definition VulkanShader.h:28
Vulkan specific implementation of Texture class.
Definition VulkanTexture.h:30
Karma's std::vector wrapper with additional functionalities.
Definition KarmaTypes.h:243
Definition VulkanDescriptorSets.h:161