As asset container which wraps shared index or vertex buffer object data.
#include <asset/YiAssetBufferObjectData.h>
Public Types | |
enum | BufferType : uint8_t { BufferType::Vertex, BufferType::Index } |
enum | IndexType : uint8_t { IndexType::UnsignedShort, IndexType::UnsignedInt, IndexType::UnsignedShortLooping } |
enum | BufferUsage : uint8_t { BufferUsage::Static, BufferUsage::Dynamic } |
![]() | |
enum | RetentionPolicy { RetentionPolicy::Retain = 0, RetentionPolicy::Unload } |
The CYIAssetHardware::RetentionPolicy enum specifies the retention policy of static hardware assets from the CPU memory once they are loaded onto the GPU. It is globally configurable, where new CYIAssetHardware will be making use of it and the can also change directly per assets. Be aware that on some platform, it is best to leave the assets retained on the CPU side when the platform lifecycle has the ability to destroy the graphic context while the app still runs, giving You.i Engine the ability to re-load every assets back onto GPU memory really fast. A good example of such platform would be Android. More... | |
![]() | |
enum | PathType { PathType::Absolute = 0, PathType::Relative } |
Public Member Functions | |
CYIAssetBufferObjectData () | |
CYIAssetBufferObjectData (const CYIString &path, PathType pathType=PathType::Relative) | |
virtual | ~CYIAssetBufferObjectData () override |
const std::vector< uint8_t > & | GetData () const |
BufferType | GetType () const |
IndexType | GetIndexType () const |
BufferUsage | GetUsage () const |
void | SetData (uint8_t const *pData, size_t numOfElements, size_t sizeOfElement) |
void | Resize (size_t numOfElements, size_t sizeOfElement) |
void | SetData (const std::vector< uint8_t > &rData) |
void | SetType (BufferType type) |
void | SetIndexType (IndexType indexType) |
void | SetIndexLoopingCounts (uint8_t loopingIndexCount, uint8_t loopingVertexCount) |
uint8_t | GetIndexLoopingIndexCount () const |
uint8_t | GetIndexLoopingVertexCount () const |
void | SetUsage (BufferUsage usage) |
size_t | GetSizeInBytes () const |
virtual std::pair< size_t, size_t > | GetApproximateSize () const override |
virtual void | ApplyRetainmentPolicy () override |
![]() | |
CYIAssetHardware () | |
virtual | ~CYIAssetHardware () override |
virtual bool | RequestHardwareLoad () |
virtual bool | RequestHardwareUnload () |
virtual bool | RequestInvalidate () |
virtual bool | RequestRestore () |
virtual bool | Prepare () override |
const std::shared_ptr< IYIGPUObject > & | GetGPUObject () const |
bool | IsLoadedOnGPU () const |
RetentionPolicy | GetRetentionPolicy () const |
void | SetRetentionPolicy (RetentionPolicy policy) |
![]() | |
virtual | ~CYIAsset () |
const CYIString & | GetPath () const |
CYIAssetLoadParams * | GetLoadParameters () const |
bool | SetName (const CYIString &name) |
const CYIString & | GetName () const |
bool | Load () |
void | Unload () |
bool | IsLoaded () const |
bool | Equals (const std::shared_ptr< CYIAsset > &pAsset) |
Protected Member Functions | |
virtual std::shared_ptr< IYIGPUObject > | CreateGPUObject () const override |
virtual void | OnUnload () override |
![]() | |
virtual void | OnLoad () override |
![]() | |
CYIAsset () | |
ssize_t | GetID () const |
void | SetPath (const CYIString &path, PathType pathType) |
void | SetApproximateSize (size_t size) |
void | SetLoaded (bool assetLoaded) |
void | SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams) |
Additional Inherited Members | |
![]() | |
bool | m_hardwareLoadRequested |
std::shared_ptr< IYIGPUObject > | m_pGPUObject |
RetentionPolicy | m_retentionPolicy |
![]() | |
static ssize_t | INVALID_ID |
|
strong |
|
strong |
|
strong |
Index buffer types. These define the data type and the usage mode for the index buffer.
Enumerator | |
---|---|
UnsignedShort | Each index is represented as an unsigned short. The maximum number of vertices is 65535. This is the default. |
UnsignedInt | Each index is represented as an unsigned int. The maximum number of vertices is 4294967295. Note that this index mode is not supported on OpenGL ES2 devices. Use CYICapabilities to check for availability. |
UnsignedShortLooping | There is no maximum number of vertices, but the indices must be applicable to repeating groups of indices. Used in conjunction with SetIndexLoopingCounts. This index type is only supported on OpenGL renderers. |
CYIAssetBufferObjectData::CYIAssetBufferObjectData | ( | ) |
CYIAssetBufferObjectData::CYIAssetBufferObjectData | ( | const CYIString & | path, |
PathType | pathType = PathType::Relative |
||
) |
|
overridevirtual |
|
overridevirtual |
Unloads CPU-side data buffer memory if the retainment policy is configured to unload instead of retaining it.
This function should only be used internally by the GPU object after the data has been uploaded onto the GPU. that some asset may chose to retain/unload cpu assets with additional conditions. For example, CYIAssetTextureBase won't unload the cpu asset if the asset is marked as being dynamic.
Reimplemented from CYIAssetHardware.
|
overrideprotectedvirtual |
Subclasses must implement this function to instance a new IYIGPUObject concrete type corresponding to the asset container. This function will be called by the CreateGPUObject implementation of CYIAssetHardware
Implements CYIAssetHardware.
|
overridevirtual |
Calculates and returns the approximate number of bytes currently used by this asset. The first item of the returned pair object represents the memory currently taken in the CPU main memory, and the second item of the returned pair object represents the memory currently taken in the GPU memory.
Reimplemented from CYIAsset.
const std::vector<uint8_t>& CYIAssetBufferObjectData::GetData | ( | ) | const |
Returns a read-only reference of the buffer. The user can chose to make a copy instead if alteration are necessary. Once altered, the copy has to be stored using SetData.
uint8_t CYIAssetBufferObjectData::GetIndexLoopingIndexCount | ( | ) | const |
Get the number of indices after which index looping should occur.
uint8_t CYIAssetBufferObjectData::GetIndexLoopingVertexCount | ( | ) | const |
Get the number of vertices to skip when looping indices.
IndexType CYIAssetBufferObjectData::GetIndexType | ( | ) | const |
Gets the the data type of vertex indices stored in this data buffer.
size_t CYIAssetBufferObjectData::GetSizeInBytes | ( | ) | const |
Get the size of the buffer in bytes
BufferType CYIAssetBufferObjectData::GetType | ( | ) | const |
Get the type of buffer data this represents.
BufferUsage CYIAssetBufferObjectData::GetUsage | ( | ) | const |
Get the buffer usage
|
overrideprotectedvirtual |
Reimplemented from CYIAsset.
Allocates memory in internal structure of the object based on the provided number of elements and the provided size of elements.
void CYIAssetBufferObjectData::SetData | ( | uint8_t const * | pData, |
size_t | numOfElements, | ||
size_t | sizeOfElement | ||
) |
Stores buffer to the object. Will automatically allocate/reallocate memory in its internal structure based on the provided number of elements and the provided size of elements
void CYIAssetBufferObjectData::SetData | ( | const std::vector< uint8_t > & | rData | ) |
Stores buffer to the object. will automatically allocate/reallocate sizeInBytes of memory at a specified address.
void CYIAssetBufferObjectData::SetIndexLoopingCounts | ( | uint8_t | loopingIndexCount, |
uint8_t | loopingVertexCount | ||
) |
Sets the looping counts for index buffers. This sets the number of indices used for a specific number of vertexes, and is used to calculate the maximum number of indices that can be used when drawing.
For example, a mesh composed of multiple quads would use 6 indices for each 4 vertex, and so this function would be called with 6 and 4 as parameters respectively.
void CYIAssetBufferObjectData::SetIndexType | ( | IndexType | indexType | ) |
Set the the data type of vertex indices stored in this data buffer.
void CYIAssetBufferObjectData::SetType | ( | BufferType | type | ) |
Set the type of buffer data this represents.
void CYIAssetBufferObjectData::SetUsage | ( | BufferUsage | usage | ) |
Set the usage for the buffer.