Exemple #1
0
 public static JobHandle ScheduleParallel <T>(this FindPairsConfig <T> config, JobHandle inputDeps = default) where T : struct, IFindPairsProcessor
 {
     if (config.isLayerLayer)
     {
         JobHandle jh = new FindPairsInternal.LayerLayerPart1 <T>
         {
             layerA    = config.layerA,
             layerB    = config.layerB,
             processor = config.processor
         }.Schedule(config.layerB.BucketCount, 1, inputDeps);
         jh = new FindPairsInternal.LayerLayerPart2 <T>
         {
             layerA    = config.layerA,
             layerB    = config.layerB,
             processor = config.processor
         }.Schedule(2, 1, jh);
         return(jh);
     }
     else
     {
         JobHandle jh = new FindPairsInternal.LayerSelfPart1 <T>
         {
             layer     = config.layerA,
             processor = config.processor
         }.Schedule(config.layerA.BucketCount, 1, inputDeps);
         jh = new FindPairsInternal.LayerSelfPart2 <T>
         {
             layer     = config.layerA,
             processor = config.processor
         }.Schedule(jh);
         return(jh);
     }
 }
        /// <summary>
        /// Run the FindPairs operation using multiple worker threads in multiple phases.
        /// </summary>
        /// <param name="inputDeps">The input dependencies for any layers or processors used in the FindPairs operation</param>
        /// <returns>The final JobHandle for the scheduled jobs</returns>
        public JobHandle ScheduleParallel(JobHandle inputDeps = default)
        {
            if (isLayerLayer)
            {
                JobHandle jh = new FindPairsInternal.LayerLayerPart1
                {
                    layerA    = layerA,
                    layerB    = layerB,
                    processor = processor
                }.Schedule(layerB.BucketCount, 1, inputDeps);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (disableEntityAliasChecks)
                {
                    jh = new FindPairsInternal.LayerLayerPart2
                    {
                        layerA    = layerA,
                        layerB    = layerB,
                        processor = processor
                    }.Schedule(2, 1, jh);
                }
                else
                {
                    jh = new FindPairsInternal.LayerLayerPart2_WithSafety
                    {
                        layerA    = layerA,
                        layerB    = layerB,
                        processor = processor
                    }.Schedule(3, 1, jh);
                }
#else
                jh = new FindPairsInternal.LayerLayerPart2
                {
                    layerA    = layerA,
                    layerB    = layerB,
                    processor = processor
                }.Schedule(2, 1, jh);
#endif
                return(jh);
            }
            else
            {
                JobHandle jh = new FindPairsInternal.LayerSelfPart1
                {
                    layer     = layerA,
                    processor = processor
                }.Schedule(layerA.BucketCount, 1, inputDeps);
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                if (disableEntityAliasChecks)
                {
                    jh = new FindPairsInternal.LayerSelfPart2
                    {
                        layer     = layerA,
                        processor = processor
                    }.Schedule(jh);
                }
                else
                {
                    jh = new FindPairsInternal.LayerSelfPart2_WithSafety
                    {
                        layer     = layerA,
                        processor = processor
                    }.ScheduleParallel(2, 1, jh);
                }
#else
                jh = new FindPairsInternal.LayerSelfPart2
                {
                    layer     = layerA,
                    processor = processor
                }.Schedule(jh);
#endif
                return(jh);
            }
        }