LiteFX 0.3.1.2022
Computer Graphics Engine
LiteFX::Rendering::PushConstantsLayout< TPushConstantsRange > Class Template Referenceabstract

Describes the layout of the pipelines push constant ranges. More...

#include <rendering.hpp>

Inherits LiteFX::Rendering::IPushConstantsLayout.

Public Types

using push_constants_range_type = TPushConstantsRange
 

Public Member Functions

virtual ~PushConstantsLayout () noexcept=default
 
virtual Array< const push_constants_range_type * > ranges () const noexcept=0
 
- Public Member Functions inherited from LiteFX::Rendering::IPushConstantsLayout
virtual ~IPushConstantsLayout () noexcept=default
 
virtual const UInt32size () const noexcept=0
 Returns the size (in bytes) of the push constants backing memory. More...
 
virtual const IPushConstantsRangerange (const ShaderStage &stage) const =0
 Returns the push constant range associated with the shader stage provided in stage . More...
 
Array< const IPushConstantsRange * > ranges () const noexcept
 Returns all push constant ranges. More...
 

Detailed Description

template<typename TPushConstantsRange>
requires rtti::implements<TPushConstantsRange, IPushConstantsRange>
class LiteFX::Rendering::PushConstantsLayout< TPushConstantsRange >

Describes the layout of the pipelines push constant ranges.

Push constants are very efficient, yet quite limited ways of passing per-draw data to shaders. They are mapped directly, so no buffer must be created or transitioned in order to use them. Conceptually a push constant is a single piece of memory that gets transferred to a command buffer directly. Each shader stage has a view into this piece of memory, described by an offset and a size. Since the memory is directly dumped in the command buffer, the backing memory can be incrementally updated and there is no need to store an array of buffers, as long as updates happen sequentially from the same thread. However, there are certain restrictions when using push constants:

  • Only one push constant layout per pipeline layout is supported.
  • A push constant layout may not define a overall memory size larger than 128 bytes. This is a soft restriction that will issue a warning, however it might be supported on some hardware or for some back-ends.
  • The elements and offsets of a push constant memory block must be aligned to 4 bytes.
  • Accordingly, the size of a push constant layout must align to 4 bytes.
  • Only one IPushConstantsRange per shader stage is permitted. Shader stages can be combined together, however in this case, no other ranges must be defined for the stages.

Push constants can be updated by calling CommandBuffer::PushConstants and are visible to subsequent draw calls immediately, until another update is performed or the command buffer is ended.

Template Parameters
TPushConstantsRangeThe type of the push constant range. Must implement IPushConstantsRange.
See also
IPushConstantsRange, DescriptorSetLayout

Member Typedef Documentation

◆ push_constants_range_type

template<typename TPushConstantsRange >
using LiteFX::Rendering::PushConstantsLayout< TPushConstantsRange >::push_constants_range_type = TPushConstantsRange

Constructor & Destructor Documentation

◆ ~PushConstantsLayout()

template<typename TPushConstantsRange >
virtual LiteFX::Rendering::PushConstantsLayout< TPushConstantsRange >::~PushConstantsLayout ( )
virtualdefaultnoexcept

Member Function Documentation

◆ ranges()

template<typename TPushConstantsRange >
virtual Array< const push_constants_range_type * > LiteFX::Rendering::PushConstantsLayout< TPushConstantsRange >::ranges ( ) const
pure virtualnoexcept