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

General purpose GPU buffer, with different use types determining its memory type, visibility and access pattern. More...

#include <Buffer.hpp>

Public Member Functions

 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

const BufferType type
 Buffer type.
 
size_t size
 Buffer size in bytes.
 
std::unique_ptr< GPUBuffergpu
 The GPU data (optional).
 

Protected Member Functions

 Buffer (BufferType atype, const std::string &name)
 

Private Attributes

std::string _name
 Resource name.
 

Detailed Description

General purpose GPU buffer, with different use types determining its memory type, visibility and access pattern.

Inherited by UniformBufferBase.

Constructor & Destructor Documentation

◆ Buffer() [1/4]

Buffer::Buffer ( size_t  sizeInBytes,
BufferType  atype,
const std::string &  name 
)

Constructor.

Parameters
sizeInBytesthe size of the buffer in bytes
atypethe use type of the buffer (uniform, index, vertex, storage...)
namethe buffer identifier

◆ Buffer() [2/4]

Buffer::Buffer ( const Buffer )
delete

Copy constructor (disabled).

◆ Buffer() [3/4]

Buffer::Buffer ( Buffer &&  )
delete

Move constructor.

◆ ~Buffer()

Buffer::~Buffer ( )
virtual

Destructor.

◆ Buffer() [4/4]

Buffer::Buffer ( BufferType  atype,
const std::string &  name 
)
protected

Internal constructor, exposed for subclasses that override the size.

Parameters
atypethe use type of the buffer (uniform, index, vertex, storage...)
namethe buffer identifier

Member Function Documentation

◆ clean()

void Buffer::clean ( )

Cleanup all data.

◆ download()

void Buffer::download ( size_t  sizeInBytes,
unsigned char *  data,
size_t  offset 
)

Download data from the buffer.

Parameters
sizeInBytesthe size of the data to download, in bytes
datathe storage to download to
offsetoffset in the buffer

◆ name()

const std::string & Buffer::name ( ) const

Get the resource name.

Returns
the name.

◆ operator=() [1/2]

Buffer & Buffer::operator= ( Buffer &&  )
delete

Move assignment operator .

Returns
a reference to the object assigned to

◆ operator=() [2/2]

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

Copy assignment operator (disabled).

Returns
a reference to the object assigned to

◆ upload() [1/2]

template<typename T >
void Buffer::upload ( const std::vector< T > &  data,
size_t  offset = 0 
)

Upload objects data from a vector to the buffer. You have to take care of synchronization when updating a subregion of the buffer that is currently in use.

Parameters
datathe objects vector to upload
offsetoffset in the buffer

◆ upload() [2/2]

void Buffer::upload ( size_t  sizeInBytes,
unsigned char *  data,
size_t  offset 
)

Upload data to the buffer. You have to take care of synchronization when updating a subregion of the buffer that is currently in use.

Parameters
sizeInBytesthe size of the data to upload, in bytes
datathe data to upload
offsetoffset in the buffer

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