You.i Engine
CYIAssetHardware Class Referenceabstract

Detailed Description

Hardware-mirrored asset. These assets contain IYIGPUObject counterparts.

Assets will automatically be marked for loading into video memory when their data setters are called. Users may also manually load and unload them into/from video memory using the CYIAssetHardware::RequestHardwareLoad() and CYIAssetHardware::RequestHardwareUnload() functions.

#include <asset/YiAssetHardware.h>

Inheritance diagram for CYIAssetHardware:

Public Types

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

 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
 
virtual std::pair< uint32_t, uint32_t > GetApproximateSize () 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 =0
 
virtual void ApplyRetainmentPolicy ()
 
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)
 
virtual void OnUnload ()
 
- Protected Member Functions inherited from CYIScriptableRTTIObject
virtual std::pair< const CYIRuntimeTypeInfo *, const void * > GetRuntimeTypeInfoWithObject () const =0
 

Protected Attributes

bool m_bHardwareLoadRequested
 
std::shared_ptr< IYIGPUObjectm_pGPUObject
 
RETENTION_POLICY m_eRetentionPolicy
 

Friends

class CYIGPULoadBufferEvent
 

Additional Inherited Members

- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Member Enumeration Documentation

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.

Note
Please note that this retension mode only affects static assets since dynamic assets are meant to be update on a regular basis.
Warning
The default retention policy varies per platform.
Enumerator
RETAIN 

Indicates that the asset data should be retained on CPU memory after is is uploaded onto GPU memory.

UNLOAD 

Indicate that the asset data should not be retained on CPU memory and unloaded/reclaimed after is is uploaded onto GPU memory.

Constructor & Destructor Documentation

CYIAssetHardware::CYIAssetHardware ( )
virtual CYIAssetHardware::~CYIAssetHardware ( )
virtual

Member Function Documentation

virtual void CYIAssetHardware::ApplyRetainmentPolicy ( )
inlineprotectedvirtual

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 in CYIAssetTextureBase, and CYIAssetBufferObjectData.

virtual std::shared_ptr<IYIGPUObject> CYIAssetHardware::CreateGPUObject ( ) const
protectedpure virtual

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!

Implemented in CYIAssetTextureBase, CYIAssetTextureRaw, CYIAssetBufferObjectData, CYIAssetShaderProgram, CYIAssetFramebuffer, CYIAssetTexture, and CYIAssetTextureFramebuffer.

std::shared_ptr<IYIGPUObject> CYIAssetHardware::GetGPUObject ( ) const

Returns the hardware version of this object, if available, or a null version if the asset is not being managed or if a hardware version is unavailable.

RETENTION_POLICY CYIAssetHardware::GetRetentionPolicy ( ) const

Returns the hardware asset retention policy for this asset.

See also
YI_HW_ASSET_RETENTION_POLICY
bool CYIAssetHardware::IsLoadedOnGPU ( ) const

Helper function that returns true when the asset data has been successfully loaded into video memory. It will return false if the GPUObject hasn't been instantiated by CreateGPUObject(), or if the GPUObject is not in the correct 'loaded' state.

virtual void CYIAssetHardware::OnLoad ( )
overrideprotectedvirtual

Reimplemented from CYIAsset.

virtual bool CYIAssetHardware::Prepare ( )
overridevirtual

Generates the hardware version of this object.

Reimplemented from CYIAsset.

virtual bool CYIAssetHardware::RequestHardwareLoad ( )
virtual

Will initiate a load request of the software data into video memory.

Reimplemented in CYIAssetFramebuffer.

virtual bool CYIAssetHardware::RequestHardwareUnload ( )
virtual

Will initiate an unload request from video memory.

Reimplemented in CYIAssetFramebuffer.

virtual bool CYIAssetHardware::RequestInvalidate ( )
virtual

In the event that the hardware context is lost, this method can be called to invalidate the resource.

Will be called automatically if this asset is registered with the asset manager.

Reimplemented in CYIAssetFramebuffer.

virtual bool CYIAssetHardware::RequestRestore ( )
virtual

In the event that the hardware context is restored, this method can be called to restore the resources after it was invalidated using Invalidate.

Will be called automatically if this asset is registered with the asset manager.

Reimplemented in CYIAssetFramebuffer.

void CYIAssetHardware::SetRetentionPolicy ( RETENTION_POLICY  ePolicy)

Sets the hardware asset retention policy for this asset.

See also
YI_HW_ASSET_RETENTION_POLICY

Friends And Related Function Documentation

friend class CYIGPULoadBufferEvent
friend

Member Data Documentation

bool CYIAssetHardware::m_bHardwareLoadRequested
protected
RETENTION_POLICY CYIAssetHardware::m_eRetentionPolicy
protected
std::shared_ptr<IYIGPUObject> CYIAssetHardware::m_pGPUObject
protected

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