internal static unsafe JobHandle ScheduleInternal <T>(ref T jobData, EntityQuery query, JobHandle dependsOn, ScheduleMode mode) where T : struct, IJobChunk { ComponentChunkIterator iterator = query.GetComponentChunkIterator(); var unfilteredChunkCount = query.CalculateChunkCountWithoutFiltering(); var prefilterHandle = ComponentChunkIterator.PreparePrefilteredChunkLists(unfilteredChunkCount, iterator.m_MatchingArchetypeList, iterator.m_Filter, dependsOn, mode, out var prefilterData, out var deferredCountData); JobChunkData <T> fullData = new JobChunkData <T> { #if ENABLE_UNITY_COLLECTIONS_CHECKS // All IJobChunk jobs have a EntityManager safety handle to ensure that BeforeStructuralChange throws an error if // jobs without any other safety handles are still running (haven't been synced). safety = new EntitySafetyHandle { m_Safety = query.SafetyManager->GetEntityManagerSafetyHandle() }, #endif Data = jobData, PrefilterData = prefilterData, }; var scheduleParams = new JobsUtility.JobScheduleParameters( UnsafeUtility.AddressOf(ref fullData), JobChunk_Process <T> .Initialize(), prefilterHandle, mode); #if ENABLE_UNITY_COLLECTIONS_CHECKS try { #endif if (mode == ScheduleMode.Batched) { return(JobsUtility.ScheduleParallelForDeferArraySize(ref scheduleParams, 1, deferredCountData, null)); } else { var count = unfilteredChunkCount; return(JobsUtility.ScheduleParallelFor(ref scheduleParams, count, 1)); } #if ENABLE_UNITY_COLLECTIONS_CHECKS } catch (InvalidOperationException e) { prefilterData.Dispose(); throw e; } #endif }
internal unsafe static void ExecuteInternal(ref JobChunkData <T> jobData, ref JobRanges ranges, int jobIndex) { ComponentChunkIterator.UnpackPrefilterData(jobData.PrefilterData, out var filteredChunks, out var entityIndices, out var chunkCount); int chunkIndex, end; while (JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out chunkIndex, out end)) { var chunk = filteredChunks[chunkIndex]; var entityOffset = entityIndices[chunkIndex]; jobData.Data.Execute(chunk, chunkIndex, entityOffset); } }
internal unsafe static void ExecuteInternal(ref JobChunkData <T> jobData, ref JobRanges ranges, int jobIndex) { var filteredChunks = (ArchetypeChunk *)NativeArrayUnsafeUtility.GetUnsafePtr(jobData.PrefilterData); var entityIndices = (int *)(filteredChunks + ranges.TotalIterationCount); int chunkIndex, end; while (JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out chunkIndex, out end)) { var chunk = filteredChunks[chunkIndex]; var entityOffset = entityIndices[chunkIndex]; jobData.Data.Execute(chunk, chunkIndex, entityOffset); } }
public unsafe static void Execute(ref JobChunkData <T> jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex) { ExecuteInternal(ref jobData, ref ranges, jobIndex); }