class in UnityEngine
Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.Close
For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.Close
GPU data buffer, mostly for use with compute shaders.
ComputeShader programs often need arbitrary data to be read & written into memory buffers.
ComputeBuffer class is exactly for that - you can create & fill them from script code,
and use them in compute shaders or regular shaders.
Compute buffers are always supported in compute shaders. Compute shader support can be queried runtime using SystemInfo.supportsComputeShaders. See the Compute Shaders Manual page for more information about platforms supporting compute shaders. In regular graphics shaders the compute buffer support requires minimum shader model 4.5.
On the shader side, ComputeBuffers with default ComputeBufferType map to
RWStructuredBuffer<T> in HLSL.
See Also: ComputeShader class, Shader.SetGlobalBuffer, Material.SetBuffer, Compute Shaders overview.
|count||Number of elements in the buffer (Read Only).|
|stride||Size of one element in the buffer (Read Only).|
|ComputeBuffer||Create a Compute Buffer.|
|GetData||Read data values from the buffer into an array.|
|GetNativeBufferPtr||Retrieve a native (underlying graphics API) pointer to the buffer.|
|Release||Release a Compute Buffer.|
|SetCounterValue||Sets counter value of append/consume buffer.|
|SetData||Set the buffer with values from an array.|
|CopyCount||Copy counter value of append/consume buffer into another buffer.|