diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs index 9a7d76fc..152c3681 100644 --- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs +++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs @@ -58,7 +58,7 @@ namespace ComputeSharp.Graphics.Buffers ref T tout = ref span.GetPinnableReference(); // Copy the padded data to the target span, removing the padding - for (int i = 0; i < Size; i++) + for (int i = 0; i < count; i++) { ref byte rsource = ref Unsafe.Add(ref tin, i * PaddedElementSizeInBytes); Unsafe.Add(ref tout, i) = Unsafe.As(ref rsource); @@ -87,7 +87,7 @@ namespace ComputeSharp.Graphics.Buffers ref byte tout = ref temporarySpan.GetPinnableReference(); // Copy the input data to the temporary array and add the padding - for (int i = 0; i < Size; i++) + for (int i = 0; i < count; i++) { ref byte rtarget = ref Unsafe.Add(ref tout, i * PaddedElementSizeInBytes); Unsafe.As(ref rtarget) = Unsafe.Add(ref tin, i);