Overte C++ Documentation
gpu::Sysmem Class Reference

Sysmem is the underneath cache for the data of a resource in CPU RAM. More...

#include <Sysmem.h>

Public Member Functions

 Sysmem (Size size, const Byte *bytes)
 
Size getSize () const
 
Size allocate (Size pSize)
 Allocate the byte array. More...
 
Size resize (Size pSize)
 Resize the byte array. More...
 
Size setData (Size size, const Byte *bytes)
 Assign data bytes and size (allocate for size, then copy bytes if exists). More...
 
Size setSubData (Size offset, Size size, const Byte *bytes)
 Update a subset of buffer data,. More...
 
Size append (Size size, const Byte *data)
 Append new data at the end of the current buffer. More...
 
const Byte * readData () const
 Access the byte array. More...
 
Byte * editData ()
 Access the byte array for reading and writing. More...
 
template<typename T >
const T * read () const
 
template<typename T >
T * edit ()
 
Stamp getStamp () const
 

Detailed Description

Sysmem is the underneath cache for the data of a resource in CPU RAM.

Constructor & Destructor Documentation

◆ Sysmem()

Sysmem::Sysmem ( Size  size,
const Byte *  bytes 
)
Parameters
sizeSize of the sysmem buffer in bytes.
bytesPointer to the data to be copied to the buffer.

Member Function Documentation

◆ allocate()

Size Sysmem::allocate ( Size  pSize)

Allocate the byte array.

Previous content is not copied over to the newly allocated memory.

Parameters
pSizeSize in bytes of the new allocation.
Returns
Buffer size in bytes after allocation. Zero if allocation fails.

◆ append()

Size Sysmem::append ( Size  size,
const Byte *  data 
)

Append new data at the end of the current buffer.

Resizes buffer to (size + getSIze) and copy the new data

Parameters
sizeSize in bytes of the data to append.
dataPointer to the data o append.
Returns
The number of bytes copied or 0 if it fails.

◆ edit()

template<typename T >
T* gpu::Sysmem::edit ( )
inline
Template Parameters
TType to cast data to.
Returns
Data as a requested type.

◆ editData()

Byte* gpu::Sysmem::editData ( )
inline

Access the byte array for reading and writing.

Returns
Pointer to the data.

◆ getSize()

Size gpu::Sysmem::getSize ( ) const
inline
Returns
Size in bytes of the buffer.

◆ getStamp()

Stamp gpu::Sysmem::getStamp ( ) const
inline

Stamp is a counter that is incremented when sysmem object changes size. It's not incremented when contents are edited without resizing.

Returns
Current stamp.

◆ read()

template<typename T >
const T* gpu::Sysmem::read ( ) const
inline
Template Parameters
TType to cast data to.
Returns
Data as a requested type.

◆ readData()

const Byte* gpu::Sysmem::readData ( ) const
inline

Access the byte array.

Returns
Pointer to the data.

◆ resize()

Size Sysmem::resize ( Size  pSize)

Resize the byte array.

Keeps previous data [0 to min(pSize, mSize)].

Parameters
pSizeNew buffer size in bytes.
Returns
Buffer size in bytes after resizing. Returns old size if allocation fails.

◆ setData()

Size Sysmem::setData ( Size  size,
const Byte *  bytes 
)

Assign data bytes and size (allocate for size, then copy bytes if exists).

Parameters
sizeSize in bytes.
bytesPointer to the data.
Returns
Buffer size after setting data. If allocation fails returned size will be different from requested.

◆ setSubData()

Size Sysmem::setSubData ( Size  offset,
Size  size,
const Byte *  bytes 
)

Update a subset of buffer data,.

Doesn't reallocate and only copies specified number of bytes at the offset location. Fails if the data doesn't fit in currently allocated buffer.

Parameters
offsetOffset in bytes where the subset starts.
sizeSize of the data subset in bytes.
bytesPointer to new data to be copied.
Returns
Subset size on success, zero on failure.

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