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

Resource handle with shared ownership of a GPU memory buffer with copy-on-write value semantics containing an array of structs to be used as instances when drawing meshes to a RenderPass. More...

#include <GREM/graphics/buffers.hpp>

Inheritance diagram for grem::graphics::InstanceBuffer< Instance >:

Public Types

using instance_type = Instance
 Instance type of the buffer.

Public Member Functions

 InstanceBuffer (Device &device)
 Create a new empty buffer set up to contain the specified element type.
uint32_t append (StridedSpan< const Instance > instances)
 Append an array of instances to the buffer, growing the buffer capacity if necessary.
uint32_t push (const Instance &instance)
 Append an instance to the buffer, growing the buffer capacity if necessary.

Detailed Description

template<typename Instance>
class grem::graphics::InstanceBuffer< Instance >

Resource handle with shared ownership of a GPU memory buffer with copy-on-write value semantics containing an array of structs to be used as instances when drawing meshes to a RenderPass.

Template Parameters
Instanceuser-defined aggregate type with the fields that each element of the buffer should contain.

Member Typedef Documentation

◆ instance_type

template<typename Instance>
using grem::graphics::InstanceBuffer< Instance >::instance_type = Instance

Instance type of the buffer.

Constructor & Destructor Documentation

◆ InstanceBuffer()

template<typename Instance>
grem::graphics::InstanceBuffer< Instance >::InstanceBuffer ( 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.

Member Function Documentation

◆ append()

template<typename Instance>
uint32_t grem::graphics::InstanceBuffer< Instance >::append ( StridedSpan< const Instance > instances)
inline

Append an array of instances to the buffer, growing the buffer capacity if necessary.

Parameters
instancesinstances to write.
Returns
the index of the first instance written to 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.

◆ push()

template<typename Instance>
uint32_t grem::graphics::InstanceBuffer< Instance >::push ( const Instance & instance)
inline

Append an instance to the buffer, growing the buffer capacity if necessary.

Parameters
instanceinstance to write.
Returns
the index of the instance written to 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.

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