Vixen
02b45cc4
csharp
public abstract class PostEffectRenderer

One post-process effect: a shader, the textures it reads, and the target it writes.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Every effect in this project is one of these, and almost none of them is more. The work a post pass does — three vertices, one draw, a descriptor set of source textures and a uniform block — is FullScreenRenderer's already; what an effect adds is which shader, which permutations, which textures go on which bindings, and its own parameters. So this holds the plumbing and a subclass answers four questions.

The node declares its own output. An effect that read a target somebody else had to remember to declare would be an effect you cannot drop into a chain — and the graph's whole argument is that a pass nothing reads costs nothing, which only works if the resource it writes is the graph's to alias and drop.

The pass is kept between frames. It owns a pipeline cache and a uniform buffer, so rebuilding it every frame would recompile the same pipeline and reallocate the same buffer — most of what a post chain can get wrong, and invisible until a profile.

Fields and properties (8)

  • public string Output

    The name this effect publishes its result under.

  • public PixelFormat Format

    The format of the target it declares.

  • public EffectPipelineDescriber? Modules

    Where shader modules come from. Set before the first frame that builds.

  • public SamplerCache? Samplers

    Where samplers come from, shared so a chain does not exhaust the device's supply.

  • public DescriptorAllocator? Allocator

    Where the pass's descriptor sets come from.

  • public IGraphicsDevice? Device

    The device its pipelines and its uniform block are created on.

  • public FullScreenRenderer Pass

    The pass this effect is, for a host that wants to look at what it did.

  • public SceneConstants? SceneConstants

    The frame's set 0, for an effect whose shader declares anything per-frame.

Methods (11)

  • protected PostEffectRenderer(string shaderName, IReadOnlyList<ParameterKey> permutationKeys, uint constantBinding)

    Creates the node for one shader.

  • protected virtual Int2 TargetSize(Int2 frame)

    The size the effect's own target is, given the frame's.

  • protected abstract void Configure(CompositorFrame frame, ParameterCollection parameters, IList<ResourceBinding> bindings)

    Fills in this frame's parameters and bindings.

  • protected void Read(IList<ResourceBinding> bindings, uint binding, string resource)

    Adds a sampled texture to the pass, and records that it is read.

  • protected void ReadBuffer(IList<ResourceBinding> bindings, uint binding, string resource)

    Adds a storage buffer to the pass, and records that it is read.

  • protected static void Sample(IList<ResourceBinding> bindings, uint binding, SamplerHandle sampler)

    Adds a sampler to the pass.

  • protected virtual void DeclareOutput(CompositorFrame frame, Int2 size)

    Declares the resource this effect writes.

  • protected static Vector2 TexelSize(Int2 size)

    One texel of a texture of the given size, which most of these shaders want.

  • protected override void Build(GraphicsCompositor compositor, CompositorFrame frame)

    Declares this node's render-graph passes.

  • public void Dispose()

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

  • protected virtual void Dispose(bool disposing)

    Releases the pass's pipelines and its uniform buffer.

Used by (25)

  • AmbientCombineRendererVixen.Rendering.PostFx
  • AmbientOcclusionRendererVixen.Rendering.PostFx
  • AutoExposureTestsVixen.Rendering.PostFx.Tests
  • DepthOfFieldRendererVixen.Rendering.PostFx
  • DistanceFieldAoImageTestsVixen.Graphics.Golden.Tests
  • DistanceFieldAoRendererVixen.Rendering.PostFx
  • FogRendererVixen.Rendering.PostFx
  • FxaaRendererVixen.Rendering.PostFx
  • HarnessVixen.Rendering.PostFx.Tests
  • IndirectDiffuseImageTestsVixen.Graphics.Golden.Tests
  • IndirectDiffuseRendererVixen.Rendering.PostFx
  • MotionBlurRendererVixen.Rendering.PostFx
  • OutlineRendererVixen.Rendering.PostFx
  • PostEffectFactoryVixen.Rendering.PostFx
  • PostEffectTestsVixen.Rendering.PostFx.Tests
  • ScreenProbeBilateralImageTestsVixen.Graphics.Golden.Tests
  • ScreenProbeGatherImageTestsVixen.Graphics.Golden.Tests
  • ScreenProbeGatherRendererVixen.Rendering.PostFx
  • ScreenProbeUpsampleImageTestsVixen.Graphics.Golden.Tests
  • ScreenProbeUpsampleRendererVixen.Rendering.PostFx
  • SharpenRendererVixen.Rendering.PostFx
  • SkyRendererVixen.Rendering.PostFx
  • TemporalAntialiasingRendererVixen.Rendering.PostFx
  • TonemapRendererVixen.Rendering.PostFx
  • VignetteRendererVixen.Rendering.PostFx