diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs index 5ede775c..2ff26f04 100644 --- a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs @@ -18,7 +18,7 @@ namespace ComputeSharp.Graphics.Buffers /// /// The associated with the current instance /// The number of items to store in the current buffer - internal ReadOnlyBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf() / 16 + 1), HeapType.Upload) + internal ReadOnlyBuffer(GraphicsDevice device, int size) : base(device, size, size * (Unsafe.SizeOf() / 16 + 1) * 16, HeapType.Upload) { PaddedElementSizeInBytes = SizeInBytes / Size; } @@ -61,7 +61,7 @@ namespace ComputeSharp.Graphics.Buffers public override void SetData(Span span) { byte[] temporaryArray = ArrayPool.Shared.Rent(SizeInBytes); - Span temporarySpan = temporaryArray.AsSpan(); + Span temporarySpan = temporaryArray.AsSpan(0, SizeInBytes); // Array pool arrays can be longer ref T tin = ref span.GetPinnableReference(); ref byte tout = ref temporarySpan.GetPinnableReference();