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>
Public Types | |
enum | Attachment { Attachment::Color0 = 0, Attachment::DepthStencil = 1 } |
![]() | |
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 | |
CYIAssetFramebuffer () | |
virtual | ~CYIAssetFramebuffer () |
void | EnableAttachment (Attachment attachment) |
void | DisableAttachment (Attachment attachment) |
bool | HasAttachment (Attachment attachment) const |
void | SetDimensions (uint32_t width, uint32_t height) |
void | GetDimensions (uint32_t &rWidth, uint32_t &rHeight) const |
std::shared_ptr< CYIAssetTextureFramebuffer > | GetAttachedTexture (Attachment attachment) const |
virtual bool | RequestInvalidate () override |
virtual bool | RequestRestore () override |
virtual bool | RequestHardwareLoad () override |
virtual bool | RequestHardwareUnload () override |
virtual std::pair< size_t, size_t > | GetApproximateSize () const override |
![]() | |
CYIAssetHardware () | |
virtual | ~CYIAssetHardware () override |
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 | ApplyRetainmentPolicy () |
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) |
virtual void | OnUnload () |
Protected Attributes | |
std::shared_ptr< CYIAssetTextureFramebuffer > | m_pAttachedTextures [s_attachmentTypes] |
bool | m_bufferEnabled [s_attachmentTypes] |
uint32_t | m_width |
uint32_t | m_height |
![]() | |
bool | m_hardwareLoadRequested |
std::shared_ptr< IYIGPUObject > | m_pGPUObject |
RetentionPolicy | m_retentionPolicy |
Static Protected Attributes | |
static const uint32_t | s_attachmentTypes = 2 |
![]() | |
static ssize_t | INVALID_ID |
|
strong |
CYIAssetFramebuffer::CYIAssetFramebuffer | ( | ) |
|
virtual |
|
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.
void CYIAssetFramebuffer::DisableAttachment | ( | Attachment | attachment | ) |
Disables the attachment point for rendering into.
void CYIAssetFramebuffer::EnableAttachment | ( | Attachment | attachment | ) |
Enables the attachment point for rendering into.
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.
std::shared_ptr<CYIAssetTextureFramebuffer> CYIAssetFramebuffer::GetAttachedTexture | ( | Attachment | attachment | ) | 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 | ( | Attachment | attachment | ) | const |
Returns true if the framebuffer has the attachment.
|
overridevirtual |
Will initiate a load request of the software data into video memory.
Reimplemented from CYIAssetHardware.
|
overridevirtual |
Will initiate an unload request from video memory.
Reimplemented from CYIAssetHardware.
|
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.
|
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 | width, |
uint32_t | height | ||
) |
Sets the dimensions of the frame buffer.
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |