I have generic job which takes arbitrary component with known data layout, reinterpret it to T array and copy to output array (which is ComputeBuffer by the way). What I want is to try to avoid using generic job here, because of need to register them for every component case.
Can job below avoid using generic in any way? All it does actually just copy one array to another with same size and same data layout.
[BurstCompile]
// takes all chunks by query, and then just copy component data to compute buffer starting from 1st entity in query index
internal struct SyncPropertyByQueryJob<TProperty> : IJobChunk
where TProperty : unmanaged
{
[ReadOnly][DeallocateOnJobCompletion] public NativeArray<int> chunkBaseEntityIndices;
// this should be filled every frame with GetDynamicComponentTypeHandle
[ReadOnly]public DynamicComponentTypeHandle componentTypeHandle;
public int typeSize;
[WriteOnly][NativeDisableParallelForRestriction] public NativeArray<TProperty> outputArray;
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
var data = chunk.GetDynamicComponentDataArrayReinterpret<TProperty>(ref componentTypeHandle, typeSize);
NativeArray<TProperty>.Copy(data, 0, outputArray, startCopyToIndex, data.Length);
}
}