ezEngine Release 26.9
Loading...
Searching...
No Matches
ezRenderGraph Class Reference

#include <RenderGraph.h>

Inheritance diagram for ezRenderGraph:

Public Member Functions

ezGALDeviceGetDevice () const
 
const ezStringGetGraphName () const
 Returns the immutable name assigned at creation.
 
void SetUserName (ezStringView sName)
 Sets the user name that can be changed at any time.
 
const ezStringGetUserName () const
 
void SetUserData (ezReflectedClass *pUserData)
 User data is accessible during execution callbacks via ctx.GetUserData<T>().
 
ezReflectedClassGetUserData () const
 
Transient Resource Creation
ezRenderGraphTextureHandle CreateTexture (const ezGALTextureCreationDescription &desc)
 Create a transient texture. The GPU resource is allocated or aliased from a pool during compilation. There is no need to set any flags on the texture. Whenever a pass operates on a texture its flags are extended to support that operation.
 
ezRenderGraphBufferHandle CreateBuffer (const ezGALBufferCreationDescription &desc)
 Create a transient buffer. The GPU resource is allocated or aliased from a pool during compilation. There is no need to set any flags on the buffer. Whenever a pass operates on a buffer its flags are extended to support that operation.
 
Resource Queries
const ezGALTextureCreationDescriptionGetTextureDesc (ezRenderGraphTextureHandle hTexture) const
 Returns the creation description of a transient or imported texture. Note that this reference is not stable and can become invalid when new textures are added to the graph so it is best to store a copy of the returned value.
 
const ezGALBufferCreationDescriptionGetBufferDesc (ezRenderGraphBufferHandle hBuffer) const
 Returns the creation description of a transient or imported buffer. Note that this reference is not stable and can become invalid when new buffers are added to the graph so it is best to store a copy of the returned value.
 
Import External Resources
ezRenderGraphTextureHandle ImportTexture (ezGALTextureHandle hTexture, ezBitflags< ezGALResourceState > access=ezGALResourceState::Unknown, ezBitflags< ezGALShaderStageFlags > stage=ezGALShaderStageFlags::Auto)
 Import an existing GPU texture into the graph, returning a graph handle so it can be used inside the graph. You can optionally set access and stage to force a barrier on the imported resource at the start of the graph.
 
ezRenderGraphBufferHandle ImportBuffer (ezGALBufferHandle hBuffer, ezBitflags< ezGALResourceState > access=ezGALResourceState::Unknown, ezBitflags< ezGALShaderStageFlags > stage=ezGALShaderStageFlags::Auto)
 Import an existing GPU buffer into the graph, returning a graph handle so it can be used inside the graph. You can optionally set access and stage to force a barrier on the imported resource at the start of the graph.
 
ezStatus ReplaceImportedTexture (ezRenderGraphTextureHandle hGraphTexture, ezGALTextureHandle hNewTexture)
 Use to replace a graph texture with an actual GPU resource. The hNewTexture must not be already imported into the graph. Mainly used when graphs are built greedily and the target swachchain image is not clear at which point it fints into the pipeline. Thus, the graph can be built entirely with transient graph textures and only at the end the replacement can be done. If this call failed the given texture does not fulfil the requirements made to the graph texture.
 
Pass Creation
ezRenderGraphPassBuilder AddGraphicsPass (ezStringView sName)
 Add a graphics pass. Returns a builder through which resource accesses and the execution callback must be declared before compilation.
 
ezRenderGraphPassBuilder AddComputePass (ezStringView sName)
 Add a compute pass.
 
ezRenderGraphPassBuilder AddTransferPass (ezStringView sName)
 Add a transfer pass.
 
void PushMarker (ezStringView sMarker)
 Insert a debug marker that will be pushed during execution at the/ current recording position (before the next pass).
 
void PopMarker ()
 Insert a pop-marker at the current recording position.
 
- Public Member Functions inherited from ezRefCounted
virtual ~ezRefCounted ()=default
 Adds a virtual destructor.
 
- Public Member Functions inherited from ezRefCountingImpl
 ezRefCountingImpl ()=default
 Constructor.
 
 ezRefCountingImpl (const ezRefCountingImpl &rhs)
 
void operator= (const ezRefCountingImpl &rhs)
 
ezInt32 AddRef () const
 Increments the reference counter. Returns the new reference count.
 
ezInt32 ReleaseRef () const
 Decrements the reference counter. Returns the new reference count.
 
bool IsReferenced () const
 Returns true if the reference count is greater than 0, false otherwise.
 
ezInt32 GetRefCount () const
 Returns the current reference count.
 

Compilation & Execution

class ezRenderGraphManager
 
class ezRenderGraphPassBuilder
 
void Reset ()
 Clear all declared passes and resources so the graph can be rebuilt. This is done automatically for enqueued graphs at the end of each frame, but should be called regardless every time you intent to record into the graph.
 
ezResult ValidateImportedResources () const
 Checks that all imported textures and buffers still exist on the device. Call before registering the graph each frame to detect stale resources.
 
ezResult Compile ()
 Compile the graph: cull unused passes, allocate and alias transient resources. After this call, no new passes can be added until the graph is reset.
 
void ComputeBarriers (ezGALResourceStateTracker &ref_tracker, ezArrayPtr< ezRenderGraphPassObserver * > observers={})
 Compute texture and buffer barriers for each pass based on resource state tracking.
 
void Execute (ezRenderGraphContext &ref_ctx, ezArrayPtr< ezRenderGraphPassObserver * > observers={})
 Execute all passes in compiled order.
 

Detailed Description

Render graph usable for a single frame. Contains passes that declare transient resource dependencies. After all passes are added, the graph is compiled to cull unused passes, allocate and alias transient resources, and compute barrier placement, then executed. Passes are always executed in declaration order.

The graph object is designed to persist across the lifetime of the program. Every frame you want to use the graph, call Reset() before re-declaring passes. Note that only one ezRenderGraphPassBuilder can exist at any time so calls to Add*Pass must be scoped individually. Finally, call ezRenderGraphManager::EnqueueRenderGraph to submit the graph for execution this frame.


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