KarmaEngine
Game Engine for practical learning and research purposes
Loading...
Searching...
No Matches
Karma::FVulkanDevice Class Reference

Manages Vulkan device resources and operations. More...

#include <VulkanDevice.h>

Public Member Functions

 FVulkanDevice (FVulkanDynamicRHI *InRHI, VkPhysicalDevice InGpu)
 Constructor for FVulkanDevice.
 ~FVulkanDevice ()
 Destructor for FVulkanDevice.
void InitGPU ()
 Creates the Vulkan logical device and default vulkan resources.
void Destroy ()
 Destroys the logical vkdevice by making Vulkan API call.
void WaitUntilIdle ()
 Waits on the host by blocking the calling CPU thread until the Vulkan logical device completes all pending GPU operations across all queues.
VkDevice GetLogicalDevice () const
 Retrieves the Vulkan logical device handle.
VkPhysicalDevice GetGPU () const
 Retrieves the Vulkan physical device handle.
VkCommandPool GetCommandPool () const
 Retrives the Vulkan command pool for the commandbuffers.
void TransitionImageLayout (VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout)
 Transitions the layout of an image from oldLayout to newLayout.
void CopyBufferToImage (VkBuffer buffer, VkImage image, uint32_t width, uint32_t height)
 Copies data from a buffer to a Vulkan image.
bool HasStencilComponent (VkFormat format)
 Checks if the given format has a stencil component.
void InitializeDefaultDescriptorSets (uint32_t MaxFramesInFlight)
VkQueue GetGraphicsQueue () const
 Getter for the graphics queue created in FVulkanDevice::InitGPU().
FVulkanDynamicRHIGetVulkanDynamicRHI () const
 Getter for the present queue created in FVulkanDevice::InitGPU().
FVulkanFenceManagerGetFenceManager ()
 Getter for the default texture (unreal grid).
KarmaVector< FVulkanDescriptorSets * > & GetDefaultDescriptorSets ()
FVulkanDescriptorSetsLayoutGetDefaultDescriptorSetLayout () const
VulkanTextureGetDefaultTexture () const
VulkanShaderGetDefaultShader () const

Detailed Description

Manages Vulkan device resources and operations.

This class encapsulates the functionality related to a Vulkan logical device, including initialization, resource management, and cleanup.

Constructor & Destructor Documentation

◆ FVulkanDevice()

Karma::FVulkanDevice::FVulkanDevice ( FVulkanDynamicRHI * InRHI,
VkPhysicalDevice InGpu )

Constructor for FVulkanDevice.

Initializes the Vulkan device with the given physical device (GPU) and dynamic RHI instance.

Parameters
InRHIPointer to the FVulkanDynamicRHI instance
InGpuThe Vulkan physical device (GPU) handle
Since
Karma 1.0.0

◆ ~FVulkanDevice()

Karma::FVulkanDevice::~FVulkanDevice ( )

Destructor for FVulkanDevice.

Cleans up resources associated with the Vulkan device.

Since
Karma 1.0.0

Member Function Documentation

◆ CopyBufferToImage()

void Karma::FVulkanDevice::CopyBufferToImage ( VkBuffer buffer,
VkImage image,
uint32_t width,
uint32_t height )

Copies data from a buffer to a Vulkan image.

This is typically used for uploading texture data from a staging buffer to a Vulkan image.

Parameters
bufferThe source buffer containing the data
imageThe destination image
widthThe width of the image
heightThe height of the image
See also
VulkanTexture::CreateTextureImage()
Since
Karma 1.0.0

◆ Destroy()

void Karma::FVulkanDevice::Destroy ( )

Destroys the logical vkdevice by making Vulkan API call.

Since
Karma 1.0.0

◆ GetCommandPool()

VkCommandPool Karma::FVulkanDevice::GetCommandPool ( ) const
inline

Retrives the Vulkan command pool for the commandbuffers.

Since
Karma 1.0.0

◆ GetFenceManager()

FVulkanFenceManager & Karma::FVulkanDevice::GetFenceManager ( )
inline

Getter for the default texture (unreal grid).

Since
Karma 1.0.0

◆ GetGPU()

VkPhysicalDevice Karma::FVulkanDevice::GetGPU ( ) const
inline

Retrieves the Vulkan physical device handle.

Returns
VkPhysicalDevice The Vulkan physical device (GPU)

◆ GetGraphicsQueue()

VkQueue Karma::FVulkanDevice::GetGraphicsQueue ( ) const
inline

Getter for the graphics queue created in FVulkanDevice::InitGPU().

Since
Karma 1.0.0

◆ GetLogicalDevice()

VkDevice Karma::FVulkanDevice::GetLogicalDevice ( ) const
inline

Retrieves the Vulkan logical device handle.

Returns
VkDevice The Vulkan logical device.

◆ GetVulkanDynamicRHI()

FVulkanDynamicRHI * Karma::FVulkanDevice::GetVulkanDynamicRHI ( ) const
inline

Getter for the present queue created in FVulkanDevice::InitGPU().

Since
Karma 1.0.0

◆ HasStencilComponent()

bool Karma::FVulkanDevice::HasStencilComponent ( VkFormat format)

Checks if the given format has a stencil component.

Sees if the format is VK_FORMAT_D32_SFLOAT_S8_UINT or VK_FORMAT_D24_UNORM_S8_UINT

Parameters
formatThe format to be checked
See also
VulkanContext::TransitionImageLayout()
Since
Karma 1.0.0

◆ InitGPU()

void Karma::FVulkanDevice::InitGPU ( )

Creates the Vulkan logical device and default vulkan resources.

Note
Called from FVulkanDynamicRHI::InitInstance()
Since
Karma 1.0.0

◆ TransitionImageLayout()

void Karma::FVulkanDevice::TransitionImageLayout ( VkImage image,
VkFormat format,
VkImageLayout oldLayout,
VkImageLayout newLayout )

Transitions the layout of an image from oldLayout to newLayout.

Image layout transitions are crucial in Vulkan to ensure that images are in the correct state for different operations, such as rendering, sampling, or transferring data.

Parameters
imageThe image to be transitioned
formatThe format of the image
oldLayoutThe current layout of the image
newLayoutThe desired layout of the image
See also
VulkanTexture::CreateTextureImage()
Since
Karma 1.0.0

◆ WaitUntilIdle()

void Karma::FVulkanDevice::WaitUntilIdle ( )

Waits on the host by blocking the calling CPU thread until the Vulkan logical device completes all pending GPU operations across all queues.

Since
Karma 1.0.0

The documentation for this class was generated from the following files: