LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::Backends::VulkanDescriptorSetLayout Class Reference

Implements a Vulkan DescriptorSetLayout. More...

#include <vulkan.hpp>

Inherits LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >, and LiteFX::Resource< VkDescriptorSetLayout >.

Classes

class  VulkanDescriptorSetLayoutImpl
 

Public Member Functions

 VulkanDescriptorSetLayout (const VulkanDevice &device, Array< UniquePtr< VulkanDescriptorLayout > > &&descriptorLayouts, const UInt32 &space, const ShaderStage &stages, const UInt32 &poolSize=1024, const UInt32 &maxUnboundedArraySize=104857)
 Initializes a Vulkan descriptor set layout. More...
 
 VulkanDescriptorSetLayout (VulkanDescriptorSetLayout &&)=delete
 
 VulkanDescriptorSetLayout (const VulkanDescriptorSetLayout &)=delete
 
virtual ~VulkanDescriptorSetLayout () noexcept
 
virtual const VulkanDevicedevice () const noexcept
 Returns the device, the pipeline layout has been created from. More...
 
virtual Array< const VulkanDescriptorLayout * > descriptors () const noexcept override
 
virtual const VulkanDescriptorLayoutdescriptor (const UInt32 &binding) const override
 Returns the descriptor layout for the descriptor bound to the binding point provided with binding . More...
 
virtual const UInt32space () const noexcept override
 Returns the space index of the descriptor set. More...
 
virtual const ShaderStage & shaderStages () const noexcept override
 Returns the shader stages, the descriptor set is used in. More...
 
virtual UInt32 uniforms () const noexcept override
 Returns the number of uniform/constant buffer descriptors within the descriptor set. More...
 
virtual UInt32 storages () const noexcept override
 Returns the number of structured and byte address buffer descriptors within the descriptor set. More...
 
virtual UInt32 images () const noexcept override
 Returns the number of image (i.e. texture) descriptors within the descriptor set. More...
 
virtual UInt32 buffers () const noexcept override
 Returns the number of texel buffer descriptors within the descriptor set. More...
 
virtual UInt32 samplers () const noexcept override
 Returns the number of dynamic sampler descriptors within the descriptor set. More...
 
virtual UInt32 staticSamplers () const noexcept override
 Returns the number of static or immutable sampler descriptors within the descriptor set. More...
 
virtual UInt32 inputAttachments () const noexcept override
 Returns the number of input attachment descriptors within the descriptor set. More...
 
virtual UniquePtr< VulkanDescriptorSetallocate (const UInt32 &descriptors=0) const override
 
virtual Array< UniquePtr< VulkanDescriptorSet > > allocateMultiple (const UInt32 &descriptorSets, const UInt32 &descriptors=0) const override
 
virtual void free (const VulkanDescriptorSet &descriptorSet) const noexcept override
 
virtual const UInt32poolSize () const noexcept
 The size of each descriptor pool. More...
 
virtual size_t pools () const noexcept
 Returns the number of active descriptor pools. More...
 
- Public Member Functions inherited from LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >
virtual ~DescriptorSetLayout () noexcept=default
 
virtual Array< const descriptor_layout_type * > descriptors () const noexcept=0
 
virtual const descriptor_layout_typedescriptor (const UInt32 &binding) const=0
 Returns the descriptor layout for the descriptor bound to the binding point provided with binding . More...
 
virtual UniquePtr< descriptor_set_typeallocate (const UInt32 &descriptors=0) const=0
 
virtual Array< UniquePtr< descriptor_set_type > > allocateMultiple (const UInt32 &descriptorSets, const UInt32 &descriptors=0) const=0
 
virtual void free (const descriptor_set_type &descriptorSet) const noexcept=0
 
- Public Member Functions inherited from LiteFX::Rendering::IDescriptorSetLayout
virtual ~IDescriptorSetLayout () noexcept=default
 
Array< const IDescriptorLayout * > descriptors () const noexcept
 Returns the layouts of the descriptors within the descriptor set. More...
 
virtual const IDescriptorLayoutdescriptor (const UInt32 &binding) const =0
 Returns the descriptor layout for the descriptor bound to the binding point provided with binding . More...
 
virtual const UInt32space () const noexcept=0
 Returns the space index of the descriptor set. More...
 
virtual const ShaderStage & shaderStages () const noexcept=0
 Returns the shader stages, the descriptor set is used in. More...
 
virtual UInt32 uniforms () const noexcept=0
 Returns the number of uniform/constant buffer descriptors within the descriptor set. More...
 
virtual UInt32 storages () const noexcept=0
 Returns the number of structured and byte address buffer descriptors within the descriptor set. More...
 
virtual UInt32 images () const noexcept=0
 Returns the number of image (i.e. texture) descriptors within the descriptor set. More...
 
virtual UInt32 buffers () const noexcept=0
 Returns the number of texel buffer descriptors within the descriptor set. More...
 
virtual UInt32 samplers () const noexcept=0
 Returns the number of dynamic sampler descriptors within the descriptor set. More...
 
virtual UInt32 staticSamplers () const noexcept=0
 Returns the number of static or immutable sampler descriptors within the descriptor set. More...
 
virtual UInt32 inputAttachments () const noexcept=0
 Returns the number of input attachment descriptors within the descriptor set. More...
 
UniquePtr< IDescriptorSetallocate (const UInt32 &descriptors=0) const
 Allocates a new descriptor set or returns an instance of an unused descriptor set. More...
 
Array< UniquePtr< IDescriptorSet > > allocateMultiple (const UInt32 &descriptorSets, const UInt32 &descriptors=0) const
 Allocates an array of descriptor sets. More...
 
void free (const IDescriptorSet &descriptorSet) const noexcept
 Marks a descriptor set as unused, so that it can be handed out again instead of allocating a new one. More...
 
- Public Member Functions inherited from LiteFX::Resource< VkDescriptorSetLayout >
 Resource (const Resource &)=delete
 
 Resource (Resource &&)=delete
 
virtual ~Resource () noexcept=default
 
const VkDescriptorSetLayout & handle () const noexcept override
 Returns the resource managed by the class. More...
 
- Public Member Functions inherited from LiteFX::IResource< VkDescriptorSetLayout >
virtual ~IResource () noexcept=default
 
virtual const VkDescriptorSetLayout & handle () const noexcept=0
 Returns the resource managed by the class. More...
 

Additional Inherited Members

- Public Types inherited from LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >
using descriptor_layout_type = VulkanDescriptorLayout
 
using descriptor_set_type = VulkanDescriptorSet
 
- Protected Member Functions inherited from LiteFX::Resource< VkDescriptorSetLayout >
 Resource (const VkDescriptorSetLayout handle) noexcept
 Initializes the managed resource. More...
 
VkDescriptorSetLayout & handle () noexcept override
 Returns the resource managed by the class. More...
 
virtual VkDescriptorSetLayout & handle () noexcept=0
 Returns the resource managed by the class. More...
 

Detailed Description

Implements a Vulkan DescriptorSetLayout.

See also
VulkanDescriptorSet, VulkanDescriptorSetLayoutBuilder

Constructor & Destructor Documentation

◆ VulkanDescriptorSetLayout() [1/3]

VulkanDescriptorSetLayout::VulkanDescriptorSetLayout ( const VulkanDevice device,
Array< UniquePtr< VulkanDescriptorLayout > > &&  descriptorLayouts,
const UInt32 space,
const ShaderStage &  stages,
const UInt32 poolSize = 1024,
const UInt32 maxUnboundedArraySize = 104857 
)
explicit

Initializes a Vulkan descriptor set layout.

If the descriptor set contains an unbounded array, it still is not truly unbounded. Instead, only maximum number of descriptors can be allocated from the descriptor set. This number is defined by the device limits and depends on the descriptor type. If you need more descriptors in one array, increase the maxUnboundedArraySize parameter. Keep in mind that you may be only able to use less or smaller unbounded descriptor arrays in other descriptor sets as a result.

Parameters
deviceThe parent device, the pipeline layout has been created from.
descriptorLayoutsThe descriptor layouts of the descriptors within the descriptor set.
spaceThe space or set id of the descriptor set.
stagesThe shader stages, the descriptor sets are bound to.
poolSizeThe size of a descriptor pool.
maxUnboundedArraySizeThe maximum number of descriptors in an unbounded array.

◆ VulkanDescriptorSetLayout() [2/3]

LiteFX::Rendering::Backends::VulkanDescriptorSetLayout::VulkanDescriptorSetLayout ( VulkanDescriptorSetLayout &&  )
delete

◆ VulkanDescriptorSetLayout() [3/3]

LiteFX::Rendering::Backends::VulkanDescriptorSetLayout::VulkanDescriptorSetLayout ( const VulkanDescriptorSetLayout )
delete

◆ ~VulkanDescriptorSetLayout()

VulkanDescriptorSetLayout::~VulkanDescriptorSetLayout ( )
virtualnoexcept

Member Function Documentation

◆ allocate()

UniquePtr< VulkanDescriptorSet > VulkanDescriptorSetLayout::allocate ( const UInt32 descriptors = 0) const
overridevirtual

◆ allocateMultiple()

Array< UniquePtr< VulkanDescriptorSet > > VulkanDescriptorSetLayout::allocateMultiple ( const UInt32 descriptorSets,
const UInt32 descriptors = 0 
) const
overridevirtual

◆ buffers()

UInt32 VulkanDescriptorSetLayout::buffers ( ) const
overridevirtualnoexcept

Returns the number of texel buffer descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ descriptor()

const VulkanDescriptorLayout & VulkanDescriptorSetLayout::descriptor ( const UInt32 binding) const
overridevirtual

Returns the descriptor layout for the descriptor bound to the binding point provided with binding .

Implements LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >.

◆ descriptors()

Array< const VulkanDescriptorLayout * > VulkanDescriptorSetLayout::descriptors ( ) const
overridevirtualnoexcept

◆ device()

const VulkanDevice & VulkanDescriptorSetLayout::device ( ) const
virtualnoexcept

Returns the device, the pipeline layout has been created from.

Returns
A reference of the device, the pipeline layout has been created from.

◆ free()

void VulkanDescriptorSetLayout::free ( const VulkanDescriptorSet descriptorSet) const
overridevirtualnoexcept

◆ images()

UInt32 VulkanDescriptorSetLayout::images ( ) const
overridevirtualnoexcept

Returns the number of image (i.e. texture) descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ inputAttachments()

UInt32 VulkanDescriptorSetLayout::inputAttachments ( ) const
overridevirtualnoexcept

Returns the number of input attachment descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ pools()

size_t VulkanDescriptorSetLayout::pools ( ) const
virtualnoexcept

Returns the number of active descriptor pools.

Returns
The number of active descriptor pools.
See also
allocate, free, poolSize

◆ poolSize()

const UInt32 & VulkanDescriptorSetLayout::poolSize ( ) const
virtualnoexcept

The size of each descriptor pool.

Descriptors are allocated from descriptor pools in Vulkan. Each descriptor pool has a number of descriptor sets it can hand out. Before allocating a new descriptor set the layout tries to find an unused descriptor set, that it can hand out. If there are no free descriptor sets, the layout tries to allocate a new one. This is only possible if the descriptor pool is not yet full, in which case a new pool needs to be created. All created pools are cached and destroyed, if the layout itself gets destroyed, causing all descriptor sets allocated from the layout to be invalidated.

In general, if the number of required descriptor sets can be pre-calculated, it should be used as a pool size. Otherwise there is a trade-off to be made, based on the frequency of which new descriptor sets are required. A small pool size is more memory efficient, but can have a significant runtime cost, as long as new allocations happen and no descriptor sets can be reused. A large pool size on the other hand is faster, whilst it may leave a large chunk of descriptor sets unallocated. Keep in mind, that the layout might not be the only active layout, hence a large portion of descriptor sets might end up not being used.

Returns
The size of one descriptor pool.
See also
allocate, free, pools

◆ samplers()

UInt32 VulkanDescriptorSetLayout::samplers ( ) const
overridevirtualnoexcept

Returns the number of dynamic sampler descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ shaderStages()

const ShaderStage & VulkanDescriptorSetLayout::shaderStages ( ) const
overridevirtualnoexcept

Returns the shader stages, the descriptor set is used in.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ space()

const UInt32 & VulkanDescriptorSetLayout::space ( ) const
overridevirtualnoexcept

Returns the space index of the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ staticSamplers()

UInt32 VulkanDescriptorSetLayout::staticSamplers ( ) const
overridevirtualnoexcept

Returns the number of static or immutable sampler descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ storages()

UInt32 VulkanDescriptorSetLayout::storages ( ) const
overridevirtualnoexcept

Returns the number of structured and byte address buffer descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.

◆ uniforms()

UInt32 VulkanDescriptorSetLayout::uniforms ( ) const
overridevirtualnoexcept

Returns the number of uniform/constant buffer descriptors within the descriptor set.

Implements LiteFX::Rendering::IDescriptorSetLayout.