Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RHI::FrameGraph Class Referencefinal

#include <FrameGraph.h>

Public Member Functions

 AZ_CLASS_ALLOCATOR (FrameGraph, AZ::SystemAllocator)
 
bool IsCompiled () const
 Returns whether the graph has been compiled.
 
bool IsBuilding () const
 Returns whether the graph is currently being built.
 
size_t GetFrameCount () const
 Returns number of frame cycles completed since initialization.
 
void Begin ()
 Begins the building phase.
 
void BeginScope (Scope &scope)
 
ResultCode UseAttachment (const BufferScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage)
 
ResultCode UseAttachment (const ImageScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access, ScopeAttachmentUsage usage)
 
ResultCode UseAttachments (AZStd::span< const ImageScopeAttachmentDescriptor > descriptors, ScopeAttachmentAccess access, ScopeAttachmentUsage usage)
 
ResultCode UseResolveAttachment (const ResolveScopeAttachmentDescriptor &descriptor)
 
ResultCode UseColorAttachments (AZStd::span< const ImageScopeAttachmentDescriptor > descriptors)
 
ResultCode UseDepthStencilAttachment (const ImageScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access)
 
ResultCode UseSubpassInputAttachments (AZStd::span< const ImageScopeAttachmentDescriptor > descriptors)
 
ResultCode UseShaderAttachment (const BufferScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access)
 
ResultCode UseShaderAttachment (const ImageScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access)
 
ResultCode UseCopyAttachment (const BufferScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access)
 
ResultCode UseCopyAttachment (const ImageScopeAttachmentDescriptor &descriptor, ScopeAttachmentAccess access)
 
ResultCode UseQueryPool (Ptr< QueryPool > queryPool, const RHI::Interval &interval, QueryPoolScopeAttachmentType type, ScopeAttachmentAccess access)
 
void ExecuteAfter (const ScopeId &scopeId)
 
void ExecuteBefore (const ScopeId &scopeId)
 
void SignalFence (Fence &fence)
 
void SetEstimatedItemCount (uint32_t itemCount)
 
void SetHardwareQueueClass (HardwareQueueClass hardwareQueueClass)
 
ResultCode UseColorAttachment (const ImageScopeAttachmentDescriptor &descriptor)
 Declares a single color attachment for use on the current scope.

 
ResultCode UseSubpassInputAttachment (const ImageScopeAttachmentDescriptor &descriptor)
 
void EndScope ()
 Ends building of the current scope.
 
ResultCode End ()
 Ends the building phase of the graph.
 
void Clear ()
 Clears the graph to an empty state.
 
const FrameGraphAttachmentDatabaseGetAttachmentDatabase () const
 Returns the attachment database.
 
FrameGraphAttachmentDatabaseGetAttachmentDatabase ()
 
ScopeGetRootScope () const
 Returns the root scope (which is always the first in the list).
 
const AZStd::vector< Scope * > & GetScopes () const
 Returns the topologically sorted list of scopes.
 
const AZStd::vector< Scope * > & GetConsumers (const Scope &producer) const
 Returns the list of consumers for the provided producer scope.
 
const AZStd::vector< Scope * > & GetProducers (const Scope &consumer) const
 Returns the list of producers for the provided consumer scope.
 
ScopeFindScope (const ScopeId &scopeId)
 Returns the scope associated with.
 
const ScopeFindScope (const ScopeId &scopeId) const
 

Friends

class FrameGraphCompiler
 

Detailed Description

The frame graph is a graph of scopes, where edges are derived from attachment usage. It can be visualized as a sparse 2D grid. The first axis is a flat array of all attachments, and the second axis is a flat array of all the scopes in dependency-sorted order. A scope attachment exists when a frame graph attachment is attached to a specific scope. As a result, each frame graph attachment builds a doubly linked list of scope attachments, where the head of the list is the first scope attachment on the first scope, and the tail is the last scope attachment on the last scope. It's possible then to derive lifetimes of each attachment by inspecting the head and tail of this list, or to traverse the "usage" chain by walking the linked list.

EXAMPLE:

[Legend] ATTACHMENTS: Uppercase Letters. SCOPES: Numbers.

            0            1           2           3           4            5           6

A [Color -> ImageRead] B [BufferWrite -> BufferRead] C [DepthWrite-> DepthRead-> DepthRead-> DepthRead-> DepthRead] D [Color -> ImageRead] E [ImageWrite-> ImageRead-> ImageRead]

Lifetimes: A: [0, 1] B: [1, 3] C: [0, 4] D: [2, 3] E: [4, 6]

In this example, (A-E) are frame graph attachments, and (0-6) are scopes. The entries in the grid are scope attachments where a particular frame graph attachment has been attached to a scope with a specific usage.

The graph allows you to walk the sparse grid as a linked list: 1) You can traverse each "usage" of an attachment, from the first to the last scope (left / right). 2) You can traverse the list of attachments in a scope (up / down). 3) You can traverse the list of attachments matching the same type in a scope (up / down).

Member Function Documentation

◆ BeginScope()

void AZ::RHI::FrameGraph::BeginScope ( Scope scope)

Begins building a new scope instance associated with scope. The FrameGraphInterface API is used to construct the scope, and is only valid within the context of these calls.

◆ FindScope()

Scope * AZ::RHI::FrameGraph::FindScope ( const ScopeId &  scopeId)

Returns the scope associated with.

Parameters
scopeId

◆ UseSubpassInputAttachment()

ResultCode AZ::RHI::FrameGraph::UseSubpassInputAttachment ( const ImageScopeAttachmentDescriptor descriptor)
inline

Declares a single subpass input attachment for use on the current scope. Subpass input attachments are image views that can be used for pixel local load operations inside a fragment shader. This means that framebuffer attachments written in one subpass can be read from at the exact same pixel in subsequent subpasses. Certain platform have optimization for this type of attachments.


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