Vixen
02b45cc4
csharp
public sealed class BufferUploadRenderer

Host bytes into a buffer the frame declared.

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

Remarks

The half of a compute pass nobody could author. A dispatch could declare what it read and what it wrote, and everything it read had to have been filled by another dispatch or by a host that imported a buffer it filled itself — because a graph buffer has no handle until the graph compiles, and a device-local one cannot be written by the host at any point. A histogram that starts at zero, a table of coefficients, a list of emitters the CPU decided on: each is a value the frame needs and no pass produces.

Staged, and the staging is a ring. The bytes go into a host-upload buffer and reach the destination through a copy the graph records, which is the only route to device-local memory. One region per frame in flight, for the reason UploadBuffer`1 has one: writing the same host-visible bytes every frame is a memcpy into memory an unfinished frame may still be copying out of, and the symptom is a buffer that is briefly a blend of two frames.

What it declares is a write, and that is the whole point. A node that copied into the buffer without saying so would run wherever it was recorded and be read by a dispatch the driver was free to start first. Declaring the write is what orders this ahead of every pass that reads the buffer and puts the barrier between them — the same edge ComputeRenderer exists for, from the other end.

Fields and properties (6)

  • public required string Buffer

    The name of the buffer to fill.

  • public long Offset

    Where in that buffer the bytes land.

  • public Action<BufferUploadRenderer>? OnUpload

    What refreshes the bytes, run at the start of every build.

  • public ReadOnlySpan<byte> Data

    What will be uploaded, for a test or an inspector.

  • public int Length

    How many bytes are staged.

  • public int UploadCount

    How many times the bytes have actually gone to the device.

Methods (6)

  • public void Set(ReadOnlySpan<byte> bytes)

    Stages raw bytes, replacing whatever was there.

  • public void Set<T>(ReadOnlySpan<T> items) where T : unmanaged

    Stages a run of records, replacing whatever was there.

  • public void Set<T>(in T item) where T : unmanaged

    Stages one record, replacing whatever was there.

  • public Span<byte> Reserve(int bytes)

    Room for a given number of bytes, to be filled in place.

  • protected internal override void Build(GraphicsCompositor compositor, CompositorFrame frame)

    Nothing to stage means no pass, which is what a node with no data should cost.

  • public void Dispose()

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

Used by (3)

  • BufferTransferDeviceTestsVixen.Graphics.Golden.Tests
  • BufferTransferTestsVixen.Rendering.Tests
  • CompositorBuilderVixen.Rendering