diff --git a/src/Aardvark.Rendering/Resources/Adaptive/AdaptiveBuffer.fs b/src/Aardvark.Rendering/Resources/Adaptive/AdaptiveBuffer.fs index 0c10d6ec..2ff67f72 100644 --- a/src/Aardvark.Rendering/Resources/Adaptive/AdaptiveBuffer.fs +++ b/src/Aardvark.Rendering/Resources/Adaptive/AdaptiveBuffer.fs @@ -59,9 +59,10 @@ type AdaptiveBufferExtensions private() = assert (start >= 0 && start < data.Length) assert (start + length <= data.Length) - (start, data) ||> NativePtr.pinArri (fun src -> - let size = nativeint (length * sizeof<'T>) - this.Write(src.Address, offset, size) + if length > 0 then + (start, data) ||> NativePtr.pinArri (fun src -> + let size = nativeint (length * sizeof<'T>) + this.Write(src.Address, offset, size) ) /// diff --git a/src/Aardvark.Rendering/Resources/Buffers/BufferExtensions.fs b/src/Aardvark.Rendering/Resources/Buffers/BufferExtensions.fs index c9509299..2282fa8a 100644 --- a/src/Aardvark.Rendering/Resources/Buffers/BufferExtensions.fs +++ b/src/Aardvark.Rendering/Resources/Buffers/BufferExtensions.fs @@ -113,9 +113,10 @@ type IBufferRangeExtensions private() = srcIndex |> checkNonNegative "srcIndex" (srcIndex, count) ||> checkArrayBounds src - (srcIndex, src) ||> NativePtr.pinArri (fun pSrc -> - dst.Buffer.Upload(dst.Offset + byteSize<'T> dstIndex, pSrc.Address, byteSize<'T> count) - ) + if count > 0 then + (srcIndex, src) ||> NativePtr.pinArri (fun pSrc -> + dst.Buffer.Upload(dst.Offset + byteSize<'T> dstIndex, pSrc.Address, byteSize<'T> count) + ) ///Copies elements from an array to a buffer range. ///The buffer range to copy data to. @@ -186,9 +187,10 @@ type IBufferRangeExtensions private() = dstIndex |> checkNonNegative "dstIndex" (dstIndex, count) ||> checkArrayBounds dst - (dstIndex, dst) ||> NativePtr.pinArri (fun pDst -> - src.Buffer.Download(src.Offset + byteSize<'T> srcIndex, pDst.Address, byteSize<'T> count) - ) + if count > 0 then + (dstIndex, dst) ||> NativePtr.pinArri (fun pDst -> + src.Buffer.Download(src.Offset + byteSize<'T> srcIndex, pDst.Address, byteSize<'T> count) + ) ///Copies elements from a buffer range to an array. ///The buffer range to copy data from. @@ -249,9 +251,10 @@ type IBufferRangeExtensions private() = dstIndex |> checkNonNegative "dstIndex" (dstIndex, count) ||> checkArrayBounds dst - (dstIndex, dst) ||> NativePtr.pinArri (fun pDst -> - src.Buffer.DownloadAsync(src.Offset + byteSize<'T> srcIndex, pDst.Address, byteSize<'T> count) - ) + if count > 0 then + (dstIndex, dst) ||> NativePtr.pinArri (fun pDst -> + src.Buffer.DownloadAsync(src.Offset + byteSize<'T> srcIndex, pDst.Address, byteSize<'T> count) + ) ///Asynchronously copies elements from a buffer range to an array. ///The buffer range to copy data from.