예제 #1
0
            static unsafe void Execute(ref JobStruct_Process3 <T, U0, U1, U2> jobData, IntPtr additionalPtr, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex)
            {
                if (jobData.Iterator.m_IsParallelFor)
                {
                    int begin;
                    int end;
                    while (JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out begin, out end))
                    {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                        JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf(ref jobData), begin, end - begin);
#endif
                        ExecuteInnerLoop(ref jobData, begin, end);
                    }
                }
                else
                {
                    ExecuteInnerLoop(ref jobData, 0, jobData.Iterator.m_Length);
                }
            }
예제 #2
0
            static unsafe void ExecuteInnerLoop(ref JobStruct_Process3 <T, U0, U1, U2> jobData, int begin, int end)
            {
                ComponentChunkCache cache0, cache1, cache2;

                while (begin != end)
                {
                    jobData.Iterator.Iterator0.UpdateCache(begin, out cache0);
                    var ptr0 = cache0.CachedPtr;

                    jobData.Iterator.Iterator1.UpdateCache(begin, out cache1);
                    var ptr1 = cache1.CachedPtr;

                    jobData.Iterator.Iterator2.UpdateCache(begin, out cache2);
                    var ptr2 = cache2.CachedPtr;

                    var curEnd = Math.Min(end, cache0.CachedEndIndex);

                    for (var i = begin; i != curEnd; i++)
                    {
                        //@TODO: use ref returns to pass by ref instead of double copy
                        var value0 = UnsafeUtility.ReadArrayElement <U0>(ptr0, i);
                        var value1 = UnsafeUtility.ReadArrayElement <U1>(ptr1, i);
                        var value2 = UnsafeUtility.ReadArrayElement <U2>(ptr2, i);

                        jobData.Data.Execute(ref value0, ref value1, ref value2);

                        if (jobData.Iterator.IsReadOnly0 == 0)
                        {
                            UnsafeUtility.WriteArrayElement(ptr0, i, value0);
                        }
                        if (jobData.Iterator.IsReadOnly1 == 0)
                        {
                            UnsafeUtility.WriteArrayElement(ptr1, i, value1);
                        }
                        if (jobData.Iterator.IsReadOnly2 == 0)
                        {
                            UnsafeUtility.WriteArrayElement(ptr2, i, value2);
                        }
                    }

                    begin = curEnd;
                }
            }