FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
Loading...
Searching...
No Matches
fge::vulkan::DescriptorPool Class Reference

This class abstract the vulkan descriptor pool for easier use. More...

#include <C_descriptorPool.hpp>

Inheritance diagram for fge::vulkan::DescriptorPool:
fge::vulkan::ContextAware

Public Member Functions

 DescriptorPool (Context const &context)
 
 DescriptorPool (DescriptorPool const &r)=delete
 
 DescriptorPool (DescriptorPool &&r) noexcept
 
DescriptorPooloperator= (DescriptorPool const &r)=delete
 
DescriptorPooloperator= (DescriptorPool &&r) noexcept=delete
 
void create (std::vector< VkDescriptorPoolSize > &&descriptorPoolSizes, uint32_t maxSetsPerPool, bool isUnique, bool individuallyFree)
 Create the descriptor pool.
 
void destroy () final
 
std::optional< DescriptorSetallocateDescriptorSet (VkDescriptorSetLayout layout, uint32_t variableElements=0) const
 Allocate a descriptor set.
 
void freeDescriptorSet (VkDescriptorSet descriptorSet, VkDescriptorPool descriptorPool) const
 Free a descriptor set.
 
void resetPools () const
 Reset all the pools.
 
uint32_t getMaxSetsPerPool () const
 
bool isUnique () const
 
bool isCreated () const
 
constexpr Context const & getContext () const
 
void swapContext (Context const &context)
 

Protected Member Functions

void verifyContext (ContextAware const &r) const
 

Detailed Description

This class abstract the vulkan descriptor pool for easier use.

In vulkan, a descriptor pool must be created with a fixed size without a way to resize it. This class help by allocating any number of descriptor sets by creating multiple pools if needed.

Member Function Documentation

◆ allocateDescriptorSet()

std::optional< DescriptorSet > fge::vulkan::DescriptorPool::allocateDescriptorSet ( VkDescriptorSetLayout layout,
uint32_t variableElements = 0 ) const
nodiscard

Allocate a descriptor set.

Warning
If variableElements is not 0, the descriptor set layout must have been created with the VK_DESCRIPTOR_SET_LAYOUT_CREATE_VARIABLE_DESCRIPTOR_COUNT_BIT_EXT flag in this last binding.
Parameters
layoutThe descriptor set layout
variableElementsThe number of variable elements in the descriptor set
Returns
The descriptor set or std::nullopt if the allocation failed

◆ create()

void fge::vulkan::DescriptorPool::create ( std::vector< VkDescriptorPoolSize > && descriptorPoolSizes,
uint32_t maxSetsPerPool,
bool isUnique,
bool individuallyFree )

Create the descriptor pool.

When the number of descriptor sets allocated reach the maxSetsPerPool, a new pool is created.

Parameters
descriptorPoolSizesA vector of VkDescriptorPoolSize
maxSetsPerPoolThe max number of descriptor sets per pool
isUniqueIf true, only one pool is created and will fail if the maxSetsPerPool is reached
individuallyFreeIf true, the descriptor sets are individually freed

◆ destroy()

void fge::vulkan::DescriptorPool::destroy ( )
finalvirtual

◆ freeDescriptorSet()

void fge::vulkan::DescriptorPool::freeDescriptorSet ( VkDescriptorSet descriptorSet,
VkDescriptorPool descriptorPool ) const

Free a descriptor set.

This function should not be directly called, DescriptorSet::destroy() should be used instead.

Parameters
descriptorSetThe descriptor set
descriptorPoolThe descriptor pool that the descriptor set was allocated from

◆ resetPools()

void fge::vulkan::DescriptorPool::resetPools ( ) const

Reset all the pools.

This function call vkResetDescriptorPool on all the pools.


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