Mandrill 2025.6.0
Loading...
Searching...
No Matches
Mandrill::Helpers Class Reference

Class with Vulkan helper functions. This class provides static functions that can be called directly without creating an object. More...

#include <Helpers.h>

Static Public Member Functions

static VkCommandBuffer cmdBegin (ptr< Device > pDevice)
 Create a new one-time use command buffer. This call should be paired with a corresponding call to cmdEnd().
 
static void cmdEnd (ptr< Device > pDevice, VkCommandBuffer cmd, const std::vector< VkSemaphore > &waitSemaphores={}, const std::vector< VkPipelineStageFlags > &waitStages={}, const std::vector< VkSemaphore > &signalSemaphores={})
 End a one-time use command buffer that was initialized with a call to cmdBegin().
 
static uint32_t findMemoryType (ptr< Device > pDevice, uint32_t typeFilter, VkMemoryPropertyFlags properties)
 Find a suitable memory type given the memory properties.
 
static VkFormat findSupportedFormat (ptr< Device > pDevice, std::vector< VkFormat > candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
 Find supported format for an attachment.
 
static VkFormat findDepthFormat (ptr< Device > pDevice)
 Find a supported depth format for a depth attachment.
 
static void imageBarrier (VkCommandBuffer cmd, VkImage image, VkPipelineStageFlags2 srcStage, VkAccessFlags2 srcAccess, VkPipelineStageFlags2 dstStage, VkAccessFlags2 dstAccess, VkImageLayout oldLayout, VkImageLayout newLayout, VkImageSubresourceRange *pSubresourceRange=nullptr)
 Create an image barrier with layout transition.
 
static void copyBufferToImage (VkCommandBuffer cmd, VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, uint32_t depth)
 Copy a buffer to an image.
 
static void copyImageToBuffer (VkCommandBuffer cmd, VkImage image, VkBuffer buffer, uint32_t width, uint32_t height, uint32_t depth)
 Copy an image to a buffer.
 
static VkDeviceSize alignTo (VkDeviceSize value, VkDeviceSize alignment)
 Aligne a value to a given alignment.
 
static float random (bool reset=false)
 Return a random value from the interval [0.0, 1.0)
 

Detailed Description

Class with Vulkan helper functions. This class provides static functions that can be called directly without creating an object.

Member Function Documentation

◆ alignTo()

static VkDeviceSize Mandrill::Helpers::alignTo ( VkDeviceSize  value,
VkDeviceSize  alignment 
)
inlinestatic

Aligne a value to a given alignment.

Parameters
valueValue to align
alignmentAlignment to use
Returns
Aligned value

◆ cmdBegin()

static VkCommandBuffer Mandrill::Helpers::cmdBegin ( ptr< Device pDevice)
inlinestatic

Create a new one-time use command buffer. This call should be paired with a corresponding call to cmdEnd().

Parameters
pDeviceDevice to use
Returns
Command buffer

◆ cmdEnd()

static void Mandrill::Helpers::cmdEnd ( ptr< Device pDevice,
VkCommandBuffer  cmd,
const std::vector< VkSemaphore > &  waitSemaphores = {},
const std::vector< VkPipelineStageFlags > &  waitStages = {},
const std::vector< VkSemaphore > &  signalSemaphores = {} 
)
inlinestatic

End a one-time use command buffer that was initialized with a call to cmdBegin().

Parameters
pDeviceDevice to use
cmdCommand buffer to end

◆ copyBufferToImage()

static void Mandrill::Helpers::copyBufferToImage ( VkCommandBuffer  cmd,
VkBuffer  buffer,
VkImage  image,
uint32_t  width,
uint32_t  height,
uint32_t  depth 
)
inlinestatic

Copy a buffer to an image.

Parameters
cmdCommand buffer to use
bufferBuffer to use
imageImage to use
widthWidth of image
heightHeight of image
depthDepth of image

◆ copyImageToBuffer()

static void Mandrill::Helpers::copyImageToBuffer ( VkCommandBuffer  cmd,
VkImage  image,
VkBuffer  buffer,
uint32_t  width,
uint32_t  height,
uint32_t  depth 
)
inlinestatic

Copy an image to a buffer.

Parameters
cmdCommand buffer to use
imageImage to use
bufferBuffer to use
widthWidth of image
heightHeight of image
depthDepth of image

◆ findDepthFormat()

static VkFormat Mandrill::Helpers::findDepthFormat ( ptr< Device pDevice)
inlinestatic

Find a supported depth format for a depth attachment.

Parameters
pDeviceDevice to use
Returns
A supported depth format or VK_FORMAT_UNDEFINED

◆ findMemoryType()

static uint32_t Mandrill::Helpers::findMemoryType ( ptr< Device pDevice,
uint32_t  typeFilter,
VkMemoryPropertyFlags  properties 
)
inlinestatic

Find a suitable memory type given the memory properties.

Parameters
pDeviceDevice to use
typeFilterType filter from memory requirements
propertiesRequested memory properties
Returns
Memory type

◆ findSupportedFormat()

static VkFormat Mandrill::Helpers::findSupportedFormat ( ptr< Device pDevice,
std::vector< VkFormat >  candidates,
VkImageTiling  tiling,
VkFormatFeatureFlags  features 
)
inlinestatic

Find supported format for an attachment.

Parameters
pDeviceDevice to use
candidatesFormats that we want to use
tilingTiling to use
featuresFeatures to use
Returns
A supported format or VK_FORMAT_UNDEFINED

◆ imageBarrier()

static void Mandrill::Helpers::imageBarrier ( VkCommandBuffer  cmd,
VkImage  image,
VkPipelineStageFlags2  srcStage,
VkAccessFlags2  srcAccess,
VkPipelineStageFlags2  dstStage,
VkAccessFlags2  dstAccess,
VkImageLayout  oldLayout,
VkImageLayout  newLayout,
VkImageSubresourceRange *  pSubresourceRange = nullptr 
)
inlinestatic

Create an image barrier with layout transition.

Parameters
cmdCommand buffer to use
imageImage to transition
srcStageStage the barrier has to wait for
srcAccessType of access the barrier has to wait for
dstStageStage when the barrier has to be finished
dstAccessType of access the barrer must be ready for when finished
oldLayoutOld image layout
newLayoutNew image layout
pSubresourceRangeSubresource range to use, or nullptr

◆ random()

static float Mandrill::Helpers::random ( bool  reset = false)
inlinestatic

Return a random value from the interval [0.0, 1.0)

Parameters
resetIf true, the random seed is reset
Returns
A random value

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