luna engine
software engine
Loading...
Searching...
No Matches
luna::utils::vulkanAllocator Class Reference

#include <vulkanAllocator.h>

Collaboration diagram for luna::utils::vulkanAllocator:

Classes

struct  transferCommand
 
struct  vmaAllocation
 

Static Public Member Functions

static void init (ref< renderer::device > device)
 allocator constructor. More...
 
static void shutdown ()
 destroys the allocator. More...
 
static VmaAllocationInfo getAllocationInfo (const uint64_t &handle)
 returns the allocation info from the given handle. More...
 
static VkResult createImage (VkImage *pImage, const VkImageUsageFlags &usageFlags, const VmaMemoryUsage &memoryUsage, const VkExtent3D &extent, const VkFormat &format)
 creates a VkImage object. More...
 
static VkResult destroyImage (const VkImage &image)
 destroys the VkImage object. More...
 
static VkResult createImageView (VkImageView *pImageView, const VkImage &image, const VkFormat &format, const VkImageAspectFlags &imageAspectFlags)
 creates a VkImageView object. More...
 
static VkResult destroyImageView (const VkImageView &imageView)
 destroys the VkImageView. More...
 
static VkResult createBuffer (VkBuffer *pBuffer, const size_t &allocSize, const VkBufferUsageFlags &usage, const VmaMemoryUsage &memoryUsage, const VmaAllocationCreateFlags &allocFlags=0)
 creates a VkBuffer object. More...
 
static void destroyBuffer (VkBuffer &buffer)
 destroys the VkBuffer object. More...
 
static void uploadTexture (VkBuffer &buffer, const VkImage &image, const VkFormat &imageFormat, const glm::vec3 &imageDimensions, const glm::vec3 &imageOffset={0, 0, 0}, const glm::vec2 &subImageDimensions={0, 0}, const uint64_t bufferOffset=0)
 uploads a texture to the gpu . More...
 
static void flush ()
 executes all recorded transferCommands. More...
 
static VkFormat getSuitableFormat (const VkImageUsageFlags &usageFlags, const uint32_t &channels)
 returns a supported VK_FORMAT given a channel amount from 1-4, if no supported format can be found VK_FORMAT_UNDEFINED will be returned More...
 

Static Private Member Functions

static void transitionImageLayout (const VkImage &image, const VkFormat &format, const VkImageLayout &oldLayout, const VkImageLayout &newLayout, const vulkan::virtualCmdBuffer &commandBufffer)
 transitions the image layout. More...
 

Static Private Attributes

static ref< renderer::devicepDevice
 
static VmaAllocator sAllocator
 
static objectStorage< vmaAllocationallocations
 
static std::vector< transferCommandtransferCommands
 
static ref< vulkan::vulkanCmdPoolcommandPool = nullptr
 
static VkQueue transferQueue
 

Member Function Documentation

◆ createBuffer()

VkResult luna::utils::vulkanAllocator::createBuffer ( VkBuffer *  pBuffer,
const size_t &  allocSize,
const VkBufferUsageFlags &  usage,
const VmaMemoryUsage &  memoryUsage,
const VmaAllocationCreateFlags &  allocFlags = 0 
)
static

creates a VkBuffer object.

Parameters
pBufferpointer to the buffer handle
allocSize
usage
memoryUsage
Returns

◆ createImage()

VkResult luna::utils::vulkanAllocator::createImage ( VkImage *  pImage,
const VkImageUsageFlags &  usageFlags,
const VmaMemoryUsage &  memoryUsage,
const VkExtent3D &  extent,
const VkFormat &  format 
)
static

creates a VkImage object.

Parameters
pImagepointer to the image handle
usageFlags
memoryUsageVMA_MEMORY_USAGE
extentimage extend
formatVkImageFormat
Returns

◆ createImageView()

VkResult luna::utils::vulkanAllocator::createImageView ( VkImageView *  pImageView,
const VkImage &  image,
const VkFormat &  format,
const VkImageAspectFlags &  imageAspectFlags 
)
static

creates a VkImageView object.

Parameters
pImageViewpointer to imageView handle
imageVkImage handle
format
imageAspectFlags
Returns

◆ destroyBuffer()

void luna::utils::vulkanAllocator::destroyBuffer ( VkBuffer &  buffer)
static

destroys the VkBuffer object.

Parameters
buffer

◆ destroyImage()

VkResult luna::utils::vulkanAllocator::destroyImage ( const VkImage &  image)
static

destroys the VkImage object.

Parameters
image
Returns

◆ destroyImageView()

VkResult luna::utils::vulkanAllocator::destroyImageView ( const VkImageView &  imageView)
static

destroys the VkImageView.

Parameters
imageView
Returns

◆ flush()

void luna::utils::vulkanAllocator::flush ( )
static

executes all recorded transferCommands.

◆ getAllocationInfo()

VmaAllocationInfo luna::utils::vulkanAllocator::getAllocationInfo ( const uint64_t &  handle)
static

returns the allocation info from the given handle.

Parameters
handle
Returns
VmaAllocationInfo

◆ getSuitableFormat()

VkFormat luna::utils::vulkanAllocator::getSuitableFormat ( const VkImageUsageFlags &  usageFlags,
const uint32_t &  channels 
)
static

returns a supported VK_FORMAT given a channel amount from 1-4, if no supported format can be found VK_FORMAT_UNDEFINED will be returned

Parameters
usageFlags
channels
Returns

◆ init()

void luna::utils::vulkanAllocator::init ( ref< renderer::device device)
static

allocator constructor.

Parameters
ref<renderer::device>device reference to the device

◆ shutdown()

void luna::utils::vulkanAllocator::shutdown ( )
static

destroys the allocator.

◆ transitionImageLayout()

void luna::utils::vulkanAllocator::transitionImageLayout ( const VkImage &  image,
const VkFormat &  format,
const VkImageLayout &  oldLayout,
const VkImageLayout &  newLayout,
const vulkan::virtualCmdBuffer commandBufffer 
)
staticprivate

transitions the image layout.

Parameters
VkImageimage imageHandle
VkFormatformat
VkImageLayoutoldLayout
VkImageLayoutnewLayout
VkCommandBuffercommandBufffer

◆ uploadTexture()

void luna::utils::vulkanAllocator::uploadTexture ( VkBuffer &  buffer,
const VkImage &  image,
const VkFormat &  imageFormat,
const glm::vec3 &  imageDimensions,
const glm::vec3 &  imageOffset = {0,0,0},
const glm::vec2 &  subImageDimensions = {0,0},
const uint64_t  bufferOffset = 0 
)
static

uploads a texture to the gpu .

Parameters
bufferdataBuffer that stores texelData
imagehandle to copy texelData in to.

Member Data Documentation

◆ allocations

objectStorage<vmaAllocation> luna::utils::vulkanAllocator::allocations
inlinestaticprivate

◆ commandPool

ref<vulkan::vulkanCmdPool> luna::utils::vulkanAllocator::commandPool = nullptr
inlinestaticprivate

◆ pDevice

ref<renderer::device> luna::utils::vulkanAllocator::pDevice
inlinestaticprivate

◆ sAllocator

VmaAllocator luna::utils::vulkanAllocator::sAllocator
inlinestaticprivate

◆ transferCommands

std::vector<transferCommand> luna::utils::vulkanAllocator::transferCommands
inlinestaticprivate

◆ transferQueue

VkQueue luna::utils::vulkanAllocator::transferQueue
inlinestaticprivate

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