Skip to content

Class ReloadablePipelines<T>

Namespace: Apogee.Rendering.Shaders
Assembly: Apogee.Rendering.dll

The pipelines a renderer builds from some shader modules, rebuilt when one of them changes (or a module it imports) without stalling the frame. A change starts a build on another thread: the shaders are compiled through the and the pipelines made, while the renderer carries on with . The renderer calls at the start of a frame; if a build has finished, the new pipelines become current there, and the old ones are destroyed through once the GPU is done with the frames that used them. A build that fails (a shader that does not compile) leaves as it was, is logged, and shows in until a later build works. Changes that arrive during a build start another one right after it.

public sealed class ReloadablePipelines<T> : IDisposable where T : class

Type Parameters

T

What the renderer uses: the pipelines, however it arranges them.

Inheritance

object ← ReloadablePipelines<T>

Implements

IDisposable

Inherited Members

object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.ReferenceEquals(object?, object?), object.ToString()

Constructors

ReloadablePipelines(ShaderLibrary, string, IReadOnlyList<string>, Func<PipelineScope, T>)

public ReloadablePipelines(ShaderLibrary library, string name, IReadOnlyList<string> modules, Func<PipelineScope, T> build)

Parameters

library ShaderLibrary

Where the modules are loaded from, and which says when they change.

name string

Names the group in logs and in .

modules IReadOnlyList<string>

The modules this group is built from (shaders://forward.slang); a change to one of them, or to a file it imports, rebuilds the group.

build Func<PipelineScope, T>

Makes the pipelines, adding each to the scope it is given as soon as it is made. It runs on the calling thread now, and on another one for rebuilds.

Properties

Current

What to render with now.

public T Current { get; }

Property Value

T

Rebuilds

How many rebuilds have replaced the first build.

public int Rebuilds { get; }

Property Value

int

Methods

Apply(Frame)

Call at the start of a frame, on the render thread: if a rebuild has finished, makes it current and defers destroying the old pipelines to frame. Returns true if it did.

public bool Apply(Frame frame)

Parameters

frame Frame

Returns

bool

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Invalidate()

Starts a rebuild without waiting for a change (tests, or a renderer whose options changed).

public void Invalidate()

WaitForPending()

Waits until the build in progress, and the ones that followed it, are done (tests).

public void WaitForPending()