XII Release 0.1.0
Loading...
Searching...
No Matches
xiiRenderGraph Class Reference

#include <RenderGraph.h>

Public Member Functions

 xiiRenderGraph (xiiStringView sName="RenderGraph")
void BeginSetup (xiiUInt64 uiFrameIndex)
xiiUInt64 GetFrameIndex () const
xiiUInt64 GetSetupSerial () const
template<typename TPassData>
std::pair< TPassData *, xiiRenderGraphPassHandle > AddPass (xiiStringView sName, xiiBitflags< xiiGALCommandQueueFlags > queueFlags, xiiDelegate< void(TPassData &, xiiRenderGraphBuilder &)> setupDelegate, xiiDelegate< void(const TPassData &, xiiRenderGraphPassContext &)> executeDelegate, bool bHasSideEffects=false)
void EndSetup ()
 Finalizes the setup phase. Must be called after all AddPass calls.
void SetSetupBinding (xiiStringView name, xiiRenderGraphTextureHandle texture)
void SetSetupBinding (xiiStringView name, xiiRenderGraphBufferHandle buffer)
void ClearSetupBindings ()
void SetResourceNamespace (xiiStringView name)
xiiStringView GetResourceNamespace () const
void SetSetupBlackboard (xiiRenderGraphBlackboard *blackboard)
xiiRenderGraphBlackboard * GetSetupBlackboard () const
xiiRenderGraphTextureHandle FindTexture (xiiStringView name) const
xiiRenderGraphBufferHandle FindBuffer (xiiStringView name) const
const xiiGALTextureCreationDescription * GetTextureDescription (xiiRenderGraphTextureHandle texture) const
 Setup-time descriptions. Invalid handles and mismatched resource identities return null.
const xiiGALBufferCreationDescription * GetBufferDescription (xiiRenderGraphBufferHandle buffer) const
xiiResult Compile (const xiiRenderGraphCompileSettings &settings={}, xiiStringBuilder *out_pError=nullptr)
xiiResult Execute (xiiGALDevice *pDevice, const xiiView *pView, xiiRenderGraphBlackboard *pBlackboard, xiiRenderGraphResourceCache *pResourceCache, xiiRenderGraphProfiler *pProfiler=nullptr, xiiStringBuilder *out_pError=nullptr)
const xiiRenderGraphStatistics & GetStatistics () const
 Returns the graph's compile-time statistics, populated after Compile() and useful for diagnostics.
xiiArrayPtr< const xiiRenderGraphCompiledPass > GetCompiledPasses () const
 Returns the list of compiled passes, in execution order, with all metadata needed for execution and profiling.
xiiArrayPtr< const xiiRenderGraphBarrierDescription > GetBarriers () const
 Returns the list of resource barriers synthesized by the compiler, in the order they are emitted during execution.
xiiArrayPtr< const xiiRenderGraphMergeGroup > GetMergeGroups () const
 Returns the list of render pass merge groups synthesized by the compiler.
xiiArrayPtr< const xiiRenderGraphQueueSubmission > GetQueueSubmissions () const
 Returns the list of queue submissions synthesized by the compiler, in execution order.
xiiRenderGraphId GetId () const
 Process-local ID and name of this graph instance.
xiiUInt64 GetInstanceId () const
 Process-local identity, unique even when several views use the same stable graph name.
xiiStringView GetName () const
xiiArrayPtr< const xiiRenderGraphResourceDescription > GetResourceDescriptions () const
 Reflection/editor-friendly compiler records.
xiiArrayPtr< const xiiRenderGraphResourceVersionDescription > GetResourceVersions () const
xiiSharedPtr< xiiGALTexture > GetExportedTexture (xiiRenderGraphTextureHandle hTexture) const
 Returns a strong reference to an exported graph-owned result after Execute().
xiiSharedPtr< xiiGALBuffer > GetExportedBuffer (xiiRenderGraphBufferHandle hBuffer) const
xiiResult DumpToDot (xiiStringBuilder &out_sDot) const
 Serializes the compiled graph to a DOT string for Graphviz visualization.
bool IsCompiled () const
 True if the graph has been compiled and not yet invalidated.

Friends

class xiiRenderGraphBuilder

Detailed Description

Advanced high-performance render graph.

Usage per frame

graph.BeginSetup(uiFrameIndex);
auto [pData, hPass] = graph.AddPass<MyPassData>(
"DepthPrepass",
[](MyPassData& data, xiiRenderGraphBuilder& builder)
{
data.hDepth = builder.WriteTexture("SceneDepth", depthTextureDescription, xiiGALResourceStateFlags::DepthWrite);
},
[](const MyPassData& data, xiiRenderGraphPassContext& context)
{
context.GetCommandList().ClearDepthStencilView(...);
},
/*bHasSideEffects=*/false
);
pData->uiDrawCount = scene.GetDrawCount();
graph.EndSetup();
if (graph.Compile(settings).Succeeded())
{
graph.Execute(pDevice, pView, pBlackboard, pCache, pProfiler);
}
Definition RenderGraph.h:284
@ Graphics
Command queue that supports graphics, compute, ray tracing and transfer commands.
Definition GraphicsTypes.h:1224
@ DepthWrite
The resource is used in a writable depth-stencil view or in clear operation.
Definition GraphicsTypes.h:1815

Threading

  • BeginSetup / AddPass / EndSetup: single-threaded (main thread).
  • Compile: single-threaded.
  • Execute: command list recording per pass is sequential per queue. Queues run genuinely in parallel on the GPU side.
  • Pass execute callbacks may safely call xiiRenderGraphBlackboard::TryGet concurrently.

Member Function Documentation

◆ AddPass()

template<typename TPassData>
std::pair< TPassData *, xiiRenderGraphPassHandle > xiiRenderGraph::AddPass ( xiiStringView sName,
xiiBitflags< xiiGALCommandQueueFlags > queueFlags,
xiiDelegate< void(TPassData &, xiiRenderGraphBuilder &)> setupDelegate,
xiiDelegate< void(const TPassData &, xiiRenderGraphPassContext &)> executeDelegate,
bool bHasSideEffects = false )

Registers a typed pass and immediately invokes its setup callback.

Template Parameters
TPassData- Plain data struct holding per-frame data and resource handles. Must be default-constructible. Lifetime is managed by the graph.
Parameters
sName- Unique name used for debugging, profiling, and the compile cache.
queueFlags- Target queue (Graphics / Compute / Transfer).
setupFunc- Called immediately to declare resource usage via xiiRenderGraphBuilder.
executeFunc- Called during Execute() to record GPU commands.
bHasSideEffects- If true, this pass is never culled even if no pass reads its outputs.
Returns
A pair of (raw pointer to TPassData, pass handle). The pointer is stable for the lifetime of this frame's graph.

◆ BeginSetup()

void xiiRenderGraph::BeginSetup ( xiiUInt64 uiFrameIndex)

Begins graph setup for the given frame index. Clears all pass registrations and resource declarations from the previous frame.

◆ Compile()

xiiResult xiiRenderGraph::Compile ( const xiiRenderGraphCompileSettings & settings = {},
xiiStringBuilder * out_pError = nullptr )

Compiles the render graph.

Runs all 7 compiler phases: A. Resource versioning (already completed during AddPass setup callbacks). B. Topological sort + live-pass culling. C. Transient resource lifetime analysis. D. Advanced barrier synthesis (sub-resource, UAV, split barriers). E. Multi-queue scheduling -> xiiRenderGraphQueueSubmission list with fence handshakes. F. Render pass group merging -> xiiRenderGraphMergeGroup list. G. Signature hash + compile cache (skip if graph is unchanged).

Parameters
settings- Optional compile configuration.
out_pError- Optional diagnostics string populated on XII_FAILURE.
Returns
XII_SUCCESS on success, XII_FAILURE if a cycle or invalid state is detected.

◆ Execute()

xiiResult xiiRenderGraph::Execute ( xiiGALDevice * pDevice,
const xiiView * pView,
xiiRenderGraphBlackboard * pBlackboard,
xiiRenderGraphResourceCache * pResourceCache,
xiiRenderGraphProfiler * pProfiler = nullptr,
xiiStringBuilder * out_pError = nullptr )

Executes the compiled render graph.

For each xiiRenderGraphQueueSubmission:

  1. Acquires the xiiGALCommandQueue via pDevice->GetCommandQueue(queueFlags).
  2. Creates / resets a command list for that queue.
  3. Emits DeviceWaitForFence calls for cross-queue dependencies.
  4. Acquires transient resources from pResourceCache.
  5. Emits pre-barriers (split-bar ends + immediates).
  6. Opens a render pass group if the pass starts a merge group.
  7. Calls pProfiler->OnPassBegin (if non-null).
  8. Calls the pass execute callback.
  9. Calls pProfiler->OnPassEnd (if non-null).

Closes the render pass group if the pass ends a merge group.

  1. Emits post-barrier-begins (split-bar starts for downstream consumers).
  2. Returns transient resources whose lifetime ends at this pass.
  3. EnqueueSignals the cross-queue fence for downstream submissions.
  4. Submits the command list.
Parameters
pDevice- Target GAL device (must remain valid for the call duration).
pView- Optional view providing camera / viewport data to passes.
pBlackboard- Per-frame data exchange store.
pResourceCache- Transient resource pool for this frame.
pProfiler- Optional GPU timing profiler.
out_pError- Optional diagnostics output.
Returns
XII_SUCCESS on success. Failure may follow partial GPU submission. A valid recorded prefix is submitted to preserve tracked resource states; callers must invalidate temporal state and retain frame resources until the submitted work completes, including on failure.

◆ GetFrameIndex()

xiiUInt64 xiiRenderGraph::GetFrameIndex ( ) const
inlinenodiscard

Full frame identity supplied to BeginSetup, available during pass construction as well as execution. Use this for frame-scoped subsystem state instead of truncated blackboard values.

◆ SetResourceNamespace()

void xiiRenderGraph::SetResourceNamespace ( xiiStringView name)
inline

Namespace for named setup resources in one expanded subgraph occurrence. Handle-based boundary connections cross namespaces explicitly. Restore the previous scope after Build.

◆ SetSetupBinding()

void xiiRenderGraph::SetSetupBinding ( xiiStringView name,
xiiRenderGraphTextureHandle texture )

Named-resource bridge for resource-defined pipeline passes. Bindings are scoped to setup; handle-based pass code remains the preferred interface. Clear before leaving the scope.


The documentation for this class was generated from the following files:
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Pipeline/RenderGraph.h
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Pipeline/Implementation/RenderGraph.cpp
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Pipeline/Implementation/RenderGraph_inl.h
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Pipeline/Implementation/RenderGraphPipelineBindings.cpp
  • /home/runner/work/XII/XII/Source/Engine/GraphicsCore/Pipeline/Implementation/RenderGraphTopologyCache.cpp