Vixen
02b45cc4
csharp
public sealed class LineRenderer

Draws world-space line segments: a grid, a gizmo, a debug ray, a collider's outline.

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

Remarks

The pipeline DebugDraw's geometry comes out of, and the editor's grid with it. It is deliberately not tied to either: what arrives here is a span of vertices in world space, so the editor's grid, a gizmo's arms and a physics engine's contact normals all go through one pipeline rather than three. Vixen.Engine.Renderer is the piece that turns an accumulator into that span.

No model matrix and no per-object anything. A line is already where it is. That is what makes the whole of a frame's lines one draw call and one buffer write, however many things produced them — and it is why the vertex is twenty-eight bytes with nothing in it but a position and a colour.

⚠ Host-visible buffers, rewritten every frame, ringed per frame in flight. Same arrangement and same reasoning as UiRenderer: this geometry is read once by one draw and thrown away, so a staging copy would add a transfer and a barrier to save nothing — and writing one region while the GPU still reads it for an unfinished frame is what makes a grid flicker.

⚠ Line width is one pixel and is not settable. lineWidth above one needs a device feature that is optional in Vulkan and absent on most tiled GPUs, so a renderer that offered it would draw different pictures on different machines. A thick line is a quad, and that belongs to whoever wants one rather than here.

Fields and properties (6)

  • public int Capacity

    How many vertices fit in one frame's region.

  • public int Regions

    How many regions the ring has.

  • public int Region

    Which region the last upload wrote.

  • public int Count

    How many vertices the last upload held.

  • public int Draws

    How many draws the last record issued.

  • public int Dropped

    How many vertices the last upload dropped for want of room.

Methods (4)

  • public LineRenderer(IGraphicsDevice device, LineShaders shaders, RenderOutput output, int capacity = 65536)

    Builds the pipeline a frame's lines are drawn with.

  • public void Upload(ReadOnlySpan<LineVertex> segments)

    Writes a frame's lines into the next region of the ring.

  • public void Record(ICommandList commands, in Matrix4x4 viewProjection, bool depthTested = true)

    Draws what the last upload wrote.

  • public void Dispose()

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

Used by (3)

  • DebugDrawRendererVixen.Engine.Renderer
  • LineImageTestsVixen.Graphics.Golden.Tests
  • ScenePresenterVixen.Editor.App