![]() |
XII Release 0.1.0
|
Copyright (c) Theophilus Eriata. All Rights Reserved. More...
#include <RenderGraphResourceCache.h>
Public Member Functions | |
| xiiRenderGraphResourceCache (xiiSharedPtr< xiiGALDevice > pDevice) | |
| Copyright (c) Theophilus Eriata. All Rights Reserved. | |
| void | BeginFrame (xiiUInt64 uiFrameIndex) |
| void | BeginFrame (xiiUInt64 uiFrameIndex, xiiUInt64 uiCompletedFrameIndex) |
| void | EndFrame () |
| Called once at the end of a frame after Execute(). Returns all active resources to the pool. | |
| xiiSharedPtr< xiiGALTexture > | AcquireTexture (const xiiGALTextureCreationDescription &description) |
| void | ReturnTexture (xiiSharedPtr< xiiGALTexture > pTexture) |
| Returns a texture to the pool for potential reuse in subsequent frames. | |
| xiiSharedPtr< xiiGALBuffer > | AcquireBuffer (const xiiGALBufferCreationDescription &description) |
| void | ReturnBuffer (xiiSharedPtr< xiiGALBuffer > pBuffer) |
| Returns a buffer to the pool for potential reuse in subsequent frames. | |
| void | ReleaseStaleResources (xiiUInt32 uiMinAgeFrames=4U) |
| xiiUInt32 | GetActiveResourceCount () const |
| Returns the number of resources currently acquired (not yet returned this frame). | |
| xiiUInt32 | GetPooledResourceCount () const |
| Returns the number of resources sitting idle in the pool. | |
Copyright (c) Theophilus Eriata. All Rights Reserved.
Frame-scoped GPU resource pool dedicated to the render graph's transient resource needs.
Transient resources are GPU textures and buffers that are created for a single frame, used by one or more render graph passes, and then returned to the pool for reuse in subsequent frames. The cache uses the resource creation description hash as a key, so resources with identical descriptions are reused without re-allocation.
AcquireTexture, ReturnTexture, AcquireBuffer, ReturnBuffer are all protected by an internal mutex and are safe to call concurrently from parallel pass execution threads.
BeginFrame() evicts completed pooled resources unused for at least four frames. This bounds retention when viewport dimensions or upload sizes change continuously. ReleaseStaleResources() can additionally trim idle resources; it never releases active or GPU-in-flight resources.
|
nodiscard |
Returns a buffer matching the given description, creating one if no pool entry exists. Returns null if allocation fails or the cache is uninitialized. The caller must handle failure.
|
nodiscard |
Returns a texture matching the given description, creating one if no pool entry exists. Returns null if allocation fails or the cache is uninitialized. The caller must handle failure.
| void xiiRenderGraphResourceCache::BeginFrame | ( | xiiUInt64 | uiFrameIndex | ) |
Called once at the start of a frame before Execute(). Uses a conservative three-frame retirement window for callers that do not expose an exact completed-frame index.
| void xiiRenderGraphResourceCache::BeginFrame | ( | xiiUInt64 | uiFrameIndex, |
| xiiUInt64 | uiCompletedFrameIndex ) |
Starts a frame, promotes resources whose last GPU frame is known to be complete, and evicts idle allocations unused for at least four frames. This overload is preferred by render loops with explicit frame fences.
| void xiiRenderGraphResourceCache::ReleaseStaleResources | ( | xiiUInt32 | uiMinAgeFrames = 4U | ) |
Destroys pooled resources that have not been acquired for more than uiMinAgeFrames frames.
| uiMinAgeFrames | Resources unused for at least this many frames are released. Default is 4. |