public sealed class FoliageCullPassThe host for FoliageCull.rvn: the instance table, the per-frame batch table, and the two dispatches that turn them into indirect draws.
Remarks
[docs/plan/31 § T5]'s owed device half. FoliageRenderer is the CPU reference — what a headless test and a machine with no compute queue use — and this is the same arithmetic where fifty thousand trees can afford it. Neither is the definition: InstanceCuller is, and both transliterate it.
⚠ Two dispatches of one shader, because compaction needs a count before it needs a slot. The first counts each level's survivors; the second recomputes every verdict and claims a slot within its level's run. That is InstanceCuller's own two-pass shape, and it is there for the same reason: one pass cannot make each level's survivors contiguous without knowing the earlier levels' sizes.
⚠ The instances are uploaded when the volume changes and the batches every frame. A forest's instances are megabytes and they do not move; its batch table is a hundred kilobytes and every field in it is the view's. Re-uploading the instances per frame would be the bandwidth this pass exists to save.
⚠ A batch writes inside its own run. FirstInstance is where its survivors go as well as where its instances are, so the output buffer is exactly as long as the input and nothing has to allocate per frame. The survivors of two batches are therefore not adjacent, which costs nothing — they are different meshes and were never one draw.
⚠ The counters are zeroed before the first dispatch, not after the second. A pass that cleared afterwards leaves the buffer holding last frame's numbers for anything that reads it in between, and what reads it is the indirect draw.
Fields and properties (18)
public const int GroupSizeHow many instances a workgroup covers. [ComputeShader(64)].
public const int MaxLevelsThe most levels a batch may bin into. FoliageCullMath.MaxLevels.
public static int DrawCommandBytesHow many bytes one indirect command is — DrawIndexedIndirect's stride.
public int InstanceCapacityHow many instances may be resident.
public int BatchCapacityHow many batches may be culled in one frame.
public int InstanceCountHow many instances the last Upload wrote.
public int BatchCountHow many batches it filed them under.
public int RefusedHow many chunks were refused because a capacity was full.
public int VisibleBatchesHow many batches the last Prepare found visible.
public bool OccludingWhether the last Prepare will also test against last frame's depth.
public int GroupsHow many workgroups each phase dispatches.
public int DrawsHow many indirect draws a frame issues — BatchCount levels' worth.
public FoliageStreamer? StreamingWhich cells are uploaded, or null while every cell always is.
public int SkippedHow many cells the last Upload left out because they are not resident.
public BufferHandle SurvivorsThe buffer the draw reads its survivors' indices from.
public BufferHandle ParametersAnd their per-instance parameters.
public BufferHandle CommandsAnd the indirect arguments.
public BufferHandle CountsAnd how many survived at each level.
Methods (8)
public FoliageCullPass(IGraphicsDevice device, ShaderHandle counting, ShaderHandle placing, int instanceCapacity = 65536, int batchCapacity = 1024, ShaderHandle occludingCount = default(ShaderHandle), ShaderHandle occludingPlace = default(ShaderHandle))Creates the pass and its buffers.
public int Upload(FoliageVolume volume, IReadOnlyList<FoliageDraw> draws)Uploads a volume's instances. Call when the volume changes, not every frame.
public int Prepare(in BoundingFrustum frustum, Vector3 viewPosition, float densityScale = 1, FoliageOccluders occluders = default(FoliageOccluders))Writes the frame's batch table, its view and its draw templates.
public int Record(ICommandList commandList)Records both dispatches.
public long CommandOf(int batch, int level)Where a batch's level's indirect command is, for the draw that reads it.
public (int First, int Length) RunOf(int batch)Where a batch's survivors are, and how many there is room for.
public FoliageCullBatchRecord BatchOf(int batch)The batch record a batch has, as the frame's last Prepare left it.
public void Dispose()Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Used by (2)
- FoliageCullParityTestsVixen.Rendering.Terrain.Tests
- FoliageCullPassTestsVixen.Rendering.Terrain.Tests