Table of Contents

Class FrameGraphBuilder

Namespace
BSGameLib.Game.Rendering
Assembly
BSGameLib.Game.dll

Collects passes and resources for a single frame's render dependency graph, then resolves them into an ordered FrameGraph via Build().

public sealed class FrameGraphBuilder
Inheritance
FrameGraphBuilder
Inherited Members
Extension Methods

Remarks

Typical usage inside ConfigureRenderGraph(FrameGraphBuilder, IGameTime):

var scenePass = builder.AddPass("MyGame.Scene")
  .Renders(new RenderPassDescriptor { ClearColorBuffer = true, ClearColor = Color.CornflowerBlue })
  .Execute(ctx => DrawScene());

AddDefaultRenderGraphPass(builder, gameTime, dependsOn: scenePass);

Most single-pass games never need to call AddPass(string) directly at all — see ConfigureRenderGraph(FrameGraphBuilder, IGameTime) and Draw(IGameTime) for when a custom pass is actually necessary versus overkill.

Properties

HasPasses

True once at least one pass has been added via AddPass(string).

public bool HasPasses { get; }

Property Value

bool

ValidationMode

Controls how strictly Build() checks the graph for mistakes (unused resources, passes with no declared dependencies or resource usage). Defaults to Disabled; Game sets this to Full in DEBUG builds automatically.

public FrameGraphValidationMode ValidationMode { get; set; }

Property Value

FrameGraphValidationMode

Methods

AddPass(string)

Starts a new pass. Configure it by chaining the returned builder's methods — Renders(RenderPassDescriptor), Reads(FrameGraphResourceHandle), Writes(FrameGraphResourceHandle), DependsOn(FrameGraphPassHandle) — in any order, then finish with Execute(Action<FrameGraphPassContext>), which is the only call that returns a usable FrameGraphPassHandle. A pass with no Execute call fails at Build() time rather than silently doing nothing.

public FrameGraphBuilder.FrameGraphPassBuilder AddPass(string name)

Parameters

name string

A short, unique-enough-to-debug-with label (e.g. "MyGame.Scene").

Returns

FrameGraphBuilder.FrameGraphPassBuilder

Build()

Resolves every declared pass/resource into an ordered FrameGraph: validates every pass has an Execute(Action<FrameGraphPassContext>) delegate, infers pass ordering from resource reads/writes plus any explicit DependsOn(FrameGraphPassHandle) calls, and computes when each transient resource can be released. Called once per frame by Game; you don't need to call this yourself inside ConfigureRenderGraph(FrameGraphBuilder, IGameTime).

public FrameGraph Build()

Returns

FrameGraph

CreateTransient(string, FrameGraphResourceDescriptor)

Declares a resource (e.g. an offscreen render target) that lives only for this frame's graph — allocated on first write, released automatically after its last read/write unless a pass calls Releases(FrameGraphResourceHandle) explicitly. Use this for intermediate results (scene color for post-processing, a shadow map), not the main back buffer.

public FrameGraphResourceHandle CreateTransient(string name, FrameGraphResourceDescriptor descriptor)

Parameters

name string
descriptor FrameGraphResourceDescriptor

Returns

FrameGraphResourceHandle

ImportResource(string, FrameGraphResourceDescriptor)

Declares a resource this graph reads/writes but does not own the lifetime of (e.g. a render target the caller allocated and will use again after this frame). Unlike CreateTransient(string, FrameGraphResourceDescriptor), imported resources are never auto-released by the graph.

public FrameGraphResourceHandle ImportResource(string name, FrameGraphResourceDescriptor descriptor)

Parameters

name string
descriptor FrameGraphResourceDescriptor

Returns

FrameGraphResourceHandle