You.i Engine
CYIAssetFramebuffer Class Reference

Detailed Description

Wraps CYIAssetBuffers and their hardware counterparts, and an internally managed FBO.

A framebuffer is a tool used for off-screen rendering. Textures are attached to various attachment points, corresponding to display buffers (such as color and depth). When the FBO is bound as a render target, these textures will be populated with the corresponding data. They can subsequently be used just as normal textures, for rendering to the screen or for shader effects.

#include <asset/YiAssetFramebuffer.h>

Inheritance diagram for CYIAssetFramebuffer:

Public Types

enum  YI_ATTACHMENT {
  YI_COLOR_ATTACHMENT0 = 0,
  YI_DEPTHSTENCIL_ATTACHMENT = 1
}
 
- 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

 CYIAssetFramebuffer ()
 
virtual ~CYIAssetFramebuffer ()
 
void EnableAttachment (YI_ATTACHMENT eAttachment)
 
void DisableAttachment (YI_ATTACHMENT eAttachment)
 
bool HasAttachment (YI_ATTACHMENT eAttachment) const
 
void SetDimensions (uint32_t uWidth, uint32_t uHeight)
 
void GetDimensions (uint32_t &rWidth, uint32_t &rHeight) const
 
std::shared_ptr< CYIAssetTextureFramebufferGetAttachedTexture (YI_ATTACHMENT eAttachment) const
 
virtual bool RequestInvalidate () override
 
virtual bool RequestRestore () override
 
virtual bool RequestHardwareLoad () override
 
virtual bool RequestHardwareUnload () override
 
virtual std::pair< uint32_t, uint32_t > GetApproximateSize () const override
 
- Public Member Functions inherited from CYIAssetHardware
 CYIAssetHardware ()
 
virtual ~CYIAssetHardware ()
 
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
 
- Protected Member Functions inherited from CYIAssetHardware
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

std::shared_ptr< CYIAssetTextureFramebufferm_pAttachedTextures [s_uAttachmentTypes]
 
bool m_bufferEnabled [s_uAttachmentTypes]
 
uint32_t m_uWidth
 
uint32_t m_uHeight
 
- Protected Attributes inherited from CYIAssetHardware
bool m_bHardwareLoadRequested
 
std::shared_ptr< IYIGPUObjectm_pGPUObject
 
RETENTION_POLICY m_eRetentionPolicy
 

Static Protected Attributes

static const uint32_t s_uAttachmentTypes = 2
 
- Static Protected Attributes inherited from CYIAsset
static ssize_t INVALID_ID
 

Member Enumeration Documentation

Enumerator
YI_COLOR_ATTACHMENT0 
YI_DEPTHSTENCIL_ATTACHMENT 

Constructor & Destructor Documentation

CYIAssetFramebuffer::CYIAssetFramebuffer ( )
virtual CYIAssetFramebuffer::~CYIAssetFramebuffer ( )
virtual

Member Function Documentation

virtual std::shared_ptr<IYIGPUObject> CYIAssetFramebuffer::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.

void CYIAssetFramebuffer::DisableAttachment ( YI_ATTACHMENT  eAttachment)

Disables the attachment point for rendering into.

void CYIAssetFramebuffer::EnableAttachment ( YI_ATTACHMENT  eAttachment)

Enables the attachment point for rendering into.

virtual std::pair<uint32_t, uint32_t> CYIAssetFramebuffer::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.

std::shared_ptr<CYIAssetTextureFramebuffer> CYIAssetFramebuffer::GetAttachedTexture ( YI_ATTACHMENT  eAttachment) const

Returns the buffer associated with the attachment point.

void CYIAssetFramebuffer::GetDimensions ( uint32_t &  rWidth,
uint32_t &  rHeight 
) const

Returns the dimensions of the frame buffer.

bool CYIAssetFramebuffer::HasAttachment ( YI_ATTACHMENT  eAttachment) const

Returns true if the framebuffer has the eAttachment.

virtual bool CYIAssetFramebuffer::RequestHardwareLoad ( )
overridevirtual

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

Reimplemented from CYIAssetHardware.

virtual bool CYIAssetFramebuffer::RequestHardwareUnload ( )
overridevirtual

Will initiate an unload request from video memory.

Reimplemented from CYIAssetHardware.

virtual bool CYIAssetFramebuffer::RequestInvalidate ( )
overridevirtual

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 from CYIAssetHardware.

virtual bool CYIAssetFramebuffer::RequestRestore ( )
overridevirtual

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 from CYIAssetHardware.

void CYIAssetFramebuffer::SetDimensions ( uint32_t  uWidth,
uint32_t  uHeight 
)

Sets the dimensions of the frame buffer.

Member Data Documentation

bool CYIAssetFramebuffer::m_bufferEnabled[s_uAttachmentTypes]
protected
std::shared_ptr<CYIAssetTextureFramebuffer> CYIAssetFramebuffer::m_pAttachedTextures[s_uAttachmentTypes]
protected
uint32_t CYIAssetFramebuffer::m_uHeight
protected
uint32_t CYIAssetFramebuffer::m_uWidth
protected
const uint32_t CYIAssetFramebuffer::s_uAttachmentTypes = 2
staticprotected

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