Class TiledCullFeeder
Namespace: ValveResourceFormat.Renderer.Buffers
Assembly: Renderer.dll
CPU side of compute_tile_cullbits and compute_depthbin_cullbits: projects world space volumes into the screen AABBs, hulls and depth keys those passes rasterize into bits.
public sealed class TiledCullFeederInheritance
object ← TiledCullFeeder
Remarks
Neither compute pass sees world space, so frustum rejection happens here, and a rejected item costs a bit rather than a test - item count sets the word stride, the buffer size and the shading loop's length. Cull space is pixels and depth is distance along the view axis. common/light_cull.slang defines both the same way and the two must not drift.
Fields
BatchBarnLights
Batch index holding barn light faces.
public const int BatchBarnLights = 0Field Value
int
BatchCount
Item classes culled together in one dispatch.
public const int BatchCount = 4Field Value
int
BatchDecals
Batch index holding projected decal boxes.
public const int BatchDecals = 3Field Value
int
BatchEnvMaps
Batch index holding environment map probes.
public const int BatchEnvMaps = 1Field Value
int
BatchLightProbes
Batch index holding light probe volumes. Only probe atlas scenes fill it.
public const int BatchLightProbes = 2Field Value
int
ItemsPerMask
Items per mask. Batches pad up to a whole number of these so no word spans two batches.
public const int ItemsPerMask = 32Field Value
int
Properties
BinDispatch
Gets the depth bin pass dispatch size.
public (int X, int Y, int Z) BinDispatch { get; }Property Value
ItemArray
Gets the backing array to upload from.
public CullItem[] ItemArray { get; }Property Value
CullItem[]
ItemCount
Gets the live entries of TiledCullFeeder.ItemArray this frame, tail padding included.
public int ItemCount { get; }Property Value
int
MaskCount
Gets the mask count across all batches, which is the dispatch's mask axis.
public int MaskCount { get; }Property Value
int
MaxItemViewDepth
Gets how far along the view axis the furthest item this frame reached.
public float MaxItemViewDepth { get; }Property Value
float
Remarks
The slice distribution is fitted to this rather than to the render far plane: slices are uniform in view depth, so every empty unit past the last light thickens all of them. Unbounded volumes are excluded, since they would pin it to its ceiling.
Params
Gets the constants both compute passes read.
public ref readonly CullParams Params { get; }Property Value
PlaneArray
Gets the hull vertex array CullItem.FirstPlane indexes.
public Vector2[] PlaneArray { get; }Property Value
Vector2[]
PlaneCount
Gets the live entries of TiledCullFeeder.PlaneArray this frame.
public int PlaneCount { get; }Property Value
int
SliceFar
Gets the far distance the slice distribution was fitted to this frame, in world units.
public float SliceFar { get; }Property Value
float
SliceWidth
Gets the view depth one slice spans, in world units. Valid after TiledCullFeeder.End().
public float SliceWidth { get; }Property Value
float
TileDispatch
Gets the tile pass dispatch size.
public (int X, int Y, int Z) TileDispatch { get; }Property Value
TotalWords
Gets the uints the cull bits buffer needs for this frame's layout.
public int TotalWords { get; }Property Value
int
ViewportSize
Gets the viewport the items were projected against, which is the extent of cull space.
public Vector2 ViewportSize { get; }Property Value
Methods
AddBarnLights(ReadOnlySpan<BarnLightCullVolume>)
Adds one item per barn light face. Item i is always light i: the shading pass indexes the light array by bit position, so a face that fails to project is rejected in place, not dropped.
public void AddBarnLights(ReadOnlySpan<BarnLightCullVolume> volumes)Parameters
volumes ReadOnlySpan<BarnLightCullVolume>
Cull volume per barn light face, in shading pass index order.
AddCounts(int, int, int, int)
Claims batch slots without projecting anything, for a frame that will not bin at all.
public void AddCounts(int barnLights, int envMaps, int lightProbes, int decals)Parameters
barnLights int
Barn light faces the shading pass will iterate.
envMaps int
Env map probes the shading pass will iterate.
lightProbes int
Light probe volumes the shading pass will iterate.
decals int
Projected decals the decal pass will iterate.
Remarks
The masks are filled with ones instead, but the shading pass still indexes them through the bases and strides TiledCullFeeder.End() derives from these counts, so the layout still has to be right.
AddDecals(ReadOnlySpan<Matrix4x4>)
Adds one item per projected decal box. Item i is decal i, so the decal pass walks the bits in the order the decals were added.
public void AddDecals(ReadOnlySpan<Matrix4x4> boxTransforms)Parameters
boxTransforms ReadOnlySpan<Matrix4x4>
Maps the unit cube centred on the origin onto each decal box.
AddEnvMaps(List<SceneEnvMap>)
Adds one item per environment map probe, slotted by SceneEnvMap.ShaderIndex.
public void AddEnvMaps(List<SceneEnvMap> envMaps)Parameters
envMaps List<SceneEnvMap>
AddLightProbes(IReadOnlyList<SceneLightProbe>)
Adds one item per light probe volume. Item i is volume i, whose shader index is also its priority, so the shading pass takes the lowest set bit whose volume contains the fragment.
public void AddLightProbes(IReadOnlyList<SceneLightProbe> lightProbes)Parameters
lightProbes IReadOnlyList<SceneLightProbe>
Volumes in shader index order.
Begin(int, int, int, int, float, float, Vector2, in Matrix4x4, Vector3, Vector3, float)
Starts a frame, capturing everything the batches added afterwards are projected against.
public void Begin(int tileCols, int tileRows, int tileSize, int depthBins, float minSliceFar, float maxSliceFar, Vector2 viewportSize, in Matrix4x4 worldToProjection, Vector3 cameraPosition, Vector3 cameraDirection, float cameraNearPlane)Parameters
tileCols int
tileRows int
tileSize int
depthBins int
minSliceFar float
maxSliceFar float
viewportSize Vector2
worldToProjection Matrix4x4
cameraPosition Vector3
cameraDirection Vector3
cameraNearPlane float
BinBase(int)
Gets the first uint of a batch's depth bin region.
public uint BinBase(int batch)Parameters
batch int
Returns
uint
BinnedCount(int)
Gets the slots holding an item that can match a tile. The gap to TiledCullFeeder.SlotCount(int) is what projected to nothing - behind the near plane or off screen - and the CPU rejected outright.
public int BinnedCount(int batch)Parameters
batch int
Batch index.
Returns
int
End()
Lays the batches out back to back in the item and bits buffers, padding each tail so the tile pass's unconditional load stays in bounds. Call once every batch is added.
public void End()SlotCount(int)
Gets the slots a batch claimed, which is every item the shading pass iterates.
public int SlotCount(int batch)Parameters
batch int
Batch index.
Returns
int
Stride(int)
Gets a batch's word stride, ceil(itemCount / 32).
public uint Stride(int batch)Parameters
batch int
Returns
uint
TileBase(int)
Gets the first uint of a batch's tile region.
public uint TileBase(int batch)Parameters
batch int
Returns
uint

