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
-
- See also
- IPushConstantsRange, DescriptorSetLayout