#pragma kernel CSMain
shared RWStructuredBuffer _TheBuffer;
[numthreads(8,8,1)]
void CSMain (uint3 id : SV_DispatchThreadID)
{
_TheBuffer[(id.y * 8) + id.x] = (id.y * 8) + id.x;
}
public class ExecTestCS : MonoBehaviour {
public ComputeShader CS;
private ComputeBuffer CB;
void Start () {
CB = new ComputeBuffer(2048, sizeof(float));
}
void Update () {
CS.SetBuffer(0, "_TheBuffer", CB);
CS.Dispatch(0, 1, 1, 1);
int[] x = new int[2048];
CB.GetData(x);
}
}
The question:
CS.Dispatch(0, 1, 1, 1); //fills 64 positions (as I was expecting)
CS.Dispatch(0, 2, 1, 1); //fills 72 positions (i dont get it)
CS.Dispatch(0, 2, 2, 1); //fills 136 positions (now i’m lost)