Vixen
02b45cc4
csharp
public sealed class HiZPyramid

A depth pyramid: last frame's depth buffer, min-reduced level by level, for GpuVisibilityGroup to occlusion-test against — or max-reduced, for a screen march to skip by. Reduction is the choice.

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

Remarks

The device half of Raven/Library/Pipeline/HiZReduce.rvn. It owns one mip-chained R32Float texture and records a dispatch per level into a list the caller supplies — the same division VfxGpuSimulation makes, and for the same reason: what to submit and when is the frame's business, not a resource's.

Level 0 is half the depth buffer, not a copy of it. The first dispatch reduces the depth texture rather than copying it, which removes a whole full-resolution level from both the memory and the chain, and costs nothing in precision: an occlusion test that needed the exact depth of a single pixel would be a test of something too small to cull.

Minimum, because depth is reversed. Near is 1 and far is 0, so the smallest value in a tile is the furthest surface drawn in it — which is the only number a conservative "is this behind everything" test can use. Reducing by maximum, or by average, culls objects that were visible.

It is persistent, and that is why it is not a graph resource. The pyramid is written at the end of one frame and read at the start of the next, so a transient the graph aliases would be somebody else's pixels by the time the culler sampled it. What is a graph resource is the depth it reduces, which is why HiZRenderer exists to declare that read.

Fields and properties (9)

  • public HiZReduction Reduction

    Which way the chain reduces. Furthest is culling's; Nearest is the screen march's.

  • public EffectSystem? Effects

    Where the reduction variant is resolved from. Null builds nothing.

  • public ComputePipelineCache? Pipelines

    Where the compute pipeline comes from. Null builds nothing.

  • public int BuildsPerFrame

    How many times a frame Build is called, which is what the set ring has to be deep enough for.

  • public Int2 Size

    Level 0's size in texels — half the depth buffer, rounded down.

  • public int Levels

    How many levels the chain has, or zero before the first build.

  • public TextureViewHandle View

    A view of every level, which is what the culling pass samples.

  • public TextureHandle Texture

    The chain's own texture — what a readback copies from, mip by mip.

  • public bool IsBuilt

    Whether a build has completed and the pyramid holds a frame's depth.

Methods (3)

  • public HiZPyramid(IGraphicsDevice device)

    Creates a pyramid on a device. Nothing is allocated until the first build.

  • public bool Build(ICommandList list, TextureViewHandle depth, Int2 depthSize)

    Records the dispatches that reduce a depth buffer into the chain.

  • public void Dispose()

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

Used by (16)

  • ArenaThirdPersonShooter
  • ArenaIlluminationThirdPersonShooter
  • FrameDocumentTestsThirdPersonShooter.Frame.Tests
  • CompositorAssetTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering
  • GpuClusterVisibilityVixen.Rendering
  • GpuVisibilityGroupVixen.Rendering
  • GpuVisibilityGroupTestsVixen.Rendering.Tests
  • HiZRendererVixen.Rendering
  • PostEffectTestsVixen.Rendering.PostFx.Tests
  • ReflectionRendererVixen.Rendering.PostFx
  • ReflectionTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenProbeGatherRendererVixen.Rendering.PostFx
  • ScreenProbeTraceDeviceTestsVixen.Graphics.Golden.Tests
  • ScreenPyramidDeviceTestsVixen.Graphics.Golden.Tests
  • ViewCullingDeviceTestsVixen.Graphics.Golden.Tests