ComputeBuffer
Create a Compute Buffer.
Read time 2 minutesLast updated 4 days ago
Definition
- Type: Constructor
- Namespace: UnityEngine
- Assembly: UnityEngine.CoreModule
ComputeBuffer(int, int)
Create a Compute Buffer.
public ComputeBuffer(int count, int stride)
Parameters
Number of elements in the buffer.
Size of one element in the buffer, in bytes. Must be a multiple of 4 and less than 2048, and match the size of the buffer type in the shader. See Compute Shaders for cross-platform compatibility information.
Remarks
Use ComputeBuffer.Release to release the buffer when no longer needed.
Additional Resources: SystemInfo.supportsComputeShaders, ComputeShader class, Shader.SetGlobalBuffer, Material.SetBuffer, Compute Shaders.
ComputeBuffer(int, int, ComputeBufferType)
Create a Compute Buffer.
public ComputeBuffer(int count, int stride, ComputeBufferType type)
Parameters
Number of elements in the buffer.
Size of one element in the buffer, in bytes. Must be a multiple of 4 and less than 2048, and match the size of the buffer type in the shader. See Compute Shaders for cross-platform compatibility information.
Type of the buffer, default is ComputeBufferType.Default (structured buffer).
Remarks
Use ComputeBuffer.Release to release the buffer when no longer needed.
Additional Resources: SystemInfo.supportsComputeShaders, ComputeShader class, Shader.SetGlobalBuffer, Material.SetBuffer, Compute Shaders.
ComputeBuffer(int, int, ComputeBufferType, ComputeBufferMode)
Create a Compute Buffer.
public ComputeBuffer(int count, int stride, ComputeBufferType type, ComputeBufferMode usage)
Parameters
Number of elements in the buffer.
Size of one element in the buffer, in bytes. Must be a multiple of 4 and less than 2048, and match the size of the buffer type in the shader. See Compute Shaders for cross-platform compatibility information.
Type of the buffer, default is ComputeBufferType.Default (structured buffer).
Usage mode of the buffer, default is ComputeBufferModeImmutable.
Remarks
Use ComputeBuffer.Release to release the buffer when no longer needed.
Additional Resources: SystemInfo.supportsComputeShaders, ComputeShader class, Shader.SetGlobalBuffer, Material.SetBuffer, Compute Shaders.