LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::IDescriptorSetLayout Class Referenceabstract

The interface for a descriptor set layout. More...

#include <rendering_api.hpp>

Inherited by LiteFX::Rendering::DescriptorSetLayout< DirectX12DescriptorLayout, DirectX12DescriptorSet >, LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >, and LiteFX::Rendering::DescriptorSetLayout< TDescriptorLayout, TDescriptorSet >.

Public Member Functions

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...
 

Detailed Description

The interface for a descriptor set layout.

Constructor & Destructor Documentation

◆ ~IDescriptorSetLayout()

virtual LiteFX::Rendering::IDescriptorSetLayout::~IDescriptorSetLayout ( )
virtualdefaultnoexcept

Member Function Documentation

◆ allocate()

UniquePtr< IDescriptorSet > LiteFX::Rendering::IDescriptorSetLayout::allocate ( const UInt32 descriptors = 0) const
inline

Allocates a new descriptor set or returns an instance of an unused descriptor set.

Parameters
descriptorsThe number of descriptors to allocate in an unbounded descriptor array. Ignored, if the descriptor set does not contain an unbounded array.

Allocating a new descriptor set may be an expensive operation. To improve performance, and prevent fragmentation, the descriptor set layout keeps track of created descriptor sets. It does this by never releasing them. Instead, when a DescriptorSet instance gets destroyed, it should call free in order to mark itself (i.e. its handle) as not being used any longer.

Before allocating a new descriptor set from a pool (which may even result in the creation of a new pool, if the existing pools are full), the layout tries to hand out descriptor sets that marked as unused. Descriptor sets are only deleted, if the whole layout instance and therefore the descriptor pools are deleted.

The above does not apply to unbounded descriptor arrays. A unbounded descriptor array is one, for which IDescriptorLayout::descriptors returns -1 (or 0xFFFFFFFF). They must be allocated by specifying the descriptors parameter. This parameter defines the number of descriptors to allocate in the array.

Note that descriptor sets, that contain an unbounded descriptor array must only contain one single descriptor (the one that identifies this array). Such descriptor sets are never cached. Instead, they are released when calling free. It is a good practice to cache such descriptor sets as global descriptor tables once and never release them. They provide more flexibility than regular descriptor arrays, since they may be updated, even after they have been bound to a command buffer or from different threads. However, you must ensure yourself not to overwrite any descriptors that are currently in use. Because unbounded arrays are not cached, freeing and re-allocating such descriptor sets may leave the descriptor heap fragmented, which might cause the allocation to fail, if the heap is full.

Returns
The instance of the descriptor set.
See also
IDescriptorLayout

◆ allocateMultiple()

Array< UniquePtr< IDescriptorSet > > LiteFX::Rendering::IDescriptorSetLayout::allocateMultiple ( const UInt32 descriptorSets,
const UInt32 descriptors = 0 
) const
inline

Allocates an array of descriptor sets.

Parameters
descriptorSetsThe number of descriptor sets to allocate.
descriptorsThe number of descriptors to allocate in an unbounded descriptor array. Ignored, if the descriptor set does not contain an unbounded array.
Returns
The array of descriptor set instances.
See also
allocate

◆ buffers()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::buffers ( ) const
pure virtualnoexcept

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

Returns
The number of texel buffer descriptors.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ descriptor()

virtual const IDescriptorLayout & LiteFX::Rendering::IDescriptorSetLayout::descriptor ( const UInt32 binding) const
pure virtual

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

Parameters
bindingThe binding point of the requested descriptor layout.
Returns
The descriptor layout for the descriptor bound to the binding point provided with binding .

Implemented in LiteFX::Rendering::DescriptorSetLayout< TDescriptorLayout, TDescriptorSet >, LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, LiteFX::Rendering::Backends::VulkanDescriptorSetLayout, LiteFX::Rendering::DescriptorSetLayout< DirectX12DescriptorLayout, DirectX12DescriptorSet >, and LiteFX::Rendering::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet >.

◆ descriptors()

Array< const IDescriptorLayout * > LiteFX::Rendering::IDescriptorSetLayout::descriptors ( ) const
inlinenoexcept

Returns the layouts of the descriptors within the descriptor set.

Returns
The layouts of the descriptors within the descriptor set.

◆ free()

void LiteFX::Rendering::IDescriptorSetLayout::free ( const IDescriptorSet descriptorSet) const
inlinenoexcept

Marks a descriptor set as unused, so that it can be handed out again instead of allocating a new one.

See also
allocate

◆ images()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::images ( ) const
pure virtualnoexcept

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

Returns
The number of image (i.e. texture) descriptors.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ inputAttachments()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::inputAttachments ( ) const
pure virtualnoexcept

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

Returns
The number of input attachment descriptors.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ samplers()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::samplers ( ) const
pure virtualnoexcept

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

Returns
The number of dynamic sampler descriptors.
See also
staticSamplers

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ shaderStages()

virtual const ShaderStage & LiteFX::Rendering::IDescriptorSetLayout::shaderStages ( ) const
pure virtualnoexcept

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

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

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ space()

virtual const UInt32 & LiteFX::Rendering::IDescriptorSetLayout::space ( ) const
pure virtualnoexcept

Returns the space index of the descriptor set.

The descriptor set space maps to the space index in HLSL and the set index in GLSL.

Returns
The space index of the descriptor set.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ staticSamplers()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::staticSamplers ( ) const
pure virtualnoexcept

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

Returns
The number of static or immutable sampler descriptors.
See also
samplers

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ storages()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::storages ( ) const
pure virtualnoexcept

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

Returns
The number of structured and byte address buffer descriptors.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.

◆ uniforms()

virtual UInt32 LiteFX::Rendering::IDescriptorSetLayout::uniforms ( ) const
pure virtualnoexcept

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

Returns
The number of uniform/constant buffer descriptors.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorSetLayout, and LiteFX::Rendering::Backends::VulkanDescriptorSetLayout.