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

Static helpers for common Vulkan allocation, copy, descriptor, and debug operations. More...

#include <VulkanHelper.h>

Collaboration diagram for VulkanHelper:

Static Public Member Functions

static void initializeDebugFunctions (VkInstance instance)
 Loads debug utils extension functions from an instance.
static void initializeFunctions (VkInstance instance, VkDevice device)
 Loads all Vulkan extension functions used by the engine.
static const VulkanFunctions & getFunctions ()
 Returns the loaded Vulkan extension function table.
template<typename T>
static void loadVkFunction (VkInstance instance, const std::string &name, T &functionPointer)
 Loads one Vulkan instance-level function pointer.
template<typename T>
static void loadVkDeviceFunction (VkDevice device, const std::string &name, T &functionPointer)
 Loads one Vulkan device-level function pointer.
static void createBuffer (VkDevice device, VkPhysicalDevice physicalDevice, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags properties, VkBuffer &buffer, VkDeviceMemory &bufferMemory)
 Creates a Vulkan buffer, allocates memory for it, and binds the memory at offset 0.
static void uploadDataToExistingBuffer (VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue queue, VkDeviceSize size, const void *dataPtr, VkBuffer targetBuffer)
 Uploads CPU memory into an existing buffer through a temporary staging buffer.
static bool isValid (void *object)
 Checks whether a Vulkan dispatchable handle value is non-null.
static std::string strIsValid (void *object)
 Returns a checkmark or cross string for a Vulkan dispatchable handle value.
static uint32_t findMemoryType (VkPhysicalDevice physicalDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties)
 Finds a memory type index that satisfies a bitmask and required properties.
static bool findSuitableMemoryType (VkPhysicalDevice physicalDevice, VkMemoryRequirements2 requirements, VkMemoryPropertyFlags properties, uint32_t &out_typeIndex)
 Finds a memory type index without throwing on failure.
static VkDeviceSize align (VkDeviceSize value, VkDeviceSize alignment)
 Rounds a size up to the next multiple of an alignment.
static void copyBuffer (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, VkBuffer sourceBuffer, VkBuffer destinationBuffer, VkDeviceSize size)
 Copies bytes from one buffer to another and waits for the queue to become idle.
static void copyBufferMultiple (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, const std::vector< BufferCopyObject > &bufferCopyObjects)
 Copies several buffer regions in one command buffer and waits for the queue to become idle.
static void recordBufferCopyMultiple (Engine::Core::ApplicationContext *context, VkCommandBuffer commandBuffer, const std::vector< BufferCopyObject > &bufferCopyObjects)
 Records several buffer copy commands into an existing command buffer.
static VkCommandBuffer beginSingleTimeCommands (VkDevice device, VkCommandPool commandPool)
 Allocates and begins a primary command buffer for one-time submission.
static void endSingleTimeCommands (VkDevice device, VkQueue graphicsQueue, VkCommandPool commandPool, VkCommandBuffer commandBuffer)
 Ends, submits, waits for, and frees a one-time command buffer.
static void cleanupBuffer (VkDevice device, VkBuffer buffer, VkDeviceMemory bufferMemory)
 Destroys a buffer and frees its memory when the handles are non-null.
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)
 Creates a 2D image, allocates memory for it, and binds the memory at offset 0.
static void transitionImageLayout (VkCommandBuffer commandBuffer, VkDevice device, VkQueue graphicsQueue, VkCommandPool commandPool, VkImage image, VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout, uint32_t layerCount=1)
 Records an image layout transition barrier into an existing command buffer.
static bool hasStencilComponent (VkFormat format)
 Checks whether a Vulkan format contains a stencil component.
static void copyBufferToImage (VkDevice device, VkCommandPool commandPool, VkQueue graphicsQueue, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height)
 Copies a buffer into the first layer and mip level of a 2D image.
static VkImageView createImageView (VkDevice device, VkImage image, VkFormat format, VkImageAspectFlags aspectFlags)
 Creates a 2D image view over one mip level and one array layer.
static VkDescriptorBufferInfo fullBufferInfo (VkBuffer buffer)
 Creates descriptor buffer info for a whole buffer binding.
static VkResult allocateDescriptorSets (VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets, const std::string &name)
 Allocates descriptor sets and assigns a debug name to the first returned set.
static VkResult createSemaphore (VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore, const std::string &name)
 Creates a semaphore and assigns a debug name.
static VkResult allocateCommandBuffers (VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers, const std::string &name)
 Allocates command buffers and assigns a debug name to the first returned command buffer.
static VkResult createDescriptorSetLayout (VkDevice device, const VkDescriptorSetLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorSetLayout *pSetLayout, const std::string &name)
 Creates a descriptor set layout and assigns a debug name.
static VkResult createPipelineLayout (VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout, const std::string &name)
 Creates a pipeline layout and assigns a debug name.
static void createFence (VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence, const std::string &name)
 Creates a fence and assigns a debug name.
static VkResult createDescriptorPool (VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDescriptorPool *pDescriptorPool, const std::string &name)
 Creates a descriptor pool and assigns a debug name.
static void beginLabel (VkCommandBuffer, const char *, const float *)
 Release-build no-op for beginning a Vulkan debug label region.
static void endLabel (VkCommandBuffer)
 Release-build no-op for ending a Vulkan debug label region.
template<typename VulkanObjectType>
static void setObjectName (VkDevice device, VulkanObjectType objectHandle, const std::string &name)
 Release-build no-op for assigning a Vulkan object debug name.
template<typename VulkanObjectType>
static std::string getDebugName (VulkanObjectType objectHandle)
 Release-build no-op for retrieving a Vulkan object debug name.

Static Private Member Functions

static std::string getName (const std::string &name, const std::string &suffix)
 Appends an object-type suffix to a debug name.

Static Private Attributes

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

Detailed Description

Static helpers for common Vulkan allocation, copy, descriptor, and debug operations.

The helper does not own Vulkan objects unless a function explicitly creates an object and returns it through an output parameter. Destroy buffers, images, image views, descriptor pools, descriptor set layouts, pipeline layouts, fences, semaphores, and command pools with the matching Vulkan destroy call.

Definition at line 93 of file VulkanHelper.h.

Member Function Documentation

◆ align()

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

Rounds a size up to the next multiple of an alignment.

Parameters
valueValue to align in bytes.
alignmentAlignment in bytes. Must be a non-zero power of two.
Returns
value rounded up to alignment, or 0 when value is 0.

◆ allocateCommandBuffers()

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

Allocates command buffers and assigns a debug name to the first returned command buffer.

Parameters
deviceLogical device that owns the command pool referenced by pAllocateInfo.
pAllocateInfoVulkan command buffer allocation info.
pCommandBuffersOutput command buffer array.
nameBase debug name. The helper appends a command-buffer suffix.
Returns
VK_SUCCESS when allocation succeeds.
Exceptions
std::runtime_errorwhen vkAllocateCommandBuffers fails.

◆ allocateDescriptorSets()

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

Allocates descriptor sets and assigns a debug name to the first returned set.

Parameters
deviceLogical device that owns the descriptor pool referenced by pAllocateInfo.
pAllocateInfoVulkan allocation info.
pDescriptorSetsOutput descriptor set array.
nameBase debug name. The helper appends a descriptor-set suffix.
Returns
Result from vkAllocateDescriptorSets.

◆ beginLabel()

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

Release-build no-op for beginning a Vulkan debug label region.

Definition at line 582 of file VulkanHelper.h.

◆ beginSingleTimeCommands()

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

Allocates and begins a primary command buffer for one-time submission.

Parameters
deviceLogical device that owns commandPool.
commandPoolCommand pool used to allocate the command buffer.
Returns
Begun command buffer with VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT.

◆ cleanupBuffer()

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

Destroys a buffer and frees its memory when the handles are non-null.

Parameters
deviceLogical device that owns the buffer and memory.
bufferBuffer handle to destroy.
bufferMemoryDevice memory handle to free.

◆ copyBuffer()

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

Copies bytes from one buffer to another and waits for the queue to become idle.

Parameters
deviceLogical device that owns the command pool.
commandPoolCommand pool used to allocate a one-time primary command buffer.
graphicsQueueQueue that executes the copy command.
sourceBufferSource buffer. It must support VK_BUFFER_USAGE_TRANSFER_SRC_BIT.
destinationBufferDestination buffer. It must support VK_BUFFER_USAGE_TRANSFER_DST_BIT.
sizeNumber of bytes to copy from offset 0 to offset 0.

◆ copyBufferMultiple()

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

Copies several buffer regions in one command buffer and waits for the queue to become idle.

Parameters
deviceLogical device that owns the command pool.
commandPoolCommand pool used to allocate a one-time primary command buffer.
graphicsQueueQueue that executes the copy commands.
bufferCopyObjectsCopy operations to record.
Warning
The current implementation uses each object's size and copies from offset 0 to offset 0.

◆ copyBufferToImage()

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

Copies a buffer into the first layer and mip level of a 2D image.

Parameters
deviceLogical device that owns the command pool.
commandPoolCommand pool used for the one-time copy command buffer.
graphicsQueueQueue that executes the copy command and is waited idle before return.
bufferSource buffer. It must support VK_BUFFER_USAGE_TRANSFER_SRC_BIT.
imageDestination image. It must be in VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL.
widthCopy width in pixels.
heightCopy height in pixels.

◆ createBuffer()

void VulkanHelper::createBuffer ( VkDevice device,
VkPhysicalDevice physicalDevice,
VkDeviceSize size,
VkBufferUsageFlags usage,
VkMemoryPropertyFlags properties,
VkBuffer & buffer,
VkDeviceMemory & bufferMemory )
static

Creates a Vulkan buffer, allocates memory for it, and binds the memory at offset 0.

Parameters
deviceLogical device that owns the buffer and memory.
physicalDevicePhysical device used to select the memory type.
sizeBuffer size in bytes.
usageVulkan buffer usage flags.
propertiesRequired memory property flags.
bufferOutput buffer handle.
bufferMemoryOutput device memory handle bound to buffer.
Exceptions
std::runtime_errorwhen buffer creation, memory type selection, or memory allocation fails.

◆ createDescriptorPool()

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

Creates a descriptor pool and assigns a debug name.

Parameters
deviceLogical device that owns the pool.
pCreateInfoVulkan descriptor pool create info.
pAllocatorOptional Vulkan allocation callbacks.
pDescriptorPoolOutput descriptor pool handle.
nameBase debug name. The helper appends a descriptor-pool suffix.
Returns
Result from vkCreateDescriptorPool.

◆ createDescriptorSetLayout()

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

Creates a descriptor set layout and assigns a debug name.

Parameters
deviceLogical device that owns the layout.
pCreateInfoVulkan descriptor set layout create info.
pAllocatorOptional Vulkan allocation callbacks.
pSetLayoutOutput descriptor set layout handle.
nameBase debug name. The helper appends a descriptor-set-layout suffix.
Returns
VK_SUCCESS when creation succeeds.
Exceptions
std::runtime_errorwhen vkCreateDescriptorSetLayout fails.

◆ createFence()

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

Creates a fence and assigns a debug name.

Parameters
deviceLogical device that owns the fence.
pCreateInfoVulkan fence create info.
pAllocatorOptional Vulkan allocation callbacks.
pFenceOutput fence handle.
nameBase debug name. The helper appends a fence suffix.
Exceptions
std::runtime_errorwhen vkCreateFence fails.

◆ 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

Creates a 2D image, allocates memory for it, and binds the memory at offset 0.

Parameters
deviceLogical device that owns the image and memory.
physicalDevicePhysical device used to select the memory type.
widthImage width in pixels.
heightImage height in pixels.
formatImage format.
tilingImage tiling mode.
usageVulkan image usage flags.
propertiesRequired memory property flags.
imageOutput image handle.
imageMemoryOutput device memory handle bound to image.
Exceptions
std::runtime_errorwhen image creation, memory type selection, or memory allocation fails.

◆ createImageView()

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

Creates a 2D image view over one mip level and one array layer.

Parameters
deviceLogical device that owns image.
imageImage handle to view. Must not be VK_NULL_HANDLE.
formatView format.
aspectFlagsImage aspect flags for the subresource range.
Returns
Created image view handle.
Exceptions
std::runtime_errorwhen vkCreateImageView fails.

◆ createPipelineLayout()

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

Creates a pipeline layout and assigns a debug name.

Parameters
deviceLogical device that owns the layout.
pCreateInfoVulkan pipeline layout create info. Must not be null.
pAllocatorOptional Vulkan allocation callbacks.
pPipelineLayoutOutput pipeline layout handle.
nameBase debug name. The helper appends a pipeline-layout suffix.
Returns
VK_SUCCESS when creation succeeds.
Exceptions
std::runtime_errorwhen vkCreatePipelineLayout fails.

◆ createSemaphore()

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

Creates a semaphore and assigns a debug name.

Parameters
deviceLogical device that owns the semaphore.
pCreateInfoVulkan semaphore create info. Must not be null.
pAllocatorOptional Vulkan allocation callbacks.
pSemaphoreOutput semaphore handle.
nameBase debug name. The helper appends a semaphore suffix.
Returns
VK_SUCCESS when the semaphore was created.
Exceptions
std::runtime_errorwhen vkCreateSemaphore fails.

◆ endLabel()

void VulkanHelper::endLabel ( VkCommandBuffer )
inlinestatic

Release-build no-op for ending a Vulkan debug label region.

Definition at line 587 of file VulkanHelper.h.

◆ endSingleTimeCommands()

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

Ends, submits, waits for, and frees a one-time command buffer.

Parameters
deviceLogical device that owns commandPool.
graphicsQueueQueue that executes the command buffer.
commandPoolCommand pool used to free the command buffer.
commandBufferCommand buffer returned by beginSingleTimeCommands().

◆ findMemoryType()

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

Finds a memory type index that satisfies a bitmask and required properties.

Parameters
physicalDevicePhysical device whose memory properties are queried.
typeFilterMemory type bitmask from VkMemoryRequirements::memoryTypeBits.
propertiesRequired memory property flags.
Returns
Matching memory type index.
Exceptions
std::runtime_errorwhen no supported memory type matches.

◆ findSuitableMemoryType()

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

Finds a memory type index without throwing on failure.

Parameters
physicalDevicePhysical device whose memory properties are queried.
requirementsMemory requirements containing the supported memory type bitmask.
propertiesRequired memory property flags.
out_typeIndexReceives the matching memory type index when the function returns true.
Returns
true when a memory type matches requirements and properties.

◆ fullBufferInfo()

VkDescriptorBufferInfo VulkanHelper::fullBufferInfo ( VkBuffer buffer)
static

Creates descriptor buffer info for a whole buffer binding.

Parameters
bufferBuffer handle to describe.
Returns
VkDescriptorBufferInfo with offset 0 and range VK_WHOLE_SIZE.

◆ getDebugName()

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

Release-build no-op for retrieving a Vulkan object debug name.

Parameters
objectHandleUnused Vulkan object handle.
Returns
Empty string.

Definition at line 661 of file VulkanHelper.h.

◆ getFunctions()

const VulkanFunctions & VulkanHelper::getFunctions ( )
static

Returns the loaded Vulkan extension function table.

Returns
Reference to the engine-owned function table.
Exceptions
std::runtime_errorwhen no Vulkan helper function initialization has run.

◆ getName()

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

Appends an object-type suffix to a debug name.

Parameters
nameBase debug name.
suffixSuffix added to name.
Returns
Combined debug name.

◆ hasStencilComponent()

bool VulkanHelper::hasStencilComponent ( VkFormat format)
static

Checks whether a Vulkan format contains a stencil component.

Parameters
formatFormat to inspect.
Returns
true for VK_FORMAT_D32_SFLOAT_S8_UINT and VK_FORMAT_D24_UNORM_S8_UINT.

◆ initializeDebugFunctions()

void VulkanHelper::initializeDebugFunctions ( VkInstance instance)
static

Loads debug utils extension functions from an instance.

Parameters
instanceVulkan instance used with vkGetInstanceProcAddr.
Exceptions
std::runtime_errorin debug builds when a required debug utils entry point is unavailable.

◆ initializeFunctions()

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

Loads all Vulkan extension functions used by the engine.

Parameters
instanceVulkan instance used with vkGetInstanceProcAddr.
deviceVulkan device used with vkGetDeviceProcAddr.
Exceptions
std::runtime_errorwhen a required instance or device entry point is unavailable.

◆ isValid()

bool VulkanHelper::isValid ( void * object)
static

Checks whether a Vulkan dispatchable handle value is non-null.

Parameters
objectHandle value cast to void*.
Returns
true when object is not VK_NULL_HANDLE.

◆ loadVkDeviceFunction()

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

Loads one Vulkan device-level function pointer.

Template Parameters
TFunction pointer type to assign.
Parameters
deviceVulkan device used with vkGetDeviceProcAddr.
nameExact Vulkan entry point name.
functionPointerOutput function pointer.
Exceptions
std::runtime_errorwhen the entry point is unavailable.

Definition at line 149 of file VulkanHelper.h.

◆ loadVkFunction()

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

Loads one Vulkan instance-level function pointer.

Template Parameters
TFunction pointer type to assign.
Parameters
instanceVulkan instance used with vkGetInstanceProcAddr.
nameExact Vulkan entry point name.
functionPointerOutput function pointer.
Exceptions
std::runtime_errorwhen the entry point is unavailable.

Definition at line 127 of file VulkanHelper.h.

◆ recordBufferCopyMultiple()

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

Records several buffer copy commands into an existing command buffer.

Parameters
contextApplication context used to inspect graphics and transfer queue family indices.
commandBufferCommand buffer already in the recording state.
bufferCopyObjectsCopy operations to record.
Warning
The current implementation uses each object's size and copies from offset 0 to offset 0.

◆ setObjectName()

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

Release-build no-op for assigning a Vulkan object debug name.

Parameters
deviceUnused logical device.
objectHandleUnused Vulkan object handle.
nameUnused debug name.

Definition at line 651 of file VulkanHelper.h.

◆ strIsValid()

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

Returns a checkmark or cross string for a Vulkan dispatchable handle value.

Parameters
objectHandle value cast to void*.
Returns
CHECK_STR when object is valid, otherwise CROSS_STR.

◆ 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

Records an image layout transition barrier into an existing command buffer.

Parameters
commandBufferCommand buffer already in the recording state.
deviceReserved; the current implementation does not access it.
graphicsQueueReserved; the current implementation does not submit work.
commandPoolReserved; the current implementation does not allocate command buffers.
imageImage to transition.
formatImage format. Stencil formats add VK_IMAGE_ASPECT_STENCIL_BIT for depth-stencil layouts.
oldLayoutSource image layout.
newLayoutDestination image layout.
layerCountNumber of array layers in the barrier subresource range.
Exceptions
std::invalid_argumentwhen the old/new layout pair is unsupported.

◆ uploadDataToExistingBuffer()

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

Uploads CPU memory into an existing buffer through a temporary staging buffer.

Parameters
deviceLogical device that owns the buffers.
physicalDevicePhysical device used to allocate the staging buffer memory.
commandPoolCommand pool used for the one-time copy command buffer.
queueQueue that executes the copy command and is waited idle before return.
sizeNumber of bytes to upload.
dataPtrSource CPU memory. The pointer must reference at least size bytes.
targetBufferDestination buffer. It must support VK_BUFFER_USAGE_TRANSFER_DST_BIT.
Exceptions
std::runtime_errorwhen staging buffer creation or memory allocation fails.

Member Data Documentation

◆ s_functionInitializationState

DynamicFunctionInitState VulkanHelper::s_functionInitializationState
staticprivate

Definition at line 669 of file VulkanHelper.h.

◆ s_functions

VulkanFunctions VulkanHelper::s_functions
staticprivate

Definition at line 668 of file VulkanHelper.h.

◆ s_mutex

std::mutex VulkanHelper::s_mutex
staticprivate

Definition at line 670 of file VulkanHelper.h.


The documentation for this class was generated from the following file:
  • /workspace/magerbeton/gl3-vulkan/code/Engine/include/Engine/Core/VulkanHelper.h