Class GpuBuffer¶
Namespace: Apogee.Graphics
Assembly: Apogee.Graphics.dll
A buffer in GPU memory. Every buffer has a device address, so shaders reach it through a pointer in push constants.
public abstract class GpuBuffer : IDisposable
Inheritance¶
Derived¶
Implements¶
Inherited Members¶
object.Equals(object?), object.Equals(object?, object?), object.GetHashCode(), object.GetType(), object.MemberwiseClone(), object.ReferenceEquals(object?, object?), object.ToString()
Constructors¶
GpuBuffer(ulong, BufferUsage, MemoryKind)¶
protected GpuBuffer(ulong size, BufferUsage usage, MemoryKind kind)
Parameters¶
size ulong
usage BufferUsage
kind MemoryKind
Properties¶
Address¶
The GPU address of the first byte: what a shader's pointer holds.
public abstract ulong Address { get; }
Property Value¶
Kind¶
public MemoryKind Kind { get; }
Property Value¶
Mapped¶
The CPU's view of the memory for
public byte* Mapped { get; protected init; }
Property Value¶
byte*
Size¶
public ulong Size { get; }
Property Value¶
Usage¶
public BufferUsage Usage { get; }
Property Value¶
Methods¶
AsSpan()¶
public Span<byte> AsSpan()
Returns¶
Dispose()¶
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public abstract void Dispose()
Flush(ulong, ulong)¶
Makes CPU writes to a range of the mapped memory visible to the GPU (a no-op for coherent memory).
protected abstract void Flush(ulong offset, ulong length)
Parameters¶
offset ulong
length ulong
Invalidate(ulong, ulong)¶
Makes GPU writes to a range of the mapped memory visible to the CPU (a no-op for coherent memory).
protected abstract void Invalidate(ulong offset, ulong length)
Parameters¶
offset ulong
length ulong
Read(ulong, int)¶
Makes the GPU's writes visible to the CPU and returns a copy of a range of a mapped buffer.
public byte[] Read(ulong offset, int length)
Parameters¶
offset ulong
length int
Returns¶
byte[]
Write(ReadOnlySpan<byte>, ulong)¶
Copies data into a mapped buffer at offset and makes the write visible to the GPU.
public void Write(ReadOnlySpan<byte> data, ulong offset = 0)
Parameters¶
data ReadOnlySpan<byte>
offset ulong