Rendu
A lightweight rendering engine for experimentations
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
UniformBuffer< T > Class Template Reference

Represents a buffer containing uniform data, stored on the CPU and GPU. Depending on the update frequency of the CPU data, the buffer will maintain one or multiple copies of the data on the GPU. More...

#include <Buffer.hpp>

Public Member Functions

 UniformBuffer (size_t count, UniformFrequency usage, const std::string &name)
 
T & operator[] (size_t i)
 
const T & operator[] (size_t i) const
 
T & at (size_t i)
 
const T & at (size_t i) const
 
size_t size () const
 
bool upload ()
 
UniformBufferoperator= (const UniformBuffer &)=delete
 
 UniformBuffer (const UniformBuffer &)=delete
 
UniformBufferoperator= (UniformBuffer &&)=default
 
 UniformBuffer (UniformBuffer &&)=default
 
 ~UniformBuffer ()=default
 
- Public Member Functions inherited from UniformBufferBase
 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 ()
 

Public Attributes

std::vector< T > data
 The CPU data.
 
- 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).
 

Additional Inherited Members

- Protected Member Functions inherited from Buffer
 Buffer (BufferType atype, const std::string &name)
 

Detailed Description

template<typename T>
class UniformBuffer< T >

Represents a buffer containing uniform data, stored on the CPU and GPU. Depending on the update frequency of the CPU data, the buffer will maintain one or multiple copies of the data on the GPU.

Inherits UniformBufferBase.

Constructor & Destructor Documentation

◆ UniformBuffer() [1/3]

template<typename T >
UniformBuffer< T >::UniformBuffer ( size_t  count,
UniformFrequency  usage,
const std::string &  name 
)

Constructor.

Parameters
countthe number of elements
usagethe update frequency of the buffer content
namethe buffer identifier

◆ UniformBuffer() [2/3]

template<typename T >
UniformBuffer< T >::UniformBuffer ( const UniformBuffer< T > &  )
delete

Copy constructor (disabled).

◆ UniformBuffer() [3/3]

template<typename T >
UniformBuffer< T >::UniformBuffer ( UniformBuffer< T > &&  )
default

Move constructor.

◆ ~UniformBuffer()

template<typename T >
UniformBuffer< T >::~UniformBuffer ( )
default

Destructor.

Member Function Documentation

◆ at() [1/2]

template<typename T >
T & UniformBuffer< T >::at ( size_t  i)
inline

Accessor.

Parameters
ithe location of the item to retrieve
Returns
a reference to the item

◆ at() [2/2]

template<typename T >
const T & UniformBuffer< T >::at ( size_t  i) const
inline

Accessor.

Parameters
ithe location of the item to retrieve
Returns
a reference to the item

◆ operator=() [1/2]

template<typename T >
UniformBuffer & UniformBuffer< T >::operator= ( const UniformBuffer< T > &  )
delete

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ operator=() [2/2]

template<typename T >
UniformBuffer & UniformBuffer< T >::operator= ( UniformBuffer< T > &&  )
default

Move assignment operator .

Returns
a reference to the object assigned to

◆ operator[]() [1/2]

template<typename T >
T & UniformBuffer< T >::operator[] ( size_t  i)
inline

Accessor.

Parameters
ithe location of the item to retrieve
Returns
a reference to the item

◆ operator[]() [2/2]

template<typename T >
const T & UniformBuffer< T >::operator[] ( size_t  i) const
inline

Accessor.

Parameters
ithe location of the item to retrieve
Returns
a reference to the item

◆ size()

template<typename T >
size_t UniformBuffer< T >::size ( ) const
inline
Returns
the CPU size of the buffer.

◆ upload()

template<typename T >
bool UniformBuffer< T >::upload

Send the buffer data to the GPU. Previously uploaded content will potentially be erased.

Returns
true if a new GPU buffer was allocated internally

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