⚠ Preview docs — built from the develop branch and may be unstable. Go to the stable docs.

ComputeBuffer.ComputeBuffer

void ComputeBuffer(ComputeBufferType type, int elementCount)

Creates a GPU storage buffer with room for elementCount elements, initially uninitialized! The contents will be whatever was in GPU memory before, so make sure to write before you read.

   
ComputeBufferType type Read or ReadWrite access from compute shaders.
int elementCount Number of T elements to allocate.
void ComputeBuffer(ComputeBufferType type, T[] initialData)

Creates a GPU storage buffer and immediately uploads initialData to it! The buffer capacity is set to the array length.

   
ComputeBufferType type Read or ReadWrite access from compute shaders.
T[] initialData Array of data to upload to the GPU.




Found an issue with these docs, or have some additional questions? Create an Issue on Github!