GpuBufferclass

A GPU data buffer intended for use with a `Sandbox.ComputeShader`. You can read and write arbitrary data to and from the CPU and GPU. This allows for efficient parallel data processing on the GPU. Different GPU buffer types can be used depending on the provided `Sandbox.GpuBuffer.UsageFlags`. Using the default `Sandbox.GpuBuffer.UsageFlags.Structured` type buffers map to StructuredBuffer and RWStructuredBuffer in HLSL.

objectGpuBuffer
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public class Sandbox.GpuBuffer

Constructors2

Showing 2 constructors

Methods12

Showing 12 methods

public void Clear(uint value = 0)PUBLIC

Fills the entire buffer with a repeated uint32 value. Uses the native GPU fill command (vkCmdFillBuffer) — no CPU-side allocation needed.

ParameterTypeDescription
value = 0uintThe uint32 value to fill with. Defaults to zero.
Returns:void

public void CopyStructureCount(Sandbox.GpuBuffer destBuffer, int destBufferOffset = 0)PUBLIC

For `Sandbox.GpuBuffer.UsageFlags.Append` buffers there is a hidden uint 32-bit atomic counter in the buffer that contains the number of writes to the buffer after invocation of the compute shader. In order to get the value of the counter, the data needs to be copied to another GPU buffer that can be used.

ParameterTypeDescription
destBufferGpuBuffer
destBufferOffset = 0int
Returns:void

public virtual sealed void Dispose()PUBLICVIRTUAL

Destroys the GPU buffer, don't use it no more

Returns:void

protected virtual override void Finalize()PROTECTEDVIRTUALOVERRIDE

Returns:void

protected void Initialize(int elementCount, int elementSize, Sandbox.GpuBuffer.UsageFlags usageFlags = 32, string debugName = null)PROTECTED

ParameterTypeDescription
elementCountint
elementSizeint
usageFlags = 32UsageFlags
debugName = nullstring
Returns:void

public void SetCounterValue(uint counterValue)PUBLIC

Sets the counter value for `Sandbox.GpuBuffer.UsageFlags.Append` or `Sandbox.GpuBuffer.UsageFlags.Counter` structured buffers.

ParameterTypeDescription
counterValueuint
Returns:void

Properties4

Showing 4 properties

public int Sandbox.GpuBuffer.ElementCount { get; set; }PUBLICGETSET

Number of elements in the buffer.

Returns:int

public int Sandbox.GpuBuffer.ElementSize { get; set; }PUBLICGETSET

Size of a single element in the buffer.

Returns:int

public virtual sealed bool Sandbox.GpuBuffer.IsValid { get; set; }PUBLICVIRTUALGETSET

Returns:bool

On this page