private JobHandle ScheduleIndependentDiffusion(JobHandle dependency, CustomRuleSymbols customSymbols) { // diffusion is only dependent on the target symbol data. don't need to register as dependent on native data/source symbols if (customSymbols.hasDiffusion && customSymbols.independentDiffusionUpdate) { diffusionHelper = new DiffusionWorkingDataPack(10, 5, 2, customSymbols, Allocator.TempJob); var diffusionJob = new IndependentDiffusionReplacementJob { inPlaceSymbols = target, customSymbols = customSymbols, working = diffusionHelper }; dependency = diffusionJob.Schedule(dependency); } return(dependency); }
public LSystemSymbolReplacementCompletable( Unity.Mathematics.Random randResult, LSystemState <float> lastSystemState, int totalNewSymbolSize, int totalNewParamSize, NativeArray <float> globalParamNative, NativeArray <float> tmpParameterMemory, NativeArray <LSystemSingleSymbolMatchData> matchSingletonData, DependencyTracker <SystemLevelRuleNativeData> nativeData, SymbolStringBranchingCache branchingCache, CustomRuleSymbols customSymbols) { this.lastSystemState = lastSystemState; this.matchSingletonData = matchSingletonData; this.branchingCache = branchingCache; UnityEngine.Profiling.Profiler.BeginSample("allocating"); target = new SymbolString <float>(totalNewSymbolSize, totalNewParamSize, Allocator.Persistent); UnityEngine.Profiling.Profiler.EndSample(); this.randResult = randResult; this.nativeData = nativeData; // 5 UnityEngine.Profiling.Profiler.BeginSample("generating replacements"); var replacementJob = new RuleReplacementJob { globalParametersArray = globalParamNative, parameterMatchMemory = tmpParameterMemory, matchSingletonData = matchSingletonData, sourceData = lastSystemState.currentSymbols.Data, structExpressionSpace = nativeData.Data.structExpressionMemorySpace, globalOperatorData = nativeData.Data.dynamicOperatorMemory, replacementSymbolData = nativeData.Data.replacementsSymbolMemorySpace, outcomeData = nativeData.Data.ruleOutcomeMemorySpace, targetData = target, blittableRulesByTargetSymbol = nativeData.Data.blittableRulesByTargetSymbol, branchingCache = branchingCache, customSymbols = customSymbols }; currentJobHandle = replacementJob.Schedule( matchSingletonData.Length, 100 ); if (customSymbols.hasDiffusion && !customSymbols.independentDiffusionUpdate) { diffusionHelper = new DiffusionWorkingDataPack(10, 5, 2, customSymbols, Allocator.TempJob); var diffusionJob = new ParallelDiffusionReplacementJob { matchSingletonData = matchSingletonData, sourceData = lastSystemState.currentSymbols.Data, targetData = target, customSymbols = customSymbols, working = diffusionHelper }; currentJobHandle = JobHandle.CombineDependencies( currentJobHandle, diffusionJob.Schedule() ); } // only parameter modifications beyond this point lastSystemState.currentSymbols.RegisterDependencyOnData(currentJobHandle); nativeData.RegisterDependencyOnData(currentJobHandle); currentJobHandle = JobHandle.CombineDependencies( JobHandle.CombineDependencies( ScheduleIdAssignmentJob(currentJobHandle, customSymbols, lastSystemState), ScheduleIndependentDiffusion(currentJobHandle, customSymbols) ), JobHandle.CombineDependencies( ScheduleAutophagyJob(currentJobHandle, customSymbols), ScheduleImmaturityJob(currentJobHandle) )); UnityEngine.Profiling.Profiler.EndSample(); }