Hello all,
i’am currently testing all out about jobs, burst and computebuffers to get the most performance.
my project generates large worlds of voxels for now, but only some inside the renderDistance are shown.
now the questions:
- What’s more performant or what whould you do?
i got two paths i can choose:
Path 1: Create a large NativeArray with Millions of structs inside (like generating a world) and save that to a extern file for later loading
Path 2: Calculate every x-frame (inside a render Distance) all voxels and save them temporary to NativeArray
- Which Job Type should i use and how much batchCount?
i’am only have two jobs that runs on Update (i now run it every frame is worse)
onupdate i create a NativeArray with a count for the maximum voxels
first job checks a noise value from Unity.Mathematics.noise.snoise for every voxel inside the array, set them to solid or not and then sets each Neighbor index for each neighbor Voxel. This job runs as IJobParallel with a batchCount of 1 because i don’t see any difference if i change the batchCount.
second job checks each voxel if solid, then for each neighbor and create the data for the matrices sending to the ComputeBuffer and later use in DrawMeshInstancedProcedual, same as IJobParallel
i call them in update so:
matricesJob = new SetMatrices { voxels = voxels, matrices = matrices }.ScheduleParallel(voxels.Length * 6, batchCount, matricesJob);
matricesJob.Complete();
For Short:
2.1 Is there a better way as using IJobParallel for hugh amount of calls?
2.2 Whats the right Method to call a Job of Type x?
2.2.1 Is it better to create a new JobHandle on Update every time i need to call the Job or create a global JobHandle and assign the job?
2.3 How does the InnerloopBatchCount changes the performance of a job?
- Using [BurstCompile(FloatPrecision.Low, FloatMode.Fast)] but where?
i read about it and and FloatPrecision.Low is currently not support, it uses Medium instead
3.1 Are there any other options to make the code run faster?
3.2 Where can I place BurstCompile?
3.3 Its possible to place it over the whole Script to get it for all inside the Script?
Thats all for now first.
If something is miss understanding, let me fix it.
Thank all iam interested to learn more about, iam more practical nature and can learn better from testing and look on examples.