Castor3D  ..
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
Castor3D::CpuBuffer< T > Class Template Reference

3D Buffer management class More...

+ Inheritance diagram for Castor3D::CpuBuffer< T >:
+ Collaboration diagram for Castor3D::CpuBuffer< T >:

Public Member Functions

void Destroy ()
 Destruction function. More...
 
void Cleanup ()
 Cleanup function. More...
 
bool Initialise (eBUFFER_ACCESS_TYPE p_type, eBUFFER_ACCESS_NATURE p_nature)
 Initialisation function, initialises GPU buffer. More...
 
T * Lock (uint32_t p_offset, uint32_t p_count, uint32_t p_flags)
 Locks the buffer, id est maps it into memory so we can modify it. More...
 
void Unlock ()
 Unlocks the buffer, id est unmaps it from memory so no modification can be made after that. More...
 
bool Fill (T const *p_buffer, ptrdiff_t p_size, Castor3D::eBUFFER_ACCESS_TYPE p_type, Castor3D::eBUFFER_ACCESS_NATURE p_nature)
 Transmits data to the GPU buffer from RAM. More...
 
bool Bind ()
 Activation function, to tell the GPU it is active. More...
 
void Unbind ()
 Deactivation function, to tell the GPU it is inactive. More...
 
void SetElement (uint32_t p_index, T const &p_value)
 Sets element value at given index. More...
 
void AddElement (T const &p_value)
 Adds a value at the end of the buffer. More...
 
uint32_t GetSize () const
 Retrieves the filled buffer size. More...
 
uint32_t GetCapacity () const
 Retrieves the allocated buffer size. More...
 
void Resize (uint32_t p_uiNewSize)
 Sets the allocated size of the buffer. More...
 
void Reserve (uint32_t p_uiIncrement)
 Increases the allocated size of the buffer. More...
 
void Clear ()
 Clears the buffer. More...
 
bool IsToDelete () const
 Retrieves the delete status of the buffer. More...
 
bool IsAssigned () const
 Retrieves the assignment status of the buffer. More...
 
GpuBufferSPtr GetGpuBuffer () const
 Retrieves the GPU buffer. More...
 
void Assign ()
 Sets the assignment status to true. More...
 
void Unassign ()
 Sets the assignment status to false. More...
 
T const * data () const
 Retrieves the data pointer. More...
 
T * data ()
 Retrieves the data pointer. More...
 

Protected Types

typedef std::shared_ptr< GpuBuffer< T > > GpuBufferSPtr
 
typedef std::weak_ptr< GpuBuffer< T > > GpuBufferWPtr
 
typedef std::weak_ptr< CpuBuffer< T > > CpuBufferWPtr
 

Protected Member Functions

 DECLARE_TPL_VECTOR (T, T)
 
 CpuBuffer (Engine &p_engine)
 Constructor. More...
 
 ~CpuBuffer ()
 Destructor. More...
 

Protected Attributes

bool m_bToDelete
 Tells the buffer is to be deleted at next render loop. More...
 
bool m_bAssigned
 Tells the buffer has it's GPU buffer assigned. More...
 
GpuBufferSPtr m_pBuffer
 The GPU buffer. More...
 
TArray m_arrayData
 The buffer data. More...
 
uint32_t m_uiSavedSize
 

Detailed Description

template<typename T>
class Castor3D::CpuBuffer< T >

3D Buffer management class

Author
Sylvain DOREMUS
Version
0.1
Date
09/02/2010
Remarks
Class which holds the buffers used in 3D (texture, VBO ...)
Not to be used to manage usual buffers of data, use Castor::Buffer for that

Member Typedef Documentation

◆ CpuBufferWPtr

template<typename T>
typedef std::weak_ptr< CpuBuffer< T > > Castor3D::CpuBuffer< T >::CpuBufferWPtr
protected

◆ GpuBufferSPtr

template<typename T>
typedef std::shared_ptr< GpuBuffer< T > > Castor3D::CpuBuffer< T >::GpuBufferSPtr
protected

◆ GpuBufferWPtr

template<typename T>
typedef std::weak_ptr< GpuBuffer< T > > Castor3D::CpuBuffer< T >::GpuBufferWPtr
protected

Constructor & Destructor Documentation

◆ CpuBuffer()

template<typename T>
Castor3D::CpuBuffer< T >::CpuBuffer ( Engine p_engine)
inlineprotected

Constructor.

Parameters
[in]p_engineThe engine

◆ ~CpuBuffer()

template<typename T>
Castor3D::CpuBuffer< T >::~CpuBuffer ( )
inlineprotected

Destructor.

Member Function Documentation

◆ AddElement()

template<typename T>
void Castor3D::CpuBuffer< T >::AddElement ( T const &  p_value)
inline

Adds a value at the end of the buffer.

Parameters
[in]p_valueThe value

◆ Assign()

template<typename T>
void Castor3D::CpuBuffer< T >::Assign ( )
inline

Sets the assignment status to true.

◆ Bind()

template<typename T>
bool Castor3D::CpuBuffer< T >::Bind ( )
inline

Activation function, to tell the GPU it is active.

Returns
true if successful

◆ Cleanup()

template<typename T>
void Castor3D::CpuBuffer< T >::Cleanup ( void  )
inline

Cleanup function.

◆ Clear()

template<typename T>
void Castor3D::CpuBuffer< T >::Clear ( )
inline

Clears the buffer.

◆ data() [1/2]

template<typename T>
T const* Castor3D::CpuBuffer< T >::data ( ) const
inline

Retrieves the data pointer.

Returns
The data pointer

Referenced by Castor3D::VertexBuffer::LinkCoords().

+ Here is the caller graph for this function:

◆ data() [2/2]

template<typename T>
T* Castor3D::CpuBuffer< T >::data ( )
inline

Retrieves the data pointer.

Returns
The data pointer

◆ DECLARE_TPL_VECTOR()

template<typename T>
Castor3D::CpuBuffer< T >::DECLARE_TPL_VECTOR ( ,
 
)
protected

◆ Destroy()

template<typename T>
void Castor3D::CpuBuffer< T >::Destroy ( )
inline

Destruction function.

◆ Fill()

template<typename T>
bool Castor3D::CpuBuffer< T >::Fill ( T const *  p_buffer,
ptrdiff_t  p_size,
Castor3D::eBUFFER_ACCESS_TYPE  p_type,
Castor3D::eBUFFER_ACCESS_NATURE  p_nature 
)
inline

Transmits data to the GPU buffer from RAM.

Parameters
[in]p_bufferThe data
[in]p_sizeData buffer size
[in]p_typeTransfer type
[in]p_natureTransfer nature
Returns
true if successful

◆ GetCapacity()

template<typename T>
uint32_t Castor3D::CpuBuffer< T >::GetCapacity ( ) const
inline

Retrieves the allocated buffer size.

Returns
The size

Referenced by Castor3D::CpuBuffer< uint8_t >::Reserve().

+ Here is the caller graph for this function:

◆ GetGpuBuffer()

template<typename T>
GpuBufferSPtr Castor3D::CpuBuffer< T >::GetGpuBuffer ( ) const
inline

◆ GetSize()

template<typename T>
uint32_t Castor3D::CpuBuffer< T >::GetSize ( ) const
inline

Retrieves the filled buffer size.

Returns
The size

◆ Initialise()

template<typename T>
bool Castor3D::CpuBuffer< T >::Initialise ( eBUFFER_ACCESS_TYPE  p_type,
eBUFFER_ACCESS_NATURE  p_nature 
)
inline

Initialisation function, initialises GPU buffer.

Parameters
[in]p_typeBuffer access type
[in]p_natureBuffer access nature
Returns
true if OK

◆ IsAssigned()

template<typename T>
bool Castor3D::CpuBuffer< T >::IsAssigned ( ) const
inline

Retrieves the assignment status of the buffer.

Returns
The assignment status

◆ IsToDelete()

template<typename T>
bool Castor3D::CpuBuffer< T >::IsToDelete ( ) const
inline

Retrieves the delete status of the buffer.

Returns
The delete status

◆ Lock()

template<typename T>
T* Castor3D::CpuBuffer< T >::Lock ( uint32_t  p_offset,
uint32_t  p_count,
uint32_t  p_flags 
)
inline

Locks the buffer, id est maps it into memory so we can modify it.

Remarks
Maps from buffer[p_offset*sizeof( T )] to buffer[(p_offset+p_uiSize-1)*sizeof( T )]
Parameters
[in]p_offsetThe start offset in the buffer
[in]p_countThe mapped elements count
[in]p_flagsThe lock flags
Returns
The mapped buffer address

◆ Reserve()

template<typename T>
void Castor3D::CpuBuffer< T >::Reserve ( uint32_t  p_uiIncrement)
inline

Increases the allocated size of the buffer.

Parameters
[in]p_uiIncrementThe size increment

◆ Resize()

template<typename T>
void Castor3D::CpuBuffer< T >::Resize ( uint32_t  p_uiNewSize)
inline

Sets the allocated size of the buffer.

Parameters
[in]p_uiNewSizeThe new size

◆ SetElement()

template<typename T>
void Castor3D::CpuBuffer< T >::SetElement ( uint32_t  p_index,
T const &  p_value 
)
inline

Sets element value at given index.

Parameters
[in]p_indexThe index
[in]p_valueThe value

◆ Unassign()

template<typename T>
void Castor3D::CpuBuffer< T >::Unassign ( )
inline

Sets the assignment status to false.

◆ Unbind()

template<typename T>
void Castor3D::CpuBuffer< T >::Unbind ( )
inline

Deactivation function, to tell the GPU it is inactive.

Returns
true if successful

◆ Unlock()

template<typename T>
void Castor3D::CpuBuffer< T >::Unlock ( )
inline

Unlocks the buffer, id est unmaps it from memory so no modification can be made after that.

Remarks
All modifications made in the mapped buffer are put into GPU memory

Member Data Documentation

◆ m_arrayData

template<typename T>
TArray Castor3D::CpuBuffer< T >::m_arrayData
protected

◆ m_bAssigned

template<typename T>
bool Castor3D::CpuBuffer< T >::m_bAssigned
protected

◆ m_bToDelete

template<typename T>
bool Castor3D::CpuBuffer< T >::m_bToDelete
protected

Tells the buffer is to be deleted at next render loop.

Referenced by Castor3D::CpuBuffer< uint8_t >::IsToDelete().

◆ m_pBuffer

template<typename T>
GpuBufferSPtr Castor3D::CpuBuffer< T >::m_pBuffer
protected

◆ m_uiSavedSize

template<typename T>
uint32_t Castor3D::CpuBuffer< T >::m_uiSavedSize
protected

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