SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::render::IDescriptorSetLayout Class Referenceabstract

Interface for a descriptor set layout. More...

#include <DescriptorSet.h>

Inheritance diagram for spark::render::IDescriptorSetLayout:
spark::render::DescriptorSetLayout< VulkanDescriptorLayout, VulkanDescriptorSet > spark::render::DescriptorSetLayout< DescriptorLayoutType, DescriptorSetType > spark::render::vk::VulkanDescriptorSetLayout

Public Member Functions

std::vector< const IDescriptorLayout * > descriptors () const noexcept
 Gets the layouts of all descriptors in the IDescriptorSet.
 
virtual const IDescriptorLayoutdescriptor (unsigned int binding) const =0
 Gets the layout of a descriptor in the IDescriptorSet bound to a specific binding point.
 
virtual unsigned int space () const noexcept=0
 Gets the space index of the IDescriptorSet.
 
virtual ShaderStage shaderStage () const noexcept=0
 Gets the shader stage the IDescriptorSet is used in.
 
virtual unsigned int uniforms () const noexcept=0
 Gets the number of uniform/constant buffers in the IDescriptorSet.
 
virtual unsigned int storages () const noexcept=0
 Gets the number of storage buffers in the IDescriptorSet.
 
virtual unsigned int images () const noexcept=0
 Gets the number of images (textures) in the IDescriptorSet.
 
virtual unsigned int buffers () const noexcept=0
 Get the number of texel buffer descriptors in the IDescriptorSet.
 
virtual unsigned int samplers () const noexcept=0
 Gets the number of texel buffer descriptors in the IDescriptorSet.
 
virtual unsigned int staticSamplers () const noexcept=0
 Gets the number of static/immutable samplers in the IDescriptorSet.
 
virtual unsigned int inputAttachments () const noexcept=0
 Gets the number of input attachments in the IDescriptorSet.
 
std::unique_ptr< IDescriptorSetallocate (const std::vector< DescriptorBinding > &bindings={}) const
 Allocates a new IDescriptorSet or returns an unused descriptor set.
 
std::unique_ptr< IDescriptorSetallocate (unsigned int descriptors, const std::vector< DescriptorBinding > &bindings={}) const
 Allocates a new IDescriptorSet or returns an unused descriptor set.
 
std::vector< std::unique_ptr< IDescriptorSet > > allocateMultiple (unsigned int descriptors_sets, const std::vector< std::vector< DescriptorBinding > > &bindings={}) const noexcept
 Allocates an array of IDescriptorSet.
 
std::vector< std::unique_ptr< IDescriptorSet > > allocateMultiple (unsigned int descriptors_sets, const std::function< std::vector< DescriptorBinding >(unsigned)> &binding_factory) const noexcept
 Allocates an array of IDescriptorSet.
 
std::vector< std::unique_ptr< IDescriptorSet > > allocateMultiple (unsigned int descriptors_sets, unsigned int descriptors, const std::vector< std::vector< DescriptorBinding > > &bindings={}) const noexcept
 Allocates an array of IDescriptorSet.
 
std::vector< std::unique_ptr< IDescriptorSet > > allocateMultiple (unsigned int descriptors_sets, unsigned int descriptors, const std::function< std::vector< DescriptorBinding >(unsigned)> &binding_factory={}) const noexcept
 Allocates an array of IDescriptorSet.
 
void free (const IDescriptorSet &descriptor_set) const noexcept
 Marks a IDescriptorSet as unused, so that it can be handed out again instead of allocating a new one.
 

Detailed Description

Interface for a descriptor set layout.

Member Function Documentation

◆ allocate() [1/2]

std::unique_ptr< IDescriptorSet > spark::render::IDescriptorSetLayout::allocate ( const std::vector< DescriptorBinding > & bindings = {}) const
inlinenodiscard

Allocates a new IDescriptorSet or returns an unused descriptor set.

Parameters
bindingsOptional list of descriptor bindings to initialize the IDescriptorSet with.
Returns
A std::unique_ptr to the allocated IDescriptorSet.

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 IDescriptorSet instance gets destroyed, it should call IDescriptorSetLayout::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 IDescriptorSetLayout::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.

◆ allocate() [2/2]

std::unique_ptr< IDescriptorSet > spark::render::IDescriptorSetLayout::allocate ( unsigned int descriptors,
const std::vector< DescriptorBinding > & bindings = {} ) const
inlinenodiscard

Allocates a new IDescriptorSet or returns an unused descriptor set.

Parameters
descriptorsThe number of descriptors to allocate in an unbounded descriptor array. Ignored if the descriptor array is bounded.
bindingsOptional list of descriptor bindings to initialize the IDescriptorSet with.
Returns
A std::unique_ptr to the allocated IDescriptorSet.

◆ allocateMultiple() [1/4]

std::vector< std::unique_ptr< IDescriptorSet > > spark::render::IDescriptorSetLayout::allocateMultiple ( unsigned int descriptors_sets,
const std::function< std::vector< DescriptorBinding >(unsigned)> & binding_factory ) const
inlinenodiscardnoexcept

Allocates an array of IDescriptorSet.

Parameters
descriptors_setsThe number of IDescriptorSet to allocate.
binding_factoryA factory function that creates a list of descriptor bindings for each IDescriptorSet.
Returns
A std::vector containing std::unique_ptr to the newly allocated descriptor sets .

◆ allocateMultiple() [2/4]

std::vector< std::unique_ptr< IDescriptorSet > > spark::render::IDescriptorSetLayout::allocateMultiple ( unsigned int descriptors_sets,
const std::vector< std::vector< DescriptorBinding > > & bindings = {} ) const
inlinenodiscardnoexcept

Allocates an array of IDescriptorSet.

Parameters
descriptors_setsThe number of IDescriptorSet to allocate.
bindingsOptional list of descriptor bindings to initialize the IDescriptorSet with.
Returns
A std::vector containing std::unique_ptr to the newly allocated descriptor sets .

◆ allocateMultiple() [3/4]

std::vector< std::unique_ptr< IDescriptorSet > > spark::render::IDescriptorSetLayout::allocateMultiple ( unsigned int descriptors_sets,
unsigned int descriptors,
const std::function< std::vector< DescriptorBinding >(unsigned)> & binding_factory = {} ) const
inlinenodiscardnoexcept

Allocates an array of IDescriptorSet.

Parameters
descriptors_setsThe number of IDescriptorSet to allocate.
descriptorsThe number of descriptors to allocate in an unbounded descriptor array. Ignored if the descriptor array is bounded.
binding_factoryA factory function that creates a list of descriptor bindings for each IDescriptorSet.
Returns
A std::vector containing std::unique_ptr to the newly allocated descriptor sets .

◆ allocateMultiple() [4/4]

std::vector< std::unique_ptr< IDescriptorSet > > spark::render::IDescriptorSetLayout::allocateMultiple ( unsigned int descriptors_sets,
unsigned int descriptors,
const std::vector< std::vector< DescriptorBinding > > & bindings = {} ) const
inlinenodiscardnoexcept

Allocates an array of IDescriptorSet.

Parameters
descriptors_setsThe number of IDescriptorSet to allocate.
descriptorsThe number of descriptors to allocate in an unbounded descriptor array. Ignored if the descriptor array is bounded.
bindingsOptional list of descriptor bindings to initialize each IDescriptorSet with.
Returns
A std::vector containing std::unique_ptr to the newly allocated descriptor sets .

◆ buffers()

virtual unsigned int spark::render::IDescriptorSetLayout::buffers ( ) const
nodiscardpure virtualnoexcept

Get the number of texel buffer descriptors in the IDescriptorSet.

Returns
The number of texel buffer descriptors in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ descriptor()

virtual const IDescriptorLayout * spark::render::IDescriptorSetLayout::descriptor ( unsigned int binding) const
nodiscardpure virtual

Gets the layout of a descriptor in the IDescriptorSet bound to a specific binding point.

Parameters
bindingThe binding point of the requested descriptor layout.
Returns
A pointer to the IDescriptorLayout describing the layout of the descriptor bound to binding.

◆ descriptors()

std::vector< const IDescriptorLayout * > spark::render::IDescriptorSetLayout::descriptors ( ) const
inlinenodiscardnoexcept

Gets the layouts of all descriptors in the IDescriptorSet.

Returns
A std::vector containing pointers to IDescriptorLayout of all descriptors in the IDescriptorSet.

◆ free()

void spark::render::IDescriptorSetLayout::free ( const IDescriptorSet & descriptor_set) const
inlinenoexcept

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

Parameters
descriptor_setThe IDescriptorSet to mark as unused.

◆ images()

virtual unsigned int spark::render::IDescriptorSetLayout::images ( ) const
nodiscardpure virtualnoexcept

Gets the number of images (textures) in the IDescriptorSet.

Returns
The number of images (textures) in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ inputAttachments()

virtual unsigned int spark::render::IDescriptorSetLayout::inputAttachments ( ) const
nodiscardpure virtualnoexcept

Gets the number of input attachments in the IDescriptorSet.

Returns
The number of input attachments in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ samplers()

virtual unsigned int spark::render::IDescriptorSetLayout::samplers ( ) const
nodiscardpure virtualnoexcept

Gets the number of texel buffer descriptors in the IDescriptorSet.

Returns
The number of texel buffer descriptors in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ shaderStage()

virtual ShaderStage spark::render::IDescriptorSetLayout::shaderStage ( ) const
nodiscardpure virtualnoexcept

Gets the shader stage the IDescriptorSet is used in.

Returns
A ShaderStage representing the shader stage the IDescriptorSet is used in.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ space()

virtual unsigned int spark::render::IDescriptorSetLayout::space ( ) const
nodiscardpure virtualnoexcept

Gets the space index of the IDescriptorSet.

Returns
The space index of the IDescriptorSet.
Note
This maps the space index in HLSL.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ staticSamplers()

virtual unsigned int spark::render::IDescriptorSetLayout::staticSamplers ( ) const
nodiscardpure virtualnoexcept

Gets the number of static/immutable samplers in the IDescriptorSet.

Returns
The number of static/immutable samplers in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ storages()

virtual unsigned int spark::render::IDescriptorSetLayout::storages ( ) const
nodiscardpure virtualnoexcept

Gets the number of storage buffers in the IDescriptorSet.

Returns
The number of storage buffers in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.

◆ uniforms()

virtual unsigned int spark::render::IDescriptorSetLayout::uniforms ( ) const
nodiscardpure virtualnoexcept

Gets the number of uniform/constant buffers in the IDescriptorSet.

Returns
The number of uniform/constant buffers in the IDescriptorSet.

Implemented in spark::render::vk::VulkanDescriptorSetLayout.