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

Describes a the layout of a single descriptor within a DescriptorSet. More...

#include <rendering_api.hpp>

Inherits LiteFX::Rendering::IBufferLayout.

Inherited by LiteFX::Rendering::Backends::DirectX12DescriptorLayout, and LiteFX::Rendering::Backends::VulkanDescriptorLayout.

Public Member Functions

virtual ~IDescriptorLayout () noexcept=default
 
virtual const DescriptorType & descriptorType () const noexcept=0
 Returns the type of the descriptor. More...
 
virtual const UInt32descriptors () const noexcept=0
 Returns the number of descriptors in the descriptor array, or -1 if the array is unbounded. More...
 
virtual const ISamplerstaticSampler () const noexcept=0
 If the descriptor describes a static sampler, this method returns the state of the sampler. Otherwise, it returns nullptr. More...
 
- Public Member Functions inherited from LiteFX::Rendering::IBufferLayout
virtual ~IBufferLayout () noexcept=default
 
virtual size_t elementSize () const noexcept=0
 Returns the size of a single element within the buffer. More...
 
virtual const UInt32binding () const noexcept=0
 Returns the binding point, the buffer will be bound to. More...
 
virtual const BufferType & type () const noexcept=0
 Returns the buffer type of the buffer. More...
 

Detailed Description

Describes a the layout of a single descriptor within a DescriptorSet.

A common metaphor for a descriptor to think of it as a "pointer for the GPU". Basically, a descriptor points to a buffer in a shader. A descriptor can have different types and sizes. The types a descriptor can have are described by the DescriptorType.

If the descriptor is a sampler, it can either be a dynamic or static sampler. A dynamic sampler needs to be bound during runtime just like any other descriptor by calling IDescriptorSet::update. A static sampler is defined alongside the descriptor layout and is automatically set when the pipeline that uses the descriptor layout gets bound. In this case, the descriptor must not be updated with another sampler. If a descriptor layout describes a static sampler, the IDescriptorLayout::staticSampler returns a pointer to the static sampler state.

Typically, a descriptor "points" to a singular buffer, i.e. a scalar. However, a descriptor can also resemble an array. In this case, IDescriptorLayout::descriptors returns the number of elements in the array. If it returns -1 (or 0xFFFFFFFF), the descriptor array is called unbounded. In this case, the number of descriptors in the array can be specified when allocating the descriptor set. Unbounded descriptor arrays behave different to normal descriptor arrays in different ways. They are typically used for bindless descriptors. If a descriptor represents an unbounded array, it must be the only descriptor in this descriptor set. Furthermore, unbounded arrays are not cached by the descriptor set layout. Descriptors within unbounded arrays may be updated after binding them to a command buffer. However, this must be done with special care, to prevent descriptors that are in use to be overwritten. For more information on how to manage unbounded arrays, refer to IDescriptorSetLayout::allocate.

See also
DescriptorSetLayout

Constructor & Destructor Documentation

◆ ~IDescriptorLayout()

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

Member Function Documentation

◆ descriptors()

virtual const UInt32 & LiteFX::Rendering::IDescriptorLayout::descriptors ( ) const
pure virtualnoexcept

Returns the number of descriptors in the descriptor array, or -1 if the array is unbounded.

If the number of descriptors is -1 (or 0xFFFFFFFF), the descriptor array is unbounded. In that case, the size of the array must be specified, when allocating the descriptor set. This can be done by specifying the descriptors parameter when calling IDescriptorSetLayout::allocate.

Returns
The number of descriptors in the descriptor array, or -1 if the array is unbounded.
See also
IDescriptorLayout

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorLayout, and LiteFX::Rendering::Backends::VulkanDescriptorLayout.

◆ descriptorType()

virtual const DescriptorType & LiteFX::Rendering::IDescriptorLayout::descriptorType ( ) const
pure virtualnoexcept

Returns the type of the descriptor.

Returns
The type of the descriptor.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorLayout, and LiteFX::Rendering::Backends::VulkanDescriptorLayout.

◆ staticSampler()

virtual const ISampler * LiteFX::Rendering::IDescriptorLayout::staticSampler ( ) const
pure virtualnoexcept

If the descriptor describes a static sampler, this method returns the state of the sampler. Otherwise, it returns nullptr.

Static samplers are called immutable samplers in Vulkan and describe sampler states, that are defined along the pipeline layout. While they do occupy a descriptor, they must not be bound explicitly. Instead, static samplers are automatically bound if the pipeline gets used. If a static sampler is set, the descriptorType must be set to DescriptorType::Sampler.

Returns
The state of the static sampler, or nullptr, if the descriptor is not a static sampler.

Implemented in LiteFX::Rendering::Backends::DirectX12DescriptorLayout, and LiteFX::Rendering::Backends::VulkanDescriptorLayout.