And unity’s documentation saying to use Structured Buffer.
StructuredBuffer g_Buffer;
Which one would i use? Are they the same? The documentation is a bit vague with this stuff from both websites…neither explain how to really use them in any detail.
I’d suggest StructuredBuffer for items you only want to read in the Compute Shader or RWStructuredBuffer for things you want to update in the shader and then potentially read back onto the CPU with bufName.GetData(1DArray).
Buffer can only use scalar, vector or matrix types as elements and max size of one element is 128 bits.
Buffer<float> _FloatBuffer;
Buffer<float4> _VectorBuffer;
Buffer<float2x2> _Matrix2x2Buffer;
// this won't compile because float4x4 is larger than 128bits
Buffer<float4x4> _Matrix4x4Bufer;
It doesn’t mention them because not every platform supports them, for some reason. I had to replace some Buffer<> with StructuredBuffer<> to get the shaders to compile in such cases.