public class Sandbox.GpuBuffer
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.
Related Guides
Broader workflow and conceptual references connected to this API.
The fancy new way to do things in Vulkan / DX12 is bindless. This removes the limitations of the binding model allowing you to have access to far more textures and other resources within a shader and the ability to sample them from a dynamically provided identifier from buffers, vertex input, etc.
GPU instancing is an optimization where multiple instances of the same model with the same material can be drawn in a single draw call. This is a big optimization when rendering things that appear many times in a scene such as foliage.
Constructors
Showing 2 constructors
No results match this filter.
Methods
Showing 12 methods
public void Clear(uint value = 0)
Fills the entire buffer with a repeated uint32 value. Uses the native GPU fill command (vkCmdFillBuffer) — no CPU-side allocation needed.
Parameters
value: The uint32 value to fill with. Defaults to zero. Default: 0
public void CopyStructureCount(Sandbox.GpuBuffer destBuffer, int destBufferOffset = 0)
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.
Parameters
destBufferOffset: Default: 0
public virtual sealed void Dispose()
Destroys the GPU buffer, don't use it no more
protected virtual override void Finalize()
protected void Initialize(int elementCount, int elementSize, Sandbox.GpuBuffer.UsageFlags usageFlags = 32, string debugName = null)
Parameters
usageFlags: Default: 32debugName: Default: null
public void SetCounterValue(uint counterValue)
Sets the counter value for `Sandbox.GpuBuffer.UsageFlags.Append` or `Sandbox.GpuBuffer.UsageFlags.Counter` structured buffers.
No results match this filter.
Properties
Showing 4 properties
public int Sandbox.GpuBuffer.ElementCount { get; set; }
Number of elements in the buffer.
public int Sandbox.GpuBuffer.ElementSize { get; set; }
Size of a single element in the buffer.
public virtual sealed bool Sandbox.GpuBuffer.IsValid { get; set; }
public Sandbox.GpuBuffer.UsageFlags Sandbox.GpuBuffer.Usage { get; set; }
What sort of buffer this is
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.GpuBuffer |