static public int constructor(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Jobs.TransformAccessArray o;
         if (matchType(l, argc, 2, typeof(UnityEngine.Transform[]), typeof(int)))
         {
             UnityEngine.Transform[] a1;
             checkArray(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             o = new UnityEngine.Jobs.TransformAccessArray(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(int), typeof(int)))
         {
             System.Int32 a1;
             checkType(l, 2, out a1);
             System.Int32 a2;
             checkType(l, 3, out a2);
             o = new UnityEngine.Jobs.TransformAccessArray(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc == 0)
         {
             o = new UnityEngine.Jobs.TransformAccessArray();
             pushValue(l, true);
             pushObject(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.Jobs.TransformAccessArray o;
         o = new UnityEngine.Jobs.TransformAccessArray();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #3
0
        public static void Allocate(int capacity, int desiredJobCount, out TransformAccessArray array)
        {
            array.m_TransformArray = TransformAccessArray.Create(capacity, desiredJobCount);
            IntPtr    arg_3F_0 = array.m_TransformArray;
            Allocator arg_3F_1 = Allocator.Persistent;
            int       arg_3F_4 = 1;

            if (TransformAccessArray.< > f__mg$cache0 == null)
            {
                TransformAccessArray.< > f__mg$cache0 = new DisposeSentinel.DeallocateDelegate(TransformAccessArray.DeallocateFromDisposeSentinel);
            }
            DisposeSentinel.Create(arg_3F_0, arg_3F_1, out array.m_Safety, out array.m_DisposeSentinel, arg_3F_4, TransformAccessArray.< > f__mg$cache0);
        }
Пример #4
0
 public                                               Transform this[int index]
 {
     get
     {
         AtomicSafetyHandle.CheckReadAndThrow(this.m_Safety);
         return(TransformAccessArray.GetTransform(this.m_TransformArray, index));
     }
     set
     {
         AtomicSafetyHandle.CheckWriteAndThrow(this.m_Safety);
         TransformAccessArray.SetTransform(this.m_TransformArray, index, value);
     }
 }
            public unsafe static void Execute(ref T jobData, IntPtr jobData2, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex)
            {
                IJobParallelForTransformExtensions.TransformParallelForLoopStruct <T> .TransformJobData transformJobData;
                UnsafeUtility.CopyPtrToStructure <IJobParallelForTransformExtensions.TransformParallelForLoopStruct <T> .TransformJobData>((void *)jobData2, out transformJobData);
                int *            ptr  = (int *)((void *)TransformAccessArray.GetSortedToUserIndex(transformJobData.TransformAccessArray));
                TransformAccess *ptr2 = (TransformAccess *)((void *)TransformAccessArray.GetSortedTransformAccess(transformJobData.TransformAccessArray));
                bool             flag = transformJobData.IsReadOnly == 1;

                if (flag)
                {
                    while (true)
                    {
                        int  num;
                        int  num2;
                        bool flag2 = !JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out num, out num2);
                        if (flag2)
                        {
                            break;
                        }
                        int num3 = num2;
                        for (int i = num; i < num3; i++)
                        {
                            int num4 = i;
                            int num5 = ptr[num4];
                            JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf <T>(ref jobData), num5, 1);
                            TransformAccess transform = ptr2[num4];
                            transform.MarkReadOnly();
                            jobData.Execute(num5, transform);
                        }
                    }
                }
                else
                {
                    int num6;
                    int num7;
                    JobsUtility.GetJobRange(ref ranges, jobIndex, out num6, out num7);
                    for (int j = num6; j < num7; j++)
                    {
                        int num8 = j;
                        int num9 = ptr[num8];
                        JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf <T>(ref jobData), num9, 1);
                        TransformAccess transform2 = ptr2[num8];
                        transform2.MarkReadWrite();
                        jobData.Execute(num9, transform2);
                    }
                }
            }
 static public int ctor__Int32__Int32_s(IntPtr l)
 {
     try {
         UnityEngine.Jobs.TransformAccessArray o;
         System.Int32 a1;
         checkType(l, 1, out a1);
         System.Int32 a2;
         checkType(l, 2, out a2);
         o = new UnityEngine.Jobs.TransformAccessArray(a1, a2);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
            public unsafe static void Execute(ref T jobData, IntPtr jobData2, IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex)
            {
                IntPtr transformArrayIntPtr;

                UnsafeUtility.CopyPtrToStructure <IntPtr>(jobData2, out transformArrayIntPtr);
                int *            ptr  = (int *)((void *)TransformAccessArray.GetSortedToUserIndex(transformArrayIntPtr));
                TransformAccess *ptr2 = (TransformAccess *)((void *)TransformAccessArray.GetSortedTransformAccess(transformArrayIntPtr));
                int num;
                int num2;

                JobsUtility.GetJobRange(ref ranges, jobIndex, out num, out num2);
                for (int i = num; i < num2; i++)
                {
                    int num3 = i;
                    int num4 = ptr[num3];
                    JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf <T>(ref jobData), num4, 1);
                    jobData.Execute(num4, ptr2[num3]);
                }
            }
            public static unsafe void Execute(ref T jobData, System.IntPtr jobData2, System.IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex)
            {
                UnsafeUtility.CopyPtrToStructure((void *)jobData2, out TransformJobData transformJobData);

                int *            sortedToUserIndex     = (int *)TransformAccessArray.GetSortedToUserIndex(transformJobData.TransformAccessArray);
                TransformAccess *sortedTransformAccess = (TransformAccess *)TransformAccessArray.GetSortedTransformAccess(transformJobData.TransformAccessArray);

                if (transformJobData.IsReadOnly == 1)
                {
                    while (true)
                    {
                        if (!JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out var begin, out var end))
                        {
                            break;
                        }

                        var endThatCompilerCanSeeWillNeverChange = end;
                        for (var i = begin; i < endThatCompilerCanSeeWillNeverChange; ++i)
                        {
                            int sortedIndex = i;
                            int userIndex   = sortedToUserIndex[sortedIndex];
                            JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf(ref jobData), userIndex, 1);
                            var transformAccess = sortedTransformAccess[sortedIndex];
                            transformAccess.MarkReadOnly();
                            jobData.Execute(userIndex, transformAccess);
                        }
                    }
                }
                else
                {
                    JobsUtility.GetJobRange(ref ranges, jobIndex, out var begin, out var end);
                    for (int i = begin; i < end; i++)
                    {
                        int sortedIndex = i;
                        int userIndex   = sortedToUserIndex[sortedIndex];
                        JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf(ref jobData), userIndex, 1);
                        var transformAccess = sortedTransformAccess[sortedIndex];
                        transformAccess.MarkReadWrite();
                        jobData.Execute(userIndex, transformAccess);
                    }
                }
            }
            public static unsafe void Execute(ref T jobData, System.IntPtr jobData2, System.IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex)
            {
                IntPtr transformAccessArray;

                UnsafeUtility.CopyPtrToStructure((void *)jobData2, out transformAccessArray);

                int *            sortedToUserIndex     = (int *)TransformAccessArray.GetSortedToUserIndex(transformAccessArray);
                TransformAccess *sortedTransformAccess = (TransformAccess *)TransformAccessArray.GetSortedTransformAccess(transformAccessArray);

                int begin;
                int end;

                JobsUtility.GetJobRange(ref ranges, jobIndex, out begin, out end);
                for (int i = begin; i < end; i++)
                {
                    int sortedIndex = i;
                    int userIndex   = sortedToUserIndex[sortedIndex];

                    jobData.Execute(userIndex, sortedTransformAccess[sortedIndex]);
                }
            }
Пример #10
0
 static public int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Jobs.TransformAccessArray o;
         if (matchType(l, "ctor__Arr_Transform__Int32", argc, 2, typeof(UnityEngine.Transform[]), typeof(int)))
         {
             UnityEngine.Transform[] a1;
             checkArray(l, 3, out a1);
             System.Int32 a2;
             checkType(l, 4, out a2);
             o = new UnityEngine.Jobs.TransformAccessArray(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (matchType(l, "ctor__Int32__Int32", argc, 2, typeof(int), typeof(int)))
         {
             System.Int32 a1;
             checkType(l, 3, out a1);
             System.Int32 a2;
             checkType(l, 4, out a2);
             o = new UnityEngine.Jobs.TransformAccessArray(a1, a2);
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         else if (argc <= 2)
         {
             o = new UnityEngine.Jobs.TransformAccessArray();
             pushValue(l, true);
             pushValue(l, o);
             return(2);
         }
         return(error(l, "New object failed."));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #11
0
    // 初期化処理など
    void Start()
    {
        // ターゲットのFPSを指定します
        Application.targetFrameRate = targetFps;
        Screen.sleepTimeout         = SleepTimeout.NeverSleep;
        if (isLowResolution)
        {
            Screen.SetResolution(Screen.width / 4, Screen.height / 4, true);
        }
        // デフォルト挙動セット
        this.executeMethod = this.defaultMode;
        Resources.FindObjectsOfTypeAll <UnityEngine.UI.Dropdown>()[0].value = (int)this.defaultMode;
        // ログファイル名指定
        BatteryLogger.Instance.LogFile = this.logFileName;

        // 操作対象のtransformの作成を行います
        transformArray = new Transform[objectNum];
        for (int i = 0; i < objectNum; ++i)
        {
            GameObject gmo = Object.Instantiate <GameObject>(prefab);
            transformArray[i] = gmo.transform;
        }


        // TransformJobの為に、TransformAccessArrayを事前に生成しておきます
        #region TRANSFORM_JOB
        transformAccessArray = new UnityEngine.Jobs.TransformAccessArray(objectNum, 0);
        for (int i = 0; i < objectNum; ++i)
        {
            transformAccessArray.Add(transformArray[i]);
        }
        #endregion TRANSFORM_JOB

        // 座標計算等を並行処理させるために、事前に計算用のワークを確保しておきます
        #region ARRAY_JOB
        myStructNativeArray = new Unity.Collections.NativeArray <MyStruct>(objectNum, Unity.Collections.Allocator.Persistent);
        #endregion ARRAY_JOB
    }
 public static void RunReadOnly <T>(this T jobData, TransformAccessArray transforms) where T : struct, IJobParallelForTransform
 {
     JobsUtility.JobScheduleParameters jobScheduleParameters = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf <T>(ref jobData), IJobParallelForTransformExtensions.TransformParallelForLoopStruct <T> .Initialize(), default(JobHandle), ScheduleMode.Run);
     JobsUtility.ScheduleParallelForTransformReadOnly(ref jobScheduleParameters, transforms.GetTransformAccessArrayForSchedule(), transforms.length);
 }
Пример #13
0
 public void Dispose()
 {
     DisposeSentinel.Dispose(this.m_Safety, ref this.m_DisposeSentinel);
     TransformAccessArray.DestroyTransformAccessArray(this.m_TransformArray);
     this.m_TransformArray = IntPtr.Zero;
 }
 public static unsafe void RunReadOnly <T>(this T jobData, TransformAccessArray transforms) where T : struct, IJobParallelForTransform
 {
     var scheduleParams = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf(ref jobData), GetReflectionData <T>(), default, ScheduleMode.Run);
Пример #15
0
 public TransformAccessArray(int capacity, int desiredJobCount = -1)
 {
     TransformAccessArray.Allocate(capacity, desiredJobCount, out this);
 }
 public static JobHandle ScheduleReadOnly <T>(this T jobData, TransformAccessArray transforms, int batchSize, JobHandle dependsOn = default(JobHandle)) where T : struct, IJobParallelForTransform
 {
     JobsUtility.JobScheduleParameters jobScheduleParameters = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf <T>(ref jobData), IJobParallelForTransformExtensions.TransformParallelForLoopStruct <T> .Initialize(), dependsOn, ScheduleMode.Batched);
     return(JobsUtility.ScheduleParallelForTransformReadOnly(ref jobScheduleParameters, transforms.GetTransformAccessArrayForSchedule(), batchSize));
 }
 public static void Allocate(int capacity, int desiredJobCount, out TransformAccessArray array)
 {
     array.m_TransformArray = Create(capacity, desiredJobCount);
 }
Пример #18
0
 public void SetTransforms(Transform[] transforms)
 {
     AtomicSafetyHandle.CheckWriteAndThrow(this.m_Safety);
     TransformAccessArray.SetTransforms(this.m_TransformArray, transforms);
 }
Пример #19
0
 public void RemoveAtSwapBack(int index)
 {
     AtomicSafetyHandle.CheckWriteAndThrow(this.m_Safety);
     TransformAccessArray.RemoveAtSwapBack(this.m_TransformArray, index);
 }
Пример #20
0
 public void Add(Transform transform)
 {
     AtomicSafetyHandle.CheckWriteAndThrow(this.m_Safety);
     TransformAccessArray.Add(this.m_TransformArray, transform);
 }
        unsafe static public JobHandle Schedule <T>(this T jobData, TransformAccessArray transforms, JobHandle dependsOn = new JobHandle()) where T : struct, IJobParallelForTransform
        {
            var scheduleParams = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf(ref jobData), TransformParallelForLoopStruct <T> .Initialize(), dependsOn, ScheduleMode.Batched);

            return(JobsUtility.ScheduleParallelForTransform(ref scheduleParams, transforms.GetTransformAccessArrayForSchedule()));
        }
        public static void Allocate(int capacity, int desiredJobCount, out TransformAccessArray array)
        {
            array.m_TransformArray = Create(capacity, desiredJobCount);

            AtomicSafetyHandle.CreateHandle(out array.m_Safety, Allocator.Persistent);
        }
        public static unsafe JobHandle ScheduleReadOnly <T>(this T jobData, TransformAccessArray transforms, int batchSize, JobHandle dependsOn = new JobHandle()) where T : struct, IJobParallelForTransform
        {
            var scheduleParams = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf(ref jobData), GetReflectionData <T>(), dependsOn, ScheduleMode.Parallel);

            return(JobsUtility.ScheduleParallelForTransformReadOnly(ref scheduleParams, transforms.GetTransformAccessArrayForSchedule(), batchSize));
        }
Пример #24
0
        public static void Allocate(int capacity, int desiredJobCount, out TransformAccessArray array)
        {
            array.m_TransformArray = Create(capacity, desiredJobCount);

            DisposeSentinel.Create(out array.m_Safety, out array.m_DisposeSentinel, 1, Allocator.Persistent);
        }
Пример #25
0
 public TransformAccessArray(Transform[] transforms, int desiredJobCount = -1)
 {
     TransformAccessArray.Allocate(transforms.Length, desiredJobCount, out this);
     TransformAccessArray.SetTransforms(this.m_TransformArray, transforms);
 }