|
KarmaEngine
Game Engine for practical learning and research purposes
|
Vulkan implementation of the Dynamic RHI. More...
#include <VulkanDynamicRHI.h>
Public Member Functions | |
| FVulkanDynamicRHI () | |
| Initialization constructor. | |
| virtual bool | Init () override |
| For initializing VulkanDynamic RHI. | |
| virtual void | Shutdown () override |
| Shuts down the RHI. | |
| void | InitInstance () |
| Calls FVulkanDevice::InitGPU() to create Vulkan logical device from selected GPU, and created appropriate resources (commandpool, default texture etc). | |
| virtual void | Present () override |
| Presents the rendered frame to the display. | |
| SwapChainSupportDetails | QuerySwapChainSupport (VkPhysicalDevice device) |
| Uses Two-Pass Query to gather surface formats (physical device and surface paired color space or pixel format data) and present modes data. | |
| VkInstance | GetInstance () const |
| Getter for Vulkan instance. | |
| FVulkanDevice * | GetDevice () const |
| Getter for FVulkanDevice object created in FVulkanDynamicRHI::SelectDevice(). | |
| QueueFamilyIndices | FindQueueFamilies (VkPhysicalDevice device) |
| Queries the graphics card for available queue families and compares against the availability of graphics and presentation queues. | |
| bool | GetValidationLayersSetting () const |
| Getter for the boolean bEnableValidationLayers. | |
| const VkPhysicalDeviceFeatures & | GetGpuDeviceFeatures () const |
| Getter for m_SupportedDeviceFeatures which contains boolean values for supported features like availability of geometry shader or sampler anisotropy. | |
| const SwapChainSupportDetails & | GetGpuSwapChainSupportDetails () const |
| Getter for m_GPUSwapChainSupport struct which gets initialized in FVulkanDynamicRHI::IsDeviceSuitable(). | |
| uint32_t | SwapChainImageCount () const |
| Getter for the number of supported swapchain images. | |
| VkFormat | FindSupportedFormat (const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features) const |
| Finds a supported format from the list of candidate formats based on the desired tiling and features. Used in depth resource creation. | |
| VkFormat | FindDepthFormat () const |
| Finds an appropriate depth format for depth resources. | |
| uint32_t | FindMemoryType (uint32_t typeFilter, VkMemoryPropertyFlags properties) |
| Finds appropriate memory type with demanded properties. Basically a loop is run from counter i = 0 to VkPhysicalDeviceMemoryProperties.memoryTypeCount (number of valid elements in the memoryTypes array) and memoryType[i] is queried for appropriate properties. On condition satisfaction, counter i is returned. | |
| void | RegisterUniformBufferObject (VulkanUniformBuffer *ubo) |
| Register a uniformbuffer object to curate an array or uniformbuffers. | |
| void | UploadUniformBufferObjects (size_t frameIndex) |
| Uploads data to the registered VulkanUniformBuffers for the specified frame index. | |
| GLFWwindow * | GetSurfaceWindow () const |
| VkSurfaceKHR | GetSurface () const |
| Public Member Functions inherited from Karma::IVulkanDynamicRHI | |
| virtual ERHIInterfaceType | GetInterfaceType () const override |
| Public Member Functions inherited from Karma::FDynamicRHI | |
| virtual | ~FDynamicRHI ()=default |
| Virtual destructor for FDynamicRHI. | |
Static Public Member Functions | |
| static FVulkanDynamicRHI & | Get () |
| Getter for the FVulkanDynamicRHI instance. | |
| Static Public Member Functions inherited from Karma::FDynamicRHI | |
| static FDynamicRHI * | CreateRHI () |
Protected Member Functions | |
| void | CreateInstance () |
| Creates a Vulkan instance. | |
| void | SetupDebugMessenger () |
| Sets up the debug messenger for Vulkan instance. | |
| void | CreateSurface () |
| Platform agnostic creation of surface to present rendered images to. Typically they are backed by the category of glfw windows (on Linux, MacOS, and Windows). | |
| void | SelectDevice () |
| Picks an Engine appropriate GPU and creates FVulkanDevice. | |
Protected Attributes | |
| uint32_t | m_APIVersion |
| VkInstance | m_VulkanInstance |
| FVulkanDevice * | m_Device |
| VkDebugUtilsMessengerEXT | m_DebugMessenger |
| GLFWwindow * | m_WindowHandle |
| VkSurfaceKHR | m_Surface |
| VkPhysicalDeviceFeatures | m_SupportedDeviceFeatures |
| VkPhysicalDevice | m_PhysicalDevice = VK_NULL_HANDLE |
| SwapChainSupportDetails | m_GPUSwapChainSupport |
| uint32_t | m_SwapChainImageCount |
| std::set< VulkanUniformBuffer * > | m_VulkanUBO |
Static Protected Attributes | |
| static bool | bEnableValidationLayers = false |
Vulkan implementation of the Dynamic RHI.
Provides Vulkan-specific implementations for initializing/deinitializing RHI along with Vulkan resources and rendering operations.
| Karma::FVulkanDynamicRHI::FVulkanDynamicRHI | ( | ) |
Initialization constructor.
Does the following
|
protected |
Creates a Vulkan instance.
|
protected |
Platform agnostic creation of surface to present rendered images to. Typically they are backed by the category of glfw windows (on Linux, MacOS, and Windows).
| VkFormat Karma::FVulkanDynamicRHI::FindDepthFormat | ( | ) | const |
Finds an appropriate depth format for depth resources.
| uint32_t Karma::FVulkanDynamicRHI::FindMemoryType | ( | uint32_t | typeFilter, |
| VkMemoryPropertyFlags | properties ) |
Finds appropriate memory type with demanded properties. Basically a loop is run from counter i = 0 to VkPhysicalDeviceMemoryProperties.memoryTypeCount (number of valid elements in the memoryTypes array) and memoryType[i] is queried for appropriate properties. On condition satisfaction, counter i is returned.
Graphics cards can offer different types of memory to allocate from. Each type of memory varies in terms of allowed operations and performance characteristics. We need to combine the requirements of the buffer and our own application requirements to find the right type of memory to use.
| typeFilter | A bitmask, and contains one bit set for every supported memory type for the resource. Bit i is set if and only if the memory type i in the VkPhysicalDeviceMemoryProperties structure for the physical device is supported for the resource. |
| properties | The demanded properties (https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/VkBufferUsageFlagBits.html). |
| QueueFamilyIndices Karma::FVulkanDynamicRHI::FindQueueFamilies | ( | VkPhysicalDevice | device | ) |
Queries the graphics card for available queue families and compares against the availability of graphics and presentation queues.
| device | The graphics card to be queired for queue family |
| VkFormat Karma::FVulkanDynamicRHI::FindSupportedFormat | ( | const std::vector< VkFormat > & | candidates, |
| VkImageTiling | tiling, | ||
| VkFormatFeatureFlags | features ) const |
Finds a supported format from the list of candidate formats based on the desired tiling and features. Used in depth resource creation.
|
inlinestatic |
Getter for the FVulkanDynamicRHI instance.
|
inline |
Getter for FVulkanDevice object created in FVulkanDynamicRHI::SelectDevice().
|
inline |
Getter for m_SupportedDeviceFeatures which contains boolean values for supported features like availability of geometry shader or sampler anisotropy.
|
inline |
Getter for m_GPUSwapChainSupport struct which gets initialized in FVulkanDynamicRHI::IsDeviceSuitable().
|
inline |
Getter for Vulkan instance.
|
inline |
Getter for the boolean bEnableValidationLayers.
For Debug builds bEnableValidationLayers is set to true
|
overridevirtual |
For initializing VulkanDynamic RHI.
Called from RHIInit() declared in KarmaRHI.h and defined in DynamicRHI.cpp
Implements Karma::FDynamicRHI.
| void Karma::FVulkanDynamicRHI::InitInstance | ( | ) |
Calls FVulkanDevice::InitGPU() to create Vulkan logical device from selected GPU, and created appropriate resources (commandpool, default texture etc).
|
inlineoverridevirtual |
| SwapChainSupportDetails Karma::FVulkanDynamicRHI::QuerySwapChainSupport | ( | VkPhysicalDevice | device | ) |
Uses Two-Pass Query to gather surface formats (physical device and surface paired color space or pixel format data) and present modes data.
| void Karma::FVulkanDynamicRHI::RegisterUniformBufferObject | ( | VulkanUniformBuffer * | ubo | ) |
Register a uniformbuffer object to curate an array or uniformbuffers.
|
protected |
Picks an Engine appropriate GPU and creates FVulkanDevice.
|
protected |
Sets up the debug messenger for Vulkan instance.
This function initializes the debug messenger that will handle debug messages from the Vulkan API. It populates the debug messenger create info structure and creates the debug messenger using the CreateDebugUtilsMessengerEXT function.
|
overridevirtual |
Shuts down the RHI.
Called from RHIExit() declared in KarmaRHI.h and defined in DynamicRHI.cpp
Cleans up resources and states used by the RHI.
Implements Karma::FDynamicRHI.
|
inline |
Getter for the number of supported swapchain images.
| void Karma::FVulkanDynamicRHI::UploadUniformBufferObjects | ( | size_t | frameIndex | ) |
Uploads data to the registered VulkanUniformBuffers for the specified frame index.
Typically called during rendering to update uniform buffer data for the current frame like so
| frameIndex | The index of the frame for which to upload UBO data |