GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::BufferSet< Buffers > Class Template Reference

Collection of GPU memory buffers to be read by a shader. More...

#include <GREM/graphics/buffers.hpp>

Inheritance diagram for grem::graphics::BufferSet< Buffers >:

Public Types

using buffer_types = meta::TypeList<Buffers...>
 Buffer type list of the buffer set.

Public Member Functions

 BufferSet (Device &device)
 Create a new set of empty buffers.
 BufferSet (Device &device, std::nullptr_t nullPointer)
 Create an empty set of buffers that is invalid until all of its buffers have been reassigned.
 BufferSet (Device &device, const Buffers &... buffers)
 Create a new buffer set from a set of existing buffers.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void setBuffer (std::nullptr_t nullPointer)
 Remove a buffer from the set, making the set invalid until all of its buffers have been reassigned.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void setBuffer (const Buffer &buffer)
 Assign an existing buffer to a slot in the buffer set.
void setBuffers (std::nullptr_t nullPointer)
 Reset the buffer set to an empty set that is invalid until all of its buffers have been reassigned.
void setBuffers (const Buffers &... buffers)
 Assign an existing set of buffers to the buffer set.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void upload (const typename Buffer::parameters_type &newParameterValues)
 Upload new parameter values to a uniform buffer in the buffer set for the next shader invocation that reads from it.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void upload (StridedSpan< const typename Buffer::fields_type > newElements)
 Upload a new array of data to a storage buffer in the buffer set, overriding any previous contents.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void write (uint32_t elementOffset, StridedSpan< const typename Buffer::fields_type > newElements)
 Upload new elements to a storage buffer in the buffer set at a specific offset, overriding any data that previously occupied that location, and growing the buffer capacity if necessary.
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void write (uint32_t elementIndex, const typename Buffer::fields_type &newElement)
 Upload a new element to the buffer at a specific index, overriding any element that previously occupied that location, and growing the buffer capacity if necessary.

Static Public Attributes

static constexpr BufferSetLayout< Buffers... > LAYOUT {}
 Layout of the buffer set.
static constexpr BufferLayoutReference LAYOUT_REFERENCE = static_cast<BufferSetLayoutReference>(LAYOUT)
 Type-erased reference to the layout of the buffer set.
static constexpr CStringView NAME = static_cast<BufferSetLayoutReference>(LAYOUT).name
 Name of the buffer set.

Detailed Description

template<typename... Buffers>
class grem::graphics::BufferSet< Buffers >

Collection of GPU memory buffers to be read by a shader.

Template Parameters
Buffersshader-readable buffer types to store in the buffer set. Each given type must be a unique specialization of UniformBuffer or StorageBuffer.

Member Typedef Documentation

◆ buffer_types

template<typename... Buffers>
using grem::graphics::BufferSet< Buffers >::buffer_types = meta::TypeList<Buffers...>

Buffer type list of the buffer set.

Constructor & Destructor Documentation

◆ BufferSet() [1/3]

template<typename... Buffers>
grem::graphics::BufferSet< Buffers >::BufferSet ( Device & device)
inlineexplicit

Create a new set of empty buffers.

Parameters
devicedevice to create the buffer set for. Must outlive the buffer set.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ BufferSet() [2/3]

template<typename... Buffers>
grem::graphics::BufferSet< Buffers >::BufferSet ( Device & device,
std::nullptr_t nullPointer )
inline

Create an empty set of buffers that is invalid until all of its buffers have been reassigned.

Parameters
devicedevice to create the buffer set for. Must outlive the buffer set.
nullPointernullptr.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Warning
A buffer set created with this constructor must be assigned a set of valid buffers before it can be read, written or uploaded to.

◆ BufferSet() [3/3]

template<typename... Buffers>
grem::graphics::BufferSet< Buffers >::BufferSet ( Device & device,
const Buffers &... buffers )
inlineexplicit

Create a new buffer set from a set of existing buffers.

Parameters
devicedevice to create the buffer set for. Must outlive the buffer set.
buffersbuffers to create the buffer set from.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Function Documentation

◆ setBuffer() [1/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::setBuffer ( std::nullptr_t nullPointer)
inline

Remove a buffer from the set, making the set invalid until all of its buffers have been reassigned.

Template Parameters
Bufferbuffer type to remove. Must be one of the types specified in the buffer set's buffer type list.
Parameters
nullPointernullptr.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Warning
After calling this function, the buffer set must be assigned a set of valid buffers before it can be read, written or uploaded to.

◆ setBuffer() [2/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::setBuffer ( const Buffer & buffer)
inline

Assign an existing buffer to a slot in the buffer set.

Template Parameters
Bufferbuffer type to assign. Must be one of the types specified in the buffer set's buffer type list.
Parameters
buffernew buffer to assign.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ setBuffers() [1/2]

template<typename... Buffers>
void grem::graphics::BufferSet< Buffers >::setBuffers ( std::nullptr_t nullPointer)
inline

Reset the buffer set to an empty set that is invalid until all of its buffers have been reassigned.

Parameters
nullPointernullptr.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.
Warning
After calling this function, the buffer set must be assigned a set of valid buffers before it can be read, written or uploaded to.

◆ setBuffers() [2/2]

template<typename... Buffers>
void grem::graphics::BufferSet< Buffers >::setBuffers ( const Buffers &... buffers)
inline

Assign an existing set of buffers to the buffer set.

Parameters
buffersnew buffers to assign.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ upload() [1/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::upload ( const typename Buffer::parameters_type & newParameterValues)
inline

Upload new parameter values to a uniform buffer in the buffer set for the next shader invocation that reads from it.

Template Parameters
Bufferuniform buffer type to upload new values to. Must be one of the types specified in the buffer set's buffer type list.
Parameters
newParameterValuesnew parameter values to upload.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ upload() [2/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::upload ( StridedSpan< const typename Buffer::fields_type > newElements)
inline

Upload a new array of data to a storage buffer in the buffer set, overriding any previous contents.

Template Parameters
Bufferstorage buffer type to upload new elements to. Must be one of the types specified in the buffer set's buffer type list.
Parameters
newElementsnew array of elements to upload.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ write() [1/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::write ( uint32_t elementOffset,
StridedSpan< const typename Buffer::fields_type > newElements )
inline

Upload new elements to a storage buffer in the buffer set at a specific offset, overriding any data that previously occupied that location, and growing the buffer capacity if necessary.

Template Parameters
Bufferstorage buffer type to upload new elements to. Must be one of the types specified in the buffer set's buffer type list.
Parameters
elementOffsetoffset at which to write the new elements.
newElementsnew elements to upload.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

◆ write() [2/2]

template<typename... Buffers>
template<typename Buffer>
requires (meta::type_list_contains_v<buffer_types, Buffer>)
void grem::graphics::BufferSet< Buffers >::write ( uint32_t elementIndex,
const typename Buffer::fields_type & newElement )
inline

Upload a new element to the buffer at a specific index, overriding any element that previously occupied that location, and growing the buffer capacity if necessary.

Template Parameters
Bufferstorage buffer type to upload new elements to. Must be one of the types specified in the buffer set's buffer type list.
Parameters
elementIndexindex at which to write the new element.
newElementnew element to upload.
Exceptions
graphics::Errorif resource creation failed.
std::length_errorif an internal size limit was exceeded.
std::bad_array_new_lengthif an internal size limit was exceeded.
std::bad_allocon allocation failure.

Member Data Documentation

◆ LAYOUT

template<typename... Buffers>
BufferSetLayout<Buffers...> grem::graphics::BufferSet< Buffers >::LAYOUT {}
staticconstexpr

Layout of the buffer set.

◆ LAYOUT_REFERENCE

template<typename... Buffers>
BufferLayoutReference grem::graphics::BufferSet< Buffers >::LAYOUT_REFERENCE = static_cast<BufferSetLayoutReference>(LAYOUT)
staticconstexpr

Type-erased reference to the layout of the buffer set.

◆ NAME

template<typename... Buffers>
CStringView grem::graphics::BufferSet< Buffers >::NAME = static_cast<BufferSetLayoutReference>(LAYOUT).name
staticconstexpr

Name of the buffer set.


The documentation for this class was generated from the following file: