Documentation / scene / HistoryResourceManager
Class: HistoryResourceManager<TTexture>
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:44
Manages cross-frame history resources that can be imported into a render graph.
History resources are textures that persist across frames for temporal effects like TAA, motion blur, or temporal upscaling. Previous-frame textures can be imported into a RenderGraph, and current-frame textures are committed only after graph execution succeeds.
Usage:
const historyMgr = new HistoryResourceManager(allocator);
historyMgr.beginFrame();
const prev = historyMgr.importPrevious(graph, 'taaColor');
// declare builder.read(prev) if non-null
historyMgr.bindImportedTextures(executor);
// after successful execution:
historyMgr.commitFrame();Type Parameters
TTexture
TTexture = Texture2D
The concrete texture type (e.g. Texture2D).
Constructors
Constructor
new HistoryResourceManager<
TTexture>(allocator):HistoryResourceManager<TTexture>
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:57
Create a new history resource manager.
Parameters
allocator
RGTextureAllocator<TTexture>
Texture allocator for creating history textures.
Returns
HistoryResourceManager<TTexture>
Accessors
frameActive
Get Signature
get frameActive():
boolean
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:98
Whether this manager is currently collecting imports/commits for a graph frame.
Returns
boolean
Methods
getPrevious()
getPrevious(
name):TTexture
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:72
Get the previous-frame texture resolved by the current render graph pass.
The resource must have been imported with HistoryResourceManager.importPrevious or HistoryResourceManager.importPreviousIfCompatible, declared as a pass read, and bound with HistoryResourceManager.beginReadScope before this method is called.
Parameters
name
string
Name of the history resource.
Returns
TTexture
The graph-resolved previous-frame texture.
Throws
If no read scope is active for the resource.
tryGetPrevious()
tryGetPrevious(
name):TTexture
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:91
Try to get a previous-frame texture from the current render graph read scope.
Returns null when the resource was not imported for the current pass.
Parameters
name
string
Name of the history resource.
Returns
TTexture
The scoped previous-frame texture, or null.
isCompatible()
isCompatible(
name,desc,size):boolean
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:110
Check whether a valid history resource exists and matches the descriptor.
Parameters
name
string
Name of the history resource.
desc
Expected texture descriptor.
size
Expected resolved size.
Returns
boolean
True if the resource exists, is valid, and matches.
beginFrame()
beginFrame():
void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:118
Start collecting graph imports and deferred commits for a new frame.
Returns
void
importPrevious()
importPrevious(
graph,name):RGHandle
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:134
Import the latest committed texture for a history resource into the graph.
Returns null when the resource has no valid previous frame.
Parameters
graph
Render graph to import into.
name
string
History resource name.
Returns
Imported graph handle, or null when no valid previous texture exists.
importPreviousIfCompatible()
importPreviousIfCompatible(
graph,name,desc,size):RGHandle
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:158
Import the latest committed texture only when it matches the expected shape.
This is the preferred API for effects that can declare their history reads while building the graph: incompatible history is treated as absent, so the pass does not declare stale reads after resize or format changes.
Parameters
graph
Render graph to import into.
name
string
History resource name.
desc
Expected texture descriptor.
size
Expected resolved size.
Returns
Imported graph handle, or null when no compatible history exists.
bindImportedTextures()
bindImportedTextures(
executor):void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:172
Bind all history imports created for this frame to the executor.
Parameters
executor
Pick<RenderGraphExecutor<TTexture>, "setImportedTexture">
Render graph executor for the current frame.
Returns
void
beginReadScope()
beginReadScope(
bindings):void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:183
Make resolved history textures available to code executing inside a pass.
Parameters
bindings
object[]
History name to resolved texture bindings.
Returns
void
endReadScope()
endReadScope():
void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:194
End the most recent history read scope.
Returns
void
queueCommit()
queueCommit(
name,desc,size,texture,ownsTexture?):void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:210
Queue a current-frame texture to become the next previous-frame history.
The texture is committed only when HistoryResourceManager.commitFrame is called. If the frame fails, HistoryResourceManager.discardFrame releases owned pending textures instead.
Parameters
name
string
History resource name.
desc
Texture descriptor.
size
Resolved texture size.
texture
TTexture
Texture produced by the current frame.
ownsTexture?
boolean = true
Whether this manager should release the texture later.
Returns
void
queueCommitFromGraph()
queueCommitFromGraph(
name,desc,size,ctx,handle):TTexture
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:243
Queue a graph-produced texture as a current-frame history write.
The allocator must retain the texture before the graph executor releases its transient reference. Use this from inside the pass that declares access to the handle being committed.
Parameters
name
string
History resource name.
desc
Texture descriptor.
size
Resolved texture size.
ctx
Pick<RGExecuteContext, "getTexture">
Current render graph execute context.
handle
Graph texture handle to commit.
Returns
TTexture
The retained texture.
queueRetainedCommit()
queueRetainedCommit(
name,desc,size,texture):void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:267
Queue a texture after retaining it through the allocator.
Use this for textures produced by the graph allocator. The manager owns the retained reference and releases it when the history slot is overwritten, discarded, or disposed.
Parameters
name
string
History resource name.
desc
Texture descriptor.
size
Resolved texture size.
texture
TTexture
Texture to retain and commit.
Returns
void
commitFrame()
commitFrame():
void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:281
Commit all current-frame history writes.
Returns
void
discardFrame()
discardFrame():
void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:319
Discard all uncommitted frame history writes.
Returns
void
dispose()
dispose():
void
Defined in: libs/scene/src/render/rendergraph/history_resource_manager.ts:336
Release all history resources and clear the manager.
Call this when disposing the render context or when history is no longer needed.
Returns
void