Пример #1
0
        public static ComputeBuffer GetTempPropertyBuffer(int length, int stride, ComputeBufferType type = ComputeBufferType.Default)
        {
            if (!allTempBuffers.isCreated)
            {
                allTempBuffers = new NativeDictionary <BufferKey, int, BufferKey.Equal>(11, Allocator.Persistent, new BufferKey.Equal());
            }
            ComputeBuffer target;
            int           targetIndex;

            if (allTempBuffers.Get(new BufferKey {
                size = stride, type = type
            }, out targetIndex))
            {
                target = MUnsafeUtility.GetHookedObject(targetIndex) as ComputeBuffer;
                if (target.count < length)
                {
                    target.Dispose();
                    target = new ComputeBuffer(length, stride, type);
                    MUnsafeUtility.SetHookedObject(targetIndex, target);
                }
                return(target);
            }
            else
            {
                target            = new ComputeBuffer(length, stride);
                allTempBuffers[new BufferKey {
                                   size = stride, type = type
                               }] = MUnsafeUtility.HookObject(target);
                return(target);
            }
        }
Пример #2
0
 public static int GetMoveCountBuffer()
 {
     if (baseBuffer.moveCountBuffers.Length > 0)
     {
         int index = baseBuffer.moveCountBuffers[baseBuffer.moveCountBuffers.Length - 1];
         baseBuffer.moveCountBuffers.RemoveLast();
         return(index);
     }
     else
     {
         ComputeBuffer cb = new ComputeBuffer(5, sizeof(int), ComputeBufferType.IndirectArguments);
         return(MUnsafeUtility.HookObject(cb));
     }
 }
Пример #3
0
        public static T GetProperty <T, R>(PipelineCamera camera, R runnable) where T : IPerCameraData where R : struct, IGetCameraData
        {
            int            index;
            IPerCameraData data;

            if (!camera.allDatas.isCreated)
            {
                camera.allDatas = new NativeDictionary <ulong, int, PipelineCamera.PtrEqual>(20, Unity.Collections.Allocator.Persistent, new PipelineCamera.PtrEqual());
            }
            if (!camera.allDatas.Get((ulong)MUnsafeUtility.GetManagedPtr(typeof(T)), out index))
            {
                data  = runnable.Run();
                index = MUnsafeUtility.HookObject(data);
                camera.allDatas.Add((ulong)MUnsafeUtility.GetManagedPtr(typeof(T)), index);
            }
            return(MUnsafeUtility.GetHookedObject(index) as T);
        }