Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
UniformBufferBase Class Reference

Uniform buffer exposed to all shader stages, that can be updated at varying frequencies. Multiple instances of the GPU data will be maintained internally. More...

#include <Buffer.hpp>

Public Member Functions

 UniformBufferBase (size_t sizeInBytes, UniformFrequency use, const std::string &name)
 
bool upload (unsigned char *data)
 
void clean ()
 
size_t currentOffset () const
 
size_t baseSize () const
 
UniformBufferBaseoperator= (const UniformBufferBase &)=delete
 
 UniformBufferBase (const UniformBufferBase &)=delete
 
UniformBufferBaseoperator= (UniformBufferBase &&)=delete
 
 UniformBufferBase (UniformBufferBase &&)=delete
 
virtual ~UniformBufferBase ()
 
- Public Member Functions inherited from Buffer
 Buffer (size_t sizeInBytes, BufferType atype, const std::string &name)
 
void upload (size_t sizeInBytes, unsigned char *data, size_t offset)
 
template<typename T >
void upload (const std::vector< T > &data, size_t offset=0)
 
void download (size_t sizeInBytes, unsigned char *data, size_t offset)
 
void clean ()
 
const std::string & name () const
 
Bufferoperator= (const Buffer &)=delete
 
 Buffer (const Buffer &)=delete
 
Bufferoperator= (Buffer &&)=delete
 
 Buffer (Buffer &&)=delete
 
virtual ~Buffer ()
 

Private Attributes

const size_t _baseSize
 The uniform buffer size (ie the size of one instance).
 
size_t _alignment = 0
 The alignment constraint to respect between successive instances.
 
size_t _offset = 0
 The current offset in bytes in the array of instances.
 
bool _wrapAround = true
 Should the buffer attempt to reuse the same memory once full.
 

Additional Inherited Members

- Public Attributes inherited from Buffer
const BufferType type
 Buffer type.
 
size_t size
 Buffer size in bytes.
 
std::unique_ptr< GPUBuffergpu
 The GPU data (optional).
 
- Protected Member Functions inherited from Buffer
 Buffer (BufferType atype, const std::string &name)
 

Detailed Description

Uniform buffer exposed to all shader stages, that can be updated at varying frequencies. Multiple instances of the GPU data will be maintained internally.

Using a base allows the class to be template-free (to avoid exposing GPU/GPUObjects details in headers), while preserving the "pass general Object to GPU for setup/upload & GPUObject only stores GPU handle and settings" approach followed by Texture and Mesh. In practice you will want to use UniformBuffer<T> to benefit from CPU storage and simplified upload.

Inherits Buffer.

Inherited by UniformBuffer< ForwardLight::GPULight >, UniformBuffer< ForwardProbe::GPUProbe >, UniformBuffer< IslandApp::GerstnerWave >, UniformBuffer< glm::vec4 >, and UniformBuffer< T >.

Constructor & Destructor Documentation

◆ UniformBufferBase() [1/3]

UniformBufferBase::UniformBufferBase ( size_t  sizeInBytes,
UniformFrequency  use,
const std::string &  name 
)

Constructor.

Parameters
sizeInBytessize of the uniform buffer
usethe update frequency
namethe buffer identifier

◆ UniformBufferBase() [2/3]

UniformBufferBase::UniformBufferBase ( const UniformBufferBase )
delete

Copy constructor (disabled).

◆ UniformBufferBase() [3/3]

UniformBufferBase::UniformBufferBase ( UniformBufferBase &&  )
delete

Move constructor.

◆ ~UniformBufferBase()

UniformBufferBase::~UniformBufferBase ( )
virtual

Destructor.

Member Function Documentation

◆ baseSize()

size_t UniformBufferBase::baseSize ( ) const
inline
Returns
the size of one instance of the buffer

◆ clean()

void UniformBufferBase::clean ( )

Clean the buffer.

◆ currentOffset()

size_t UniformBufferBase::currentOffset ( ) const
inline
Returns
the current offset in bytes in the internal GPU buffer.

◆ operator=() [1/2]

UniformBufferBase & UniformBufferBase::operator= ( const UniformBufferBase )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

UniformBufferBase & UniformBufferBase::operator= ( UniformBufferBase &&  )
delete

Move assignment operator .

Returns
a reference to the object assigned to

◆ upload()

bool UniformBufferBase::upload ( unsigned char *  data)

Upload data. The buffer will internally copy the data (using the internal size) to a region of mapped GPU memory. Buffering will be handled based on the update frequency.

Parameters
datathe data to copy
Returns
true if a new GPU buffer was allocated internally

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