Table of Contents

Class InstancedLayerBase<T>

Namespace
LansMap.Map.Rendering

One GPU instance buffer's upload/draw/dispose mechanics, held as a private field (composition, never a base class) by every instanced marker/label/line layer.

public sealed class InstancedLayerBase<T> where T : struct

Type Parameters

T
Inheritance
object
InstancedLayerBase<T>

Remarks

A layer with more than one buffer (glyphs plus plates, opaque plus fading) holds one instance per buffer; each layer keeps its own per-instance layout and dirty-range math untouched and calls in through these plain methods. Deliberately not abstract and not an interface: the per-layer layout/dirty-range seam stays ordinary private methods on each layer, not a virtual override point.

Constructors

InstancedLayerBase(int, int, int)

public InstancedLayerBase(int stride, int initialCapacity, int minCapacity = 0)

Parameters

stride int
initialCapacity int
minCapacity int

Properties

Buffer

Live GPU buffer; replaced (never resized in place) on grow.

public ComputeBuffer Buffer { get; }

Property Value

ComputeBuffer

Scratch

CPU-side staging array, same length as Buffer.count, that layers write instance data directly into.

public T[] Scratch { get; }

Property Value

T[]

Methods

Dispose()

Releases Buffer. Null-tolerant and double-dispose safe, same as ComputeBuffer.Release.

public void Dispose()

Draw(Material, int, int, int, MeshTopology, int)

Binds Buffer to material and issues an immediate-mode instanced draw (SetPass + DrawProceduralNow), the MarkerLayer/MarkerLabelLayer/PolylineLayer.Render shape.

public void Draw(Material material, int bufferPropId, int pass, int instanceCount, MeshTopology topology = MeshTopology.Triangles, int vertsPerInstance = 6)

Parameters

material Material
bufferPropId int
pass int
instanceCount int
topology MeshTopology
vertsPerInstance int

DrawBounds(Material, int, Bounds, int, int, MeshTopology, int)

Binds Buffer to material and issues a bounds-culled draw (Graphics.DrawProcedural with an explicit Bounds and layer), the SurfaceWorldMarkerRenderer/ SurfaceWorldLabelLayer/PolylineLayer.RenderWorld shape; the caller still sets every other uniform on material first.

public void DrawBounds(Material material, int bufferPropId, Bounds bounds, int instanceCount, int layer, MeshTopology topology = MeshTopology.Triangles, int vertsPerInstance = 6)

Parameters

material Material
bufferPropId int
bounds Bounds
instanceCount int
layer int
topology MeshTopology
vertsPerInstance int

EnsureCapacity(int)

Grows Buffer and Scratch to at least n slots (rounded up to the next power of two), or does nothing when already large enough; never shrinks, matching TileBatchRenderer.BeginGrowLayers' one-way policy.

public void EnsureCapacity(int n)

Parameters

n int

Remarks

Sized from n and the floor passed at construction, never from a live/active count, so a fresh caller cannot collapse to the floor regardless of what it asked for.

FillCommandBuffer(CommandBuffer, Material, int, int, int, MaterialPropertyBlock, MeshTopology, int)

Records an instanced draw into cb through a per-draw UnityEngine.MaterialPropertyBlock: command buffers do not snapshot material buffer state, so the buffer must ride the property block rather than a prior SetBuffer on the material.

public void FillCommandBuffer(CommandBuffer cb, Material material, int bufferPropId, int pass, int instanceCount, MaterialPropertyBlock props, MeshTopology topology = MeshTopology.Triangles, int vertsPerInstance = 6)

Parameters

cb CommandBuffer
material Material
bufferPropId int
pass int
instanceCount int
props MaterialPropertyBlock
topology MeshTopology
vertsPerInstance int

Upload(int, int)

Uploads Scratch[start, start+count) to the same range in Buffer.

public void Upload(int start, int count)

Parameters

start int
count int

UploadAll(int)

Uploads Scratch[0, count) to Buffer.

public void UploadAll(int count)

Parameters

count int