Some wrappers for comfortable prototyping of simple сompute shader use cases.
This is a generic wrapper for ComputeBuffer that encapsulates a persistently allocated NativeArray of buffer data, that can be easily updated without the need to retrieve the data from the buffer. Also eliminating the need to calculate the data stride.
var computeBuffer = new CompBuffer<float>(count);
for (int i = 0; i < count; ++i)
{
computeBuffer.SetData(i, value);
}
computeBuffer.ApplyData();
using var data = new NativeArray<float>(count, Allocator.TempJob);
var job = new Job
{
Data = data,
};
job.Schedule(count, 64).Complete();
var buffer = new CompBuffer<float3>(data);
This is a wrapper for ComputeShader that works with single-kernel shader files. It encapsulates the kernelIndex, threadGroupsX, and threadGroupsY, allowing for easy dispatch without passing arguments.
var computeShader = new CompShader(shader, countX, countY);
computeShader.SetBuffer("_Buffer", computeBuffer);
computeShader.Dispatch();
v1.0.0