Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
VulkanHelper Class Reference

Stores lots of different functions which shorten the amount of code which needs to be written for default vulkan operations. More...

#include <VulkanHelper.h>

Collaboration diagram for VulkanHelper:

Static Public Member Functions

static void initializeDebugFunctions (VkInstance instance)
static void initializeFunctions (VkInstance instance, VkDevice device)
static const VulkanFunctionsgetFunctions ()
template<typename T>
static void loadVkFunction (VkInstance instance, const std::string &name, T &functionPointer)
template<typename T>
static void loadVkDeviceFunction (VkDevice device, const std::string &name, T &functionPointer)
static void createBuffer (VkDevice device, VkPhysicalDevice physicalDevice, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory)
static void uploadDataToExistingBuffer (VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue queue, VkDeviceSize size, const void *dataPtr, VkBuffer targetBuffer)
static bool isValid (void *object)
static std::string strIsValid (void *object)
static void createBufferWithStaging (VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue queue, VkDeviceSize size, VkBufferUsageFlags usage, const void *dataPtr, VkBuffer &buffer, VkDeviceMemory &bufferMemory)
static void copyDataToBufferViaStaging (VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue queue, VkDeviceSize size, const void *dataPtr, VkBuffer buffer, VkDeviceMemory bufferMemory)
static uint32_t findMemoryType (VkPhysicalDevice physicalDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties)
static bool findSuitableMemoryType (VkPhysicalDevice physicalDevice, VkMemoryRequirements2 requirements, VkMemoryPropertyFlags properties, uint32_t &out_typeIndex)
static VkDeviceSize align (VkDeviceSize value, VkDeviceSize alignment)
static void copyBuffer (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, VkBuffer sourceBuffer, VkBuffer destinationBuffer, VkDeviceSize size)
static void copyBufferMultiple (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, const std::vector< BufferCopyObject > &bufferCopyObjects)
static void recordBufferCopyMultiple (EngineCore::ApplicationContext *context, VkCommandBuffer commandBuffer, const std::vector< BufferCopyObject > &bufferCopyObjects)
static VkCommandBuffer beginSingleTimeCommands (VkDevice device, VkCommandPool commandPool)
static void endSingleTimeCommands (VkDevice device, VkQueue graphicsQueue, VkCommandPool commandPool, VkCommandBuffer commandBuffer)
static void cleanupBuffer (VkDevice device, VkBuffer buffer, VkDeviceMemory bufferMemory)
static void createImage (VkDevice device, VkPhysicalDevice physicalDevice, uint32_t width, uint32_t height, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties, VkImage &image, VkDeviceMemory &imageMemory)
static void transitionImageLayout (VkCommandBuffer commandBuffer, VkDevice device, VkQueue graphicsQueue, VkCommandPool commandPool, VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t layerCount=1)
static bool hasStencilComponent (VkFormat format)
static void copyBufferToImage (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height)
static VkImageView createImageView (VkDevice device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags)
static VkDescriptorBufferInfo fullBufferInfo (VkBuffer buffer)
static VkResult allocateDescriptorSets (VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets, const std::string &name)
static VkResult createSemaphore (VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore, const std::string &name)
static VkResult allocateCommandBuffers (VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers, const std::string &name)
static VkResult createDescriptorSetLayout (VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout, const std::string &name)
static VkResult createPipelineLayout (VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout, const std::string &name)
static void createFence (VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence, const std::string &name)
static VkResult createDescriptorPool (VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool, const std::string &name)
static void beginLabel (VkCommandBuffer, const char *, const float *)
static void endLabel (VkCommandBuffer)
template<typename VulkanObjectType>
static void setObjectName (VkDevice device, VulkanObjectType objectHandle, const std::string &name)
template<typename VulkanObjectType>
static std::string getDebugName (VulkanObjectType objectHandle)

Static Private Member Functions

static std::string getName (const std::string &name, const std::string &suffix)

Static Private Attributes

static VulkanFunctions s_functions
static DynamicFunctionInitState s_functionInitializationState = NOT_INITIALIZED
static std::mutex s_mutex

Detailed Description

Stores lots of different functions which shorten the amount of code which needs to be written for default vulkan operations.

Definition at line 55 of file VulkanHelper.h.

Member Function Documentation

◆ align()

VkDeviceSize VulkanHelper::align ( VkDeviceSize value,
VkDeviceSize alignment )
static

Definition at line 310 of file VulkanHelper.cpp.

◆ allocateCommandBuffers()

VkResult VulkanHelper::allocateCommandBuffers ( VkDevice device,
const VkCommandBufferAllocateInfo * pAllocateInfo,
VkCommandBuffer * pCommandBuffers,
const std::string & name )
static

Definition at line 749 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Here is the call graph for this function:

◆ allocateDescriptorSets()

VkResult VulkanHelper::allocateDescriptorSets ( VkDevice device,
const VkDescriptorSetAllocateInfo * pAllocateInfo,
VkDescriptorSet * pDescriptorSets,
const std::string & name )
static

Definition at line 723 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Referenced by EngineCore::ComputePass::createDescriptorSet().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ beginLabel()

void VulkanHelper::beginLabel ( VkCommandBuffer ,
const char * ,
const float *  )
inlinestatic

Definition at line 313 of file VulkanHelper.h.

◆ beginSingleTimeCommands()

VkCommandBuffer VulkanHelper::beginSingleTimeCommands ( VkDevice device,
VkCommandPool commandPool )
static

Definition at line 454 of file VulkanHelper.cpp.

References setObjectName().

Referenced by copyBuffer(), copyBufferMultiple(), copyBufferToImage(), EngineCore::Headset::Headset(), and EngineCore::Renderer::initializeXrSwapchainFormats().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanupBuffer()

void VulkanHelper::cleanupBuffer ( VkDevice device,
VkBuffer buffer,
VkDeviceMemory bufferMemory )
static

Definition at line 495 of file VulkanHelper.cpp.

◆ copyBuffer()

void VulkanHelper::copyBuffer ( VkDevice device,
VkCommandPool commandPool,
VkQueue graphicsQueue,
VkBuffer sourceBuffer,
VkBuffer destinationBuffer,
VkDeviceSize size )
static

Definition at line 319 of file VulkanHelper.cpp.

References beginSingleTimeCommands(), endSingleTimeCommands(), and TRACY_ZONE_SCOPED_NAMED.

Referenced by copyDataToBufferViaStaging(), createBufferWithStaging(), and uploadDataToExistingBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copyBufferMultiple()

void VulkanHelper::copyBufferMultiple ( VkDevice device,
VkCommandPool commandPool,
VkQueue graphicsQueue,
const std::vector< BufferCopyObject > & bufferCopyObjects )
static

Definition at line 340 of file VulkanHelper.cpp.

References beginSingleTimeCommands(), endSingleTimeCommands(), and TRACY_ZONE_SCOPED_NAMED.

Here is the call graph for this function:

◆ copyBufferToImage()

void VulkanHelper::copyBufferToImage ( VkDevice device,
VkCommandPool commandPool,
VkQueue graphicsQueue,
VkBuffer buffer,
VkImage image,
uint32_t width,
uint32_t height )
static

Definition at line 645 of file VulkanHelper.cpp.

References beginSingleTimeCommands(), and endSingleTimeCommands().

Here is the call graph for this function:

◆ copyDataToBufferViaStaging()

void VulkanHelper::copyDataToBufferViaStaging ( VkDevice device,
VkPhysicalDevice physicalDevice,
VkCommandPool commandPool,
VkQueue queue,
VkDeviceSize size,
const void * dataPtr,
VkBuffer buffer,
VkDeviceMemory bufferMemory )
static

Definition at line 228 of file VulkanHelper.cpp.

References copyBuffer(), and createBuffer().

Here is the call graph for this function:

◆ createBuffer()

void VulkanHelper::createBuffer ( VkDevice device,
VkPhysicalDevice physicalDevice,
VkDeviceSize size,
VkBufferUsageFlags usage,
VkMemoryPropertyFlags properties,
VkBuffer & buffer,
VkDeviceMemory & bufferMemory )
static
Deprecated
Use VulkanBuffer with VMA instead for better memory management

Definition at line 76 of file VulkanHelper.cpp.

References findMemoryType(), getDebugName(), and TRACY_ZONE_SCOPED_NAMED.

Referenced by copyDataToBufferViaStaging(), EngineCore::VulkanBuffer::create(), createBufferWithStaging(), and uploadDataToExistingBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createBufferWithStaging()

void VulkanHelper::createBufferWithStaging ( VkDevice device,
VkPhysicalDevice physicalDevice,
VkCommandPool commandPool,
VkQueue queue,
VkDeviceSize size,
VkBufferUsageFlags usage,
const void * dataPtr,
VkBuffer & buffer,
VkDeviceMemory & bufferMemory )
static

Definition at line 183 of file VulkanHelper.cpp.

References copyBuffer(), and createBuffer().

Here is the call graph for this function:

◆ createDescriptorPool()

VkResult VulkanHelper::createDescriptorPool ( VkDevice device,
const VkDescriptorPoolCreateInfo * pCreateInfo,
const VkAllocationCallbacks * pAllocator,
VkDescriptorPool * pDescriptorPool,
const std::string & name )
static

Definition at line 800 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Referenced by EngineCore::Renderer::createHiZMipDescriptorSets(), and EngineCore::Renderer::createHiZSPDDescriptorSets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createDescriptorSetLayout()

VkResult VulkanHelper::createDescriptorSetLayout ( VkDevice device,
const VkDescriptorSetLayoutCreateInfo * pCreateInfo,
const VkAllocationCallbacks * pAllocator,
VkDescriptorSetLayout * pSetLayout,
const std::string & name )
static

Definition at line 761 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Referenced by EngineCore::Renderer::allocateDescriptors(), and EngineCore::ComputePass::create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createFence()

void VulkanHelper::createFence ( VkDevice device,
const VkFenceCreateInfo * pCreateInfo,
const VkAllocationCallbacks * pAllocator,
VkFence * pFence,
const std::string & name )
static

Definition at line 788 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Here is the call graph for this function:

◆ createImage()

void VulkanHelper::createImage ( VkDevice device,
VkPhysicalDevice physicalDevice,
uint32_t width,
uint32_t height,
VkFormat format,
VkImageTiling tiling,
VkImageUsageFlags usage,
VkMemoryPropertyFlags properties,
VkImage & image,
VkDeviceMemory & imageMemory )
static
Deprecated
Use Texture class with VMA instead for better memory management

Definition at line 503 of file VulkanHelper.cpp.

References findMemoryType().

Here is the call graph for this function:

◆ createImageView()

VkImageView VulkanHelper::createImageView ( VkDevice device,
VkImage image,
VkFormat format,
VkImageAspectFlags aspectFlags )
static

Definition at line 675 of file VulkanHelper.cpp.

◆ createPipelineLayout()

VkResult VulkanHelper::createPipelineLayout ( VkDevice device,
const VkPipelineLayoutCreateInfo * pCreateInfo,
const VkAllocationCallbacks * pAllocator,
VkPipelineLayout * pPipelineLayout,
const std::string & name )
static

Definition at line 774 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Referenced by EngineCore::Renderer::allocateDescriptors(), and EngineCore::ComputePass::create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createSemaphore()

VkResult VulkanHelper::createSemaphore ( VkDevice device,
const VkSemaphoreCreateInfo * pCreateInfo,
const VkAllocationCallbacks * pAllocator,
VkSemaphore * pSemaphore,
const std::string & name )
static

Definition at line 735 of file VulkanHelper.cpp.

References getName(), and setObjectName().

Here is the call graph for this function:

◆ endLabel()

void VulkanHelper::endLabel ( VkCommandBuffer )
inlinestatic

Definition at line 315 of file VulkanHelper.h.

◆ endSingleTimeCommands()

void VulkanHelper::endSingleTimeCommands ( VkDevice device,
VkQueue graphicsQueue,
VkCommandPool commandPool,
VkCommandBuffer commandBuffer )
static

Definition at line 475 of file VulkanHelper.cpp.

Referenced by copyBuffer(), copyBufferMultiple(), copyBufferToImage(), EngineCore::Headset::Headset(), and EngineCore::Renderer::initializeXrSwapchainFormats().

Here is the caller graph for this function:

◆ findMemoryType()

uint32_t VulkanHelper::findMemoryType ( VkPhysicalDevice physicalDevice,
uint32_t typeFilter,
VkMemoryPropertyFlags properties )
static

Definition at line 263 of file VulkanHelper.cpp.

Referenced by createBuffer(), and createImage().

Here is the caller graph for this function:

◆ findSuitableMemoryType()

bool VulkanHelper::findSuitableMemoryType ( VkPhysicalDevice physicalDevice,
VkMemoryRequirements2 requirements,
VkMemoryPropertyFlags properties,
uint32_t & out_typeIndex )
static

Definition at line 284 of file VulkanHelper.cpp.

Referenced by EngineCore::RenderProcess::createHiZPyramid(), and EngineCore::Headset::Headset().

Here is the caller graph for this function:

◆ fullBufferInfo()

◆ getDebugName()

template<typename VulkanObjectType>
std::string VulkanHelper::getDebugName ( VulkanObjectType objectHandle)
inlinestatic

Definition at line 372 of file VulkanHelper.h.

Referenced by createBuffer(), EngineCore::ComputePass::createDescriptorSet(), fullBufferInfo(), and EngineCore::ComputePass::updateDescriptorSet().

Here is the caller graph for this function:

◆ getFunctions()

const VulkanFunctions & VulkanHelper::getFunctions ( )
static

Definition at line 65 of file VulkanHelper.cpp.

References s_functionInitializationState, and s_functions.

Referenced by EngineCore::Engine::cleanup(), EngineCore::Engine::createVulkanDebugMessenger(), EngineCore::Engine::mainLoop(), EngineCore::Renderer::recordPass2RenderPass(), and EngineCore::Renderer::recordRenderPass().

Here is the caller graph for this function:

◆ getName()

std::string VulkanHelper::getName ( const std::string & name,
const std::string & suffix )
staticprivate

Definition at line 813 of file VulkanHelper.cpp.

Referenced by allocateCommandBuffers(), allocateDescriptorSets(), createDescriptorPool(), createDescriptorSetLayout(), createFence(), createPipelineLayout(), and createSemaphore().

Here is the caller graph for this function:

◆ hasStencilComponent()

bool VulkanHelper::hasStencilComponent ( VkFormat format)
static

Definition at line 640 of file VulkanHelper.cpp.

Referenced by transitionImageLayout().

Here is the caller graph for this function:

◆ initializeDebugFunctions()

void VulkanHelper::initializeDebugFunctions ( VkInstance instance)
static

Definition at line 17 of file VulkanHelper.cpp.

References DEBUG_FUNCTIONS_INITIALIZED, loadVkFunction(), s_functionInitializationState, and s_functions.

Referenced by EngineCore::ApplicationContext::createResources(), and initializeFunctions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializeFunctions()

void VulkanHelper::initializeFunctions ( VkInstance instance,
VkDevice device )
static

Definition at line 32 of file VulkanHelper.cpp.

References FINISHED, initializeDebugFunctions(), loadVkDeviceFunction(), loadVkFunction(), s_functionInitializationState, s_functions, and s_mutex.

Referenced by EngineCore::Engine::initVulkan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isValid()

bool VulkanHelper::isValid ( void * object)
static

Definition at line 173 of file VulkanHelper.cpp.

Referenced by strIsValid().

Here is the caller graph for this function:

◆ loadVkDeviceFunction()

template<typename T>
void VulkanHelper::loadVkDeviceFunction ( VkDevice device,
const std::string & name,
T & functionPointer )
inlinestatic

Definition at line 77 of file VulkanHelper.h.

Referenced by initializeFunctions().

Here is the caller graph for this function:

◆ loadVkFunction()

template<typename T>
void VulkanHelper::loadVkFunction ( VkInstance instance,
const std::string & name,
T & functionPointer )
inlinestatic

Definition at line 63 of file VulkanHelper.h.

Referenced by initializeDebugFunctions(), and initializeFunctions().

Here is the caller graph for this function:

◆ recordBufferCopyMultiple()

void VulkanHelper::recordBufferCopyMultiple ( EngineCore::ApplicationContext * context,
VkCommandBuffer commandBuffer,
const std::vector< BufferCopyObject > & bufferCopyObjects )
static

Definition at line 364 of file VulkanHelper.cpp.

References EngineCore::ApplicationContext::getVkGraphicsQueueFamilyIndex(), EngineCore::ApplicationContext::getVkTransferQueueFamilyIndex(), and TRACY_ZONE_SCOPED_FUNCTION.

Here is the call graph for this function:

◆ setObjectName()

template<typename VulkanObjectType>
void VulkanHelper::setObjectName ( VkDevice device,
VulkanObjectType objectHandle,
const std::string & name )
inlinestatic

◆ strIsValid()

std::string VulkanHelper::strIsValid ( void * object)
static

Definition at line 178 of file VulkanHelper.cpp.

References CHECK_STR, CROSS_STR, and isValid().

Referenced by EngineCore::Renderer::allocateDescriptors(), and fullBufferInfo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transitionImageLayout()

void VulkanHelper::transitionImageLayout ( VkCommandBuffer commandBuffer,
VkDevice device,
VkQueue graphicsQueue,
VkCommandPool commandPool,
VkImage image,
VkFormat format,
VkImageLayout oldLayout,
VkImageLayout newLayout,
uint32_t layerCount = 1 )
static

Definition at line 554 of file VulkanHelper.cpp.

References hasStencilComponent().

Referenced by EngineCore::Headset::Headset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uploadDataToExistingBuffer()

void VulkanHelper::uploadDataToExistingBuffer ( VkDevice device,
VkPhysicalDevice physicalDevice,
VkCommandPool commandPool,
VkQueue queue,
VkDeviceSize size,
const void * dataPtr,
VkBuffer targetBuffer )
static

Definition at line 136 of file VulkanHelper.cpp.

References copyBuffer(), and createBuffer().

Referenced by EngineCore::RenderProcess::createIndirectDrawBuffer().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ s_functionInitializationState

DynamicFunctionInitState VulkanHelper::s_functionInitializationState = NOT_INITIALIZED
staticprivate

Definition at line 380 of file VulkanHelper.h.

Referenced by getFunctions(), initializeDebugFunctions(), and initializeFunctions().

◆ s_functions

VulkanFunctions VulkanHelper::s_functions
staticprivate

Definition at line 379 of file VulkanHelper.h.

Referenced by getFunctions(), initializeDebugFunctions(), and initializeFunctions().

◆ s_mutex

std::mutex VulkanHelper::s_mutex
staticprivate

Definition at line 381 of file VulkanHelper.h.

Referenced by initializeFunctions().


The documentation for this class was generated from the following files:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Core/VulkanHelper.h
  • /home/magerbeton/Documents/gl3-vulkan/Engine/src/Engine/Core/VulkanHelper.cpp