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  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
}
 
- Public Types inherited from CYIAssetHardware
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...
 
- Public Types inherited from CYIAsset
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_tGetApproximateSize () const override
 
virtual void ApplyRetainmentPolicy () override
 
- Public Member Functions inherited from CYIAssetHardware
 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)
 
- 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)
 

Protected Member Functions

virtual std::shared_ptr< IYIGPUObjectCreateGPUObject () const override
 
virtual void OnUnload () 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, PathType pathType)
 
void SetApproximateSize (size_t size)
 
void SetLoaded (bool assetLoaded)
 
void SetLoadParameters (std::unique_ptr< CYIAssetLoadParams > pParams)
 

Additional Inherited Members

- Protected Attributes inherited from CYIAssetHardware
bool m_hardwareLoadRequested
 
std::shared_ptr< IYIGPUObjectm_pGPUObject
 
RetentionPolicy m_retentionPolicy
 
- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Member Enumeration Documentation

◆ BufferType

enum CYIAssetBufferObjectData::BufferType : uint8_t
strong

Creation hints for the buffers

Enumerator
Vertex 

A vertex buffer object

Index 

An index buffer object

◆ BufferUsage

Buffer usage mode.

Enumerator
Static 

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

Dynamic 

Hint indicating that the buffer can be dynamically updated.

◆ IndexType

enum CYIAssetBufferObjectData::IndexType : uint8_t
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.

Constructor & Destructor Documentation

◆ CYIAssetBufferObjectData() [1/2]

CYIAssetBufferObjectData::CYIAssetBufferObjectData ( )

◆ CYIAssetBufferObjectData() [2/2]

CYIAssetBufferObjectData::CYIAssetBufferObjectData ( const CYIString path,
PathType  pathType = PathType::Relative 
)

◆ ~CYIAssetBufferObjectData()

virtual CYIAssetBufferObjectData::~CYIAssetBufferObjectData ( )
overridevirtual

Member Function Documentation

◆ ApplyRetainmentPolicy()

virtual void CYIAssetBufferObjectData::ApplyRetainmentPolicy ( )
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.

See also
SetRetentionPolicy
GetRetentionPolicy

Reimplemented from CYIAssetHardware.

◆ CreateGPUObject()

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.

◆ GetApproximateSize()

virtual std::pair<size_t, size_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.

◆ GetData()

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.

◆ GetIndexLoopingIndexCount()

uint8_t CYIAssetBufferObjectData::GetIndexLoopingIndexCount ( ) const

Get the number of indices after which index looping should occur.

Note
This is only applicable if the type of the buffer is BufferType::Index and if the index type is IndexType::UnsignedShortLooping

◆ GetIndexLoopingVertexCount()

uint8_t CYIAssetBufferObjectData::GetIndexLoopingVertexCount ( ) const

Get the number of vertices to skip when looping indices.

Note
This is only applicable if the type of the buffer is BufferType::Index and if the index type is IndexType::UnsignedShortLooping

◆ GetIndexType()

IndexType CYIAssetBufferObjectData::GetIndexType ( ) const

Gets the the data type of vertex indices stored in this data buffer.

Note
This is only applicable if the type of the buffer is BufferType::Index

◆ GetSizeInBytes()

size_t CYIAssetBufferObjectData::GetSizeInBytes ( ) const

Get the size of the buffer in bytes

◆ GetType()

BufferType CYIAssetBufferObjectData::GetType ( ) const

Get the type of buffer data this represents.

◆ GetUsage()

BufferUsage CYIAssetBufferObjectData::GetUsage ( ) const

Get the buffer usage

◆ OnUnload()

virtual void CYIAssetBufferObjectData::OnUnload ( )
overrideprotectedvirtual

Reimplemented from CYIAsset.

◆ Resize()

void CYIAssetBufferObjectData::Resize ( size_t  numOfElements,
size_t  sizeOfElement 
)

Allocates memory in internal structure of the object based on the provided number of elements and the provided size of elements.

◆ SetData() [1/2]

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

◆ SetData() [2/2]

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.

◆ SetIndexLoopingCounts()

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.

Note
This is only applicable if the type of the buffer is BufferType::Index and if the index type is IndexType::UnsignedShortLooping

◆ SetIndexType()

void CYIAssetBufferObjectData::SetIndexType ( IndexType  indexType)

Set the the data type of vertex indices stored in this data buffer.

Note
This is only applicable if the type of the buffer is BufferType::Index

◆ SetType()

void CYIAssetBufferObjectData::SetType ( BufferType  type)

Set the type of buffer data this represents.

◆ SetUsage()

void CYIAssetBufferObjectData::SetUsage ( BufferUsage  usage)

Set the usage for the buffer.


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