public unsafe static AsyncGPUReadbackRequest RequestIntoNativeSlice <T>(ref NativeSlice <T> output, Texture src, int mipIndex = 0, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
        {
            AsyncRequestNativeArrayData asyncRequestNativeArrayData = AsyncRequestNativeArrayData.CreateAndCheckAccess <T>(output);
            AsyncGPUReadbackRequest     result = AsyncGPUReadback.Request_Internal_Texture_1(src, mipIndex, &asyncRequestNativeArrayData);

            result.SetScriptingCallback(callback);
            return(result);
        }
        public unsafe static AsyncGPUReadbackRequest RequestIntoNativeSlice <T>(ref NativeSlice <T> output, GraphicsBuffer src, int size, int offset, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
        {
            AsyncRequestNativeArrayData asyncRequestNativeArrayData = AsyncRequestNativeArrayData.CreateAndCheckAccess <T>(output);
            AsyncGPUReadbackRequest     result = AsyncGPUReadback.Request_Internal_GraphicsBuffer_2(src, size, offset, &asyncRequestNativeArrayData);

            result.SetScriptingCallback(callback);
            return(result);
        }
        public unsafe static AsyncGPUReadbackRequest RequestIntoNativeArray <T>(ref NativeArray <T> output, ComputeBuffer src, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
        {
            AsyncRequestNativeArrayData asyncRequestNativeArrayData = AsyncRequestNativeArrayData.CreateAndCheckAccess <T>(output);
            AsyncGPUReadbackRequest     result = AsyncGPUReadback.Request_Internal_ComputeBuffer_1(src, &asyncRequestNativeArrayData);

            result.SetScriptingCallback(callback);
            return(result);
        }
        public unsafe static AsyncGPUReadbackRequest RequestIntoNativeSlice <T>(ref NativeSlice <T> output, Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, GraphicsFormat dstFormat, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
        {
            AsyncGPUReadback.ValidateFormat(src, dstFormat);
            AsyncRequestNativeArrayData asyncRequestNativeArrayData = AsyncRequestNativeArrayData.CreateAndCheckAccess <T>(output);
            AsyncGPUReadbackRequest     result = AsyncGPUReadback.Request_Internal_Texture_4(src, mipIndex, x, width, y, height, z, depth, dstFormat, &asyncRequestNativeArrayData);

            result.SetScriptingCallback(callback);
            return(result);
        }
 static public AsyncGPUReadbackRequest RequestIntoNativeArray <T>(ref NativeArray <T> output, GraphicsBuffer src, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
 {
     unsafe
     {
         var data = AsyncRequestNativeArrayData.CreateAndCheckAccess(output);
         AsyncGPUReadbackRequest request = Request_Internal_GraphicsBuffer_1(src, &data);
         request.SetScriptingCallback(callback);
         return(request);
     }
 }
 static public AsyncGPUReadbackRequest RequestIntoNativeSlice <T>(ref NativeSlice <T> output, ComputeBuffer src, int size, int offset, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
 {
     unsafe
     {
         var data = AsyncRequestNativeArrayData.CreateAndCheckAccess(output);
         AsyncGPUReadbackRequest request = Request_Internal_ComputeBuffer_2(src, size, offset, &data);
         request.SetScriptingCallback(callback);
         return(request);
     }
 }
 static public AsyncGPUReadbackRequest RequestIntoNativeArray <T>(ref NativeArray <T> output, Texture src, int mipIndex, GraphicsFormat dstFormat, Action <AsyncGPUReadbackRequest> callback = null) where T : struct
 {
     ValidateFormat(src, dstFormat);
     unsafe
     {
         var data = AsyncRequestNativeArrayData.CreateAndCheckAccess(output);
         AsyncGPUReadbackRequest request = Request_Internal_Texture_2(src, mipIndex, dstFormat, &data);
         request.SetScriptingCallback(callback);
         return(request);
     }
 }
        public static AsyncRequestNativeArrayData CreateAndCheckAccess <T>(NativeArray <T> array) where T : struct
        {
            var nativeArrayData = new AsyncRequestNativeArrayData();

            nativeArrayData.nativeArrayBuffer = array.GetUnsafePtr();
            nativeArrayData.lengthInBytes     = array.Length * UnsafeUtility.SizeOf <T>();
            var handle     = NativeArrayUnsafeUtility.GetAtomicSafetyHandle(array);
            var versionPtr = (int *)handle.versionNode;

            if (handle.version != ((*versionPtr) & AtomicSafetyHandle.WriteCheck))
            {
                AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut(handle);
            }
            nativeArrayData.safetyHandle = handle;
            return(nativeArrayData);
        }
        public unsafe static AsyncRequestNativeArrayData CreateAndCheckAccess <T>(NativeSlice <T> array) where T : struct
        {
            AsyncRequestNativeArrayData result = default(AsyncRequestNativeArrayData);

            result.nativeArrayBuffer = array.GetUnsafePtr <T>();
            result.lengthInBytes     = (long)array.Length * (long)UnsafeUtility.SizeOf <T>();
            AtomicSafetyHandle atomicSafetyHandle = NativeSliceUnsafeUtility.GetAtomicSafetyHandle <T>(array);
            int *ptr  = (int *)((void *)atomicSafetyHandle.versionNode);
            bool flag = atomicSafetyHandle.version != (*ptr & -6);

            if (flag)
            {
                AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut(atomicSafetyHandle);
            }
            result.safetyHandle = atomicSafetyHandle;
            return(result);
        }
        public static AsyncRequestNativeArrayData CreateAndCheckAccess <T>(NativeArray <T> array) where T : struct
        {
            if (array.m_AllocatorLabel == Allocator.Temp || array.m_AllocatorLabel == Allocator.TempJob)
            {
                throw new ArgumentException("AsyncGPUReadback cannot use Temp memory as input since the result may only become available at an unspecified point in the future.");
            }
            var nativeArrayData = new AsyncRequestNativeArrayData();

            nativeArrayData.nativeArrayBuffer = array.GetUnsafePtr();
            nativeArrayData.lengthInBytes     = (long)array.Length * UnsafeUtility.SizeOf <T>();
            var handle     = NativeArrayUnsafeUtility.GetAtomicSafetyHandle(array);
            var versionPtr = (int *)handle.versionNode;

            if (handle.version != ((*versionPtr) & AtomicSafetyHandle.WriteCheck))
            {
                AtomicSafetyHandle.CheckWriteAndThrowNoEarlyOut(handle);
            }
            nativeArrayData.safetyHandle = handle;
            return(nativeArrayData);
        }