What is the reason for passing the kernel index along with the buffer when binding it using ComputeShader.SetBuffer, even though buffers are global variables in shader code that can be accessed by any kernel within the same shader file?
I think because the underlying APIs require it. Even though the kernels are are in the same file, they could be compiled into separate binary blobs. So it needs to know which kernel is going to use the buffer. It mirrors the underlying APIs, eg you need to set up a separate root signature for each kernel in DX12.