Using a Job to write data into ComputeBuffer

Hey all!

I’m messing around with getting indirect instancing working, and I want to write my instance data into some compute buffers with a job (As implied in the Nordeus talk here)

But given that the ComputerBuffer is a reference type, how can you pass it into a job?

My test code:

 struct FillInstanceComputeBuffersJob : IJobParallelForBatch
    {
        [ReadOnly] public NativeArray<InstanceData> InstanceData;
        public ComputeBuffer TargetComputeBuffer;

        public void Execute(int startIndex, int count)
        {
            TargetComputeBuffer.SetData(InstanceData, startIndex, startIndex, count);
        }
    }

you can not. you need to add the data to the compute buffer as normal on the main thread.

Ahh thank you for the confirmation!