GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::graphics::StorageBuffer< FieldStruct, Name > Class Template Reference

GPU memory buffer containing an array of structs to be read by a shader program. More...

#include <GREM/graphics/buffers.hpp>

Inheritance diagram for grem::graphics::StorageBuffer< FieldStruct, Name >:

Public Types

using fields_type = FieldStruct
 Field struct type of the buffer.

Public Member Functions

 StorageBuffer (Device &device)
 Create a new empty buffer set up to contain the specified element type.
void upload (StridedSpan< const FieldStruct > newElements)
 Upload a new array of data to the buffer, overriding any previous contents.
void write (uint32_t elementOffset, StridedSpan< const FieldStruct > newElements)
 Upload new elements to the buffer at a specific offset, overriding any data that previously occupied that location, and growing the buffer capacity if necessary.
void write (uint32_t elementIndex, const FieldStruct &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 StorageBufferLayout< FieldStruct, Name > LAYOUT {}
 Layout of the buffer.
static constexpr BufferLayoutReference LAYOUT_REFERENCE = static_cast<StorageBufferLayoutReference>(LAYOUT)
 Type-erased reference to the layout of the buffer.
static constexpr CStringView NAME = Name
 Name of the buffer.

Detailed Description

template<typename FieldStruct, ConstantString Name>
class grem::graphics::StorageBuffer< FieldStruct, Name >

GPU memory buffer containing an array of structs to be read by a shader program.

Template Parameters
FieldStructuser-defined aggregate type with the fields that each element of the buffer should contain.
Namename of the storage buffer. Must be globally unique among all buffer type instantiations.

Member Typedef Documentation

◆ fields_type

template<typename FieldStruct, ConstantString Name>
using grem::graphics::StorageBuffer< FieldStruct, Name >::fields_type = FieldStruct

Field struct type of the buffer.

Constructor & Destructor Documentation

◆ StorageBuffer()

template<typename FieldStruct, ConstantString Name>
grem::graphics::StorageBuffer< FieldStruct, Name >::StorageBuffer ( Device & device)
inlineexplicit

Create a new empty buffer set up to contain the specified element type.

Parameters
devicedevice to create the buffer for. Must outlive the buffer.
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

◆ upload()

template<typename FieldStruct, ConstantString Name>
void grem::graphics::StorageBuffer< FieldStruct, Name >::upload ( StridedSpan< const FieldStruct > newElements)
inline

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

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 FieldStruct, ConstantString Name>
void grem::graphics::StorageBuffer< FieldStruct, Name >::write ( uint32_t elementOffset,
StridedSpan< const FieldStruct > newElements )
inline

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

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 FieldStruct, ConstantString Name>
void grem::graphics::StorageBuffer< FieldStruct, Name >::write ( uint32_t elementIndex,
const FieldStruct & 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.

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 FieldStruct, ConstantString Name>
StorageBufferLayout<FieldStruct, Name> grem::graphics::StorageBuffer< FieldStruct, Name >::LAYOUT {}
staticconstexpr

Layout of the buffer.

◆ LAYOUT_REFERENCE

template<typename FieldStruct, ConstantString Name>
BufferLayoutReference grem::graphics::StorageBuffer< FieldStruct, Name >::LAYOUT_REFERENCE = static_cast<StorageBufferLayoutReference>(LAYOUT)
staticconstexpr

Type-erased reference to the layout of the buffer.

◆ NAME

template<typename FieldStruct, ConstantString Name>
CStringView grem::graphics::StorageBuffer< FieldStruct, Name >::NAME = Name
staticconstexpr

Name of the buffer.


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