You.i Engine
CYIAssetBufferObjectData Class Reference

Detailed Description

As asset container which wraps shared index or vertex buffer object data.

#include <asset/YiAssetBufferObjectData.h>

Inheritance diagram for CYIAssetBufferObjectData:

Public Types

enum  YI_BUFFER_TYPE {
  YI_VERTEX_BUFFER,
  YI_INDEX_BUFFER
}
 
enum  YI_BUFFER_USAGE {
  YI_BUFFER_USAGE_STATIC,
  YI_BUFFER_USAGE_DYNAMIC
}
 
- Public Types inherited from CYIAssetHardware
enum  RETENTION_POLICY {
  RETAIN = 0,
  UNLOAD
}
 The YI_HW_ASSET_RETENTION_POLICY 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...
 
- Public Types inherited from CYIAsset
enum  PATH_TYPE {
  PATH_ABSOLUTE = 0,
  PATH_RELATIVE
}
 

Public Member Functions

 CYIAssetBufferObjectData ()
 
 CYIAssetBufferObjectData (const CYIString &path, PATH_TYPE ePathType=PATH_RELATIVE)
 
virtual ~CYIAssetBufferObjectData ()
 
const std::vector< uint8_t > & GetData () const
 
YI_BUFFER_TYPE GetType () const
 
YI_BUFFER_USAGE GetUsage () const
 
void SetData (uint8_t const *pData, uint32_t uNumOfElements, uint32_t uSizeOfElement)
 
void Resize (uint32_t uNumOfElements, uint32_t uSizeOfElement)
 
void SetData (const std::vector< uint8_t > &rData)
 
void SetType (YI_BUFFER_TYPE eType)
 
void SetUsage (YI_BUFFER_USAGE eUsage)
 
uint32_t GetSizeInBytes () const
 
virtual std::pair< uint32_t, uint32_t > GetApproximateSize () const override
 
- Public Member Functions inherited from CYIAssetHardware
 CYIAssetHardware ()
 
virtual ~CYIAssetHardware ()
 
virtual bool RequestHardwareLoad ()
 
virtual bool RequestHardwareUnload ()
 
virtual bool RequestInvalidate ()
 
virtual bool RequestRestore ()
 
virtual bool Prepare () override
 
std::shared_ptr< IYIGPUObjectGetGPUObject () const
 
bool IsLoadedOnGPU () const
 
RETENTION_POLICY GetRetentionPolicy () const
 
void SetRetentionPolicy (RETENTION_POLICY ePolicy)
 
- Public Member Functions inherited from CYIAsset
virtual ~CYIAsset ()
 
const CYIStringGetPath () const
 
CYIAssetLoadParamsGetLoadParameters () const
 
bool SetName (const CYIString &name)
 
const CYIStringGetName () const
 
bool Load ()
 
void Unload ()
 
bool IsLoaded () const
 
bool Equals (const std::shared_ptr< CYIAsset > &pAsset)
 
- Public Member Functions inherited from CYIScriptableRTTIObject
 CYIScriptableRTTIObject ()
 
virtual ~CYIScriptableRTTIObject ()
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const override
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 

Protected Member Functions

virtual std::shared_ptr< IYIGPUObjectCreateGPUObject () const override
 
virtual void OnUnload () override
 
virtual void ApplyRetainmentPolicy () override
 
- Protected Member Functions inherited from CYIAssetHardware
virtual void OnLoad () override
 
- Protected Member Functions inherited from CYIAsset
 CYIAsset ()
 
ssize_t GetID () const
 
void SetPath (const CYIString &path, PATH_TYPE ePathType)
 
void SetApproximateSize (uint32_t nSize)
 
void SetLoaded (bool bAssetLoaded)
 
void SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams)
 
- Protected Member Functions inherited from CYIScriptableRTTIObject
virtual std::pair< const CYIRuntimeTypeInfo *, const void * > GetRuntimeTypeInfoWithObject () const =0
 

Additional Inherited Members

- Protected Attributes inherited from CYIAssetHardware
bool m_bHardwareLoadRequested
 
std::shared_ptr< IYIGPUObjectm_pGPUObject
 
RETENTION_POLICY m_eRetentionPolicy
 
- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Member Enumeration Documentation

Creation hints for the buffers

Enumerator
YI_VERTEX_BUFFER 

A vertex buffer object

YI_INDEX_BUFFER 

An index buffer object

Enumerator
YI_BUFFER_USAGE_STATIC 

Hint indicating that the buffer should not be modified. Updating will delete and recreate the buffer

YI_BUFFER_USAGE_DYNAMIC 

Hint indicating that the buffer can be dynamically updated.

Constructor & Destructor Documentation

CYIAssetBufferObjectData::CYIAssetBufferObjectData ( )
CYIAssetBufferObjectData::CYIAssetBufferObjectData ( const CYIString path,
PATH_TYPE  ePathType = PATH_RELATIVE 
)
virtual CYIAssetBufferObjectData::~CYIAssetBufferObjectData ( )
virtual

Member Function Documentation

virtual void CYIAssetBufferObjectData::ApplyRetainmentPolicy ( )
overrideprotectedvirtual

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.

See also
YI_HW_ASSET_RETENTION_POLICY
SetRetentionPolicy
GetRetentionPolicy

Reimplemented from CYIAssetHardware.

virtual std::shared_ptr<IYIGPUObject> CYIAssetBufferObjectData::CreateGPUObject ( ) const
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

Warning
This function may not return null!

Implements CYIAssetHardware.

virtual std::pair<uint32_t, uint32_t> CYIAssetBufferObjectData::GetApproximateSize ( ) const
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.

Note
This function only returns an approximate memory consumption as the exact memory consumption changes depending on the used C++ libraries and on the specific GPU infrastructure and drivers used by the system.

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.

uint32_t CYIAssetBufferObjectData::GetSizeInBytes ( ) const

Get the size of the buffer in bytes

YI_BUFFER_TYPE CYIAssetBufferObjectData::GetType ( ) const

Get the type of buffer data this represents

YI_BUFFER_USAGE CYIAssetBufferObjectData::GetUsage ( ) const

Get the buffer usage

virtual void CYIAssetBufferObjectData::OnUnload ( )
overrideprotectedvirtual

Reimplemented from CYIAsset.

void CYIAssetBufferObjectData::Resize ( uint32_t  uNumOfElements,
uint32_t  uSizeOfElement 
)

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,
uint32_t  uNumOfElements,
uint32_t  uSizeOfElement 
)

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 uSizeInBytes of memory at a specified address.

void CYIAssetBufferObjectData::SetType ( YI_BUFFER_TYPE  eType)

Set the type of buffer data this represents

void CYIAssetBufferObjectData::SetUsage ( YI_BUFFER_USAGE  eUsage)

Set the usage for the buffer.


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