diff --git a/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs
index ce6cba9f..90707aec 100644
--- a/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/BufferExtensions.cs
@@ -15,32 +15,32 @@ public static class BufferExtensions
/// Reads the contents of a instance and returns an array.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// A array with the contents of the input buffer.
[Pure]
- public static T[] ToArray(this Buffer buffer)
+ public static T[] ToArray(this Buffer source)
where T : unmanaged
{
- return buffer.ToArray(0, buffer.Length);
+ return source.ToArray(0, source.Length);
}
///
/// Reads the contents of a instance in a given range and returns an array.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The offset to start reading data from.
/// The number of items to read.
/// A array with the contents of the specified range from the current buffer.
[Pure]
- public static T[] ToArray(this Buffer buffer, int offset, int count)
+ public static T[] ToArray(this Buffer source, int offset, int count)
where T : unmanaged
{
Guard.IsGreaterThanOrEqualTo(count, 0, nameof(count));
T[] data = GC.AllocateUninitializedArray(count);
- buffer.CopyTo(data.AsSpan(), offset);
+ source.CopyTo(data.AsSpan(), offset);
return data;
}
@@ -49,161 +49,161 @@ public static class BufferExtensions
/// Reads the contents of a instance and writes them into a target array.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The input array to write data to.
- public static void CopyTo(this Buffer buffer, T[] destination)
+ public static void CopyTo(this Buffer source, T[] destination)
where T : unmanaged
{
- buffer.CopyTo(destination.AsSpan(), 0);
+ source.CopyTo(destination.AsSpan(), 0);
}
///
/// Reads the contents of the specified range from a instance and writes them into a target array.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The input array to write data to.
/// The offset to start reading data from.
/// The starting offset within to write data to.
/// The number of items to read.
- public static void CopyTo(this Buffer buffer, T[] destination, int sourceOffset, int destinationOffset, int count)
+ public static void CopyTo(this Buffer source, T[] destination, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
Span span = destination.AsSpan(destinationOffset, count);
- buffer.CopyTo(span, sourceOffset);
+ source.CopyTo(span, sourceOffset);
}
///
/// Reads the contents of a instance and writes them into a target .
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The input to write data to.
- public static void CopyTo(this Buffer buffer, Span destination)
+ public static void CopyTo(this Buffer source, Span destination)
where T : unmanaged
{
- buffer.CopyTo(destination, 0);
+ source.CopyTo(destination, 0);
}
///
/// Reads the contents of the specified range from a instance and writes them into a target .
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The input to write data to.
- /// The offset to start reading data from.
- public static void CopyTo(this Buffer buffer, Span destination, int offset)
+ /// The offset to start reading data from.
+ public static void CopyTo(this Buffer source, Span destination, int sourceOffset)
where T : unmanaged
{
- buffer.CopyTo(ref MemoryMarshal.GetReference(destination), destination.Length, offset);
+ source.CopyTo(ref MemoryMarshal.GetReference(destination), sourceOffset, destination.Length);
}
///
/// Reads the contents of the specified instance and copies them to the target instance.
///
/// The type of items stored on the buffers.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
- public static void CopyTo(this Buffer buffer, Buffer destination)
+ public static void CopyTo(this Buffer source, Buffer destination)
where T : unmanaged
{
- buffer.CopyTo(destination, 0, 0, buffer.Length);
+ source.CopyTo(destination, 0, 0, source.Length);
}
///
/// Reads the contents of the specified range from a instance and copies them to the target instance.
///
/// The type of items stored on the buffers.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
/// The offset to start reading data from.
/// The starting offset within to write data to.
/// The number of items to read.
- public static void CopyTo(this Buffer buffer, Buffer destination, int sourceOffset, int destinationOffset, int count)
+ public static void CopyTo(this Buffer source, Buffer destination, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
- buffer.CopyTo(destination, sourceOffset, destinationOffset, count);
+ source.CopyTo(destination, sourceOffset, destinationOffset, count);
}
///
/// Writes the contents of a given array to a instance.
///
/// The type of items stored on the buffer.
- /// The target instance to write data to.
+ /// The target instance to write data to.
/// The input array to read data from.
- public static void CopyFrom(this Buffer buffer, T[] source)
+ public static void CopyFrom(this Buffer destination, T[] source)
where T : unmanaged
{
- buffer.CopyFrom(source.AsSpan(), 0);
+ destination.CopyFrom(source.AsSpan(), 0);
}
///
/// Writes the contents of a given array to a specified area of a instance.
///
/// The type of items stored on the buffer.
- /// The target instance to write data to.
+ /// The target instance to write data to.
/// The input array to read data from.
/// The starting offset within to read data from.
- /// The offset to start writing data to.
+ /// The offset to start writing data to.
/// The number of items to write.
- public static void CopyFrom(this Buffer buffer, T[] source, int sourceOffset, int bufferOffset, int count)
+ public static void CopyFrom(this Buffer destination, T[] source, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
ReadOnlySpan span = source.AsSpan(sourceOffset, count);
- buffer.CopyFrom(span, bufferOffset);
+ destination.CopyFrom(span, destinationOffset);
}
///
/// Writes the contents of a given to a instance.
///
/// The type of items stored on the buffer.
- /// The target instance to write data to.
+ /// The target instance to write data to.
/// The input to read data from.
- public static void CopyFrom(this Buffer buffer, ReadOnlySpan source)
+ public static void CopyFrom(this Buffer destination, ReadOnlySpan source)
where T : unmanaged
{
- buffer.CopyFrom(source, 0);
+ destination.CopyFrom(source, 0);
}
///
/// Writes the contents of a given to a specified area of a instance.
///
/// The type of items stored on the buffer.
- /// The target instance to write data to.
+ /// The target instance to write data to.
/// The input to read data from.
- /// The offset to start writing data to.
- public static void CopyFrom(this Buffer buffer, ReadOnlySpan source, int offset)
+ /// The offset to start writing data to.
+ public static void CopyFrom(this Buffer destination, ReadOnlySpan source, int destinationOffset)
where T : unmanaged
{
- buffer.CopyFrom(ref MemoryMarshal.GetReference(source), source.Length, offset);
+ destination.CopyFrom(ref MemoryMarshal.GetReference(source), destinationOffset, source.Length);
}
///
/// Writes the contents of the specified instance to the curreent instance.
///
/// The type of items stored on the buffers.
- /// The input instance to write data data to.
+ /// The input instance to write data data to.
/// The source instance to read data from.
- public static void CopyFrom(this Buffer buffer, Buffer source)
+ public static void CopyFrom(this Buffer destination, Buffer source)
where T : unmanaged
{
- source.CopyTo(buffer, 0, 0, source.Length);
+ source.CopyTo(destination, 0, 0, source.Length);
}
///
/// Writes the contents of the specified range from a instance and copies them to the current instance.
///
/// The type of items stored on the buffers.
- /// The input instance to write data to.
+ /// The input instance to write data to.
/// The source instance to read data from.
/// The offset to start reading data from.
- /// The starting offset within to write data to.
+ /// The starting offset within to write data to.
/// The number of items to read.
- public static void CopyFrom(this Buffer buffer, Buffer source, int sourceOffset, int destinationOffset, int count)
+ public static void CopyFrom(this Buffer destination, Buffer source, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
- source.CopyTo(buffer, sourceOffset, destinationOffset, count);
+ source.CopyTo(destination, sourceOffset, destinationOffset, count);
}
}
diff --git a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs
index bde72b1f..3438e4ff 100644
--- a/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/StructuredBufferExtensions.cs
@@ -11,26 +11,26 @@ public static class StructuredBufferExtensions
/// Reads the contents of a instance and writes them into a target instance.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
- public static void CopyTo(this StructuredBuffer buffer, ReadBackBuffer destination)
+ public static void CopyTo(this StructuredBuffer source, ReadBackBuffer destination)
where T : unmanaged
{
- buffer.CopyTo(destination, 0, buffer.Length, 0);
+ source.CopyTo(destination, 0, 0, source.Length);
}
///
/// Reads the contents of a instance and writes them into a target instance.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
+ /// The offset to start reading data from.
/// The starting offset within to write data to.
- /// The offset to start reading data from.
/// The number of items to read.
- public static void CopyTo(this StructuredBuffer buffer, ReadBackBuffer destination, int destinationOffset, int bufferOffset, int count)
+ public static void CopyTo(this StructuredBuffer source, ReadBackBuffer destination, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
- buffer.CopyTo(destination, destinationOffset, count, bufferOffset);
+ source.CopyTo(destination, sourceOffset, destinationOffset, count);
}
}
diff --git a/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs b/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs
index 6dc443e8..10054354 100644
--- a/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs
+++ b/src/ComputeSharp/Graphics/Extensions/UploadBufferExtensions.cs
@@ -11,26 +11,26 @@ public static class UploadBufferExtensions
/// Reads the contents of a instance and writes them into a target instance.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
- public static void CopyTo(this UploadBuffer buffer, StructuredBuffer destination)
+ public static void CopyTo(this UploadBuffer source, StructuredBuffer destination)
where T : unmanaged
{
- destination.CopyFrom(buffer, 0, buffer.Length, 0);
+ destination.CopyFrom(source, 0, 0, source.Length);
}
///
/// Reads the contents of a instance and writes them into a target instance.
///
/// The type of items stored on the buffer.
- /// The input instance to read data from.
+ /// The input instance to read data from.
/// The target instance to write data to.
+ /// The offset to start reading data from.
/// The starting offset within to write data to.
- /// The offset to start reading data from.
/// The number of items to read.
- public static void CopyTo(this UploadBuffer buffer, StructuredBuffer destination, int destinationOffset, int bufferOffset, int count)
+ public static void CopyTo(this UploadBuffer source, StructuredBuffer destination, int sourceOffset, int destinationOffset, int count)
where T : unmanaged
{
- destination.CopyFrom(buffer, bufferOffset, count, destinationOffset);
+ destination.CopyFrom(source, sourceOffset, destinationOffset, count);
}
}
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
index 8a245512..ce442d70 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/Buffer{T}.cs
@@ -126,9 +126,9 @@ public unsafe abstract class Buffer : NativeObject
/// Reads the contents of the specified range from the current instance and writes them into a target memory area.
///
/// The input memory area to write data to.
- /// The length of the memory area to write data to.
- /// The offset to start reading data from.
- internal abstract void CopyTo(ref T destination, int length, int offset);
+ /// The offset to start reading data from.
+ /// The length of the memory area to write data to.
+ internal abstract void CopyTo(ref T destination, int sourceOffset, int count);
///
/// Writes the contents of a given range from the current instance and writes them into a target instance.
@@ -136,8 +136,8 @@ public unsafe abstract class Buffer : NativeObject
/// The target instance to write data to.
/// The offset to start reading data from.
/// The starting offset within to write data to.
- /// The number of items to read.
- internal abstract void CopyTo(Buffer destination, int sourceOffset, int destinationOffset, int length);
+ /// The number of items to read.
+ internal abstract void CopyTo(Buffer destination, int sourceOffset, int destinationOffset, int count);
///
/// Writes the contents of a given range from the current instance and writes them into a target instance, using a temporary CPU buffer.
@@ -145,18 +145,18 @@ public unsafe abstract class Buffer : NativeObject
/// The target instance to write data to.
/// The offset to start reading data from.
/// The starting offset within to write data to.
- /// The number of items to read.
- protected void CopyToWithCpuBuffer(Buffer destination, int sourceOffset, int destinationOffset, int length)
+ /// The number of items to read.
+ protected void CopyToWithCpuBuffer(Buffer destination, int sourceOffset, int destinationOffset, int count)
{
- T[] array = ArrayPool.Shared.Rent(length);
+ T[] array = ArrayPool.Shared.Rent(count);
try
{
ref T r0 = ref MemoryMarshal.GetArrayDataReference(array);
- CopyTo(ref r0, length, sourceOffset);
+ CopyTo(ref r0, sourceOffset, count);
- destination.CopyFrom(ref r0, length, destinationOffset);
+ destination.CopyFrom(ref r0, destinationOffset, count);
}
finally
{
@@ -168,9 +168,9 @@ public unsafe abstract class Buffer : NativeObject
/// Writes the contents of a given memory area to a specified area of the current instance.
///
/// The input memory area to read data from.
- /// The length of the input memory area to read data from.
- /// The offset to start writing data to.
- internal abstract void CopyFrom(ref T source, int length, int offset);
+ /// The offset to start writing data to.
+ /// The length of the input memory area to read data from.
+ internal abstract void CopyFrom(ref T source, int destinationOffset, int count);
///
protected override void OnDispose()
diff --git a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
index 30a01823..4992bab5 100644
--- a/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Abstract/StructuredBuffer{T}.cs
@@ -30,15 +30,15 @@ public abstract class StructuredBuffer : Buffer
}
///
- internal override unsafe void CopyTo(ref T destination, int length, int offset)
+ internal override unsafe void CopyTo(ref T destination, int sourceOffset, int count)
{
GraphicsDevice.ThrowIfDisposed();
ThrowIfDisposed();
- Guard.IsBetweenOrEqualTo(length, 0, Length, nameof(length));
- Guard.IsInRange(offset, 0, Length, nameof(offset));
- Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(offset));
+ Guard.IsBetweenOrEqualTo(count, 0, Length, nameof(count));
+ Guard.IsInRange(sourceOffset, 0, Length, nameof(sourceOffset));
+ Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
if (GraphicsDevice.IsCacheCoherentUMA)
{
@@ -49,17 +49,17 @@ public abstract class StructuredBuffer : Buffer
MemoryHelper.Copy(
source: resource.Pointer,
destination: destinationPointer,
- sourceElementOffset: (uint)offset,
+ sourceElementOffset: (uint)sourceOffset,
destinationElementOffset: 0,
sourceElementPitchInBytes: (uint)sizeof(T),
destinationElementPitchInBytes: (uint)sizeof(T),
- count: (uint)length);
+ count: (uint)count);
}
}
else
{
- nint byteOffset = (nint)offset * sizeof(T);
- nint byteLength = length * sizeof(T);
+ nint byteOffset = (nint)sourceOffset * sizeof(T);
+ nint byteLength = count * sizeof(T);
using UniquePtr allocation = GraphicsDevice.Allocator->CreateResource(null, ResourceType.ReadBack, AllocationMode.Default, (ulong)byteLength);
@@ -80,13 +80,13 @@ public abstract class StructuredBuffer : Buffer
destinationElementOffset: 0,
sourceElementPitchInBytes: (uint)sizeof(T),
destinationElementPitchInBytes: (uint)sizeof(T),
- count: (uint)length);
+ count: (uint)count);
}
}
}
///
- internal override unsafe void CopyTo(Buffer destination, int sourceOffset, int destinationOffset, int length)
+ internal override unsafe void CopyTo(Buffer destination, int sourceOffset, int destinationOffset, int count)
{
GraphicsDevice.ThrowIfDisposed();
@@ -95,18 +95,18 @@ public abstract class StructuredBuffer : Buffer
destination.ThrowIfDeviceMismatch(GraphicsDevice);
destination.ThrowIfDisposed();
- Guard.IsBetweenOrEqualTo(length, 0, Length, nameof(length));
- Guard.IsBetweenOrEqualTo(length, 0, destination.Length, nameof(length));
+ Guard.IsBetweenOrEqualTo(count, 0, Length, nameof(count));
+ Guard.IsBetweenOrEqualTo(count, 0, destination.Length, nameof(count));
Guard.IsInRange(sourceOffset, 0, Length, nameof(sourceOffset));
- Guard.IsLessThanOrEqualTo(sourceOffset + length, Length, nameof(sourceOffset));
+ Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, destination.Length, nameof(destinationOffset));
- Guard.IsLessThanOrEqualTo(destinationOffset + length, destination.Length, nameof(destinationOffset));
+ Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
if (!destination.IsPaddingPresent)
{
nint sourceByteOffset = (nint)sourceOffset * sizeof(T);
nint destinationByteOffset = (nint)destinationOffset * sizeof(T);
- nint byteLength = length * sizeof(T);
+ nint byteLength = count * sizeof(T);
// Directly copy the input buffer
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
@@ -120,17 +120,17 @@ public abstract class StructuredBuffer : Buffer
copyCommandList.ExecuteAndWaitForCompletion();
}
- else CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, length);
+ else CopyToWithCpuBuffer(destination, sourceOffset, destinationOffset, count);
}
///
/// Reads the contents of the specified range from the current instance and writes them into a target instance.
///
/// The target instance to write data to.
+ /// The offset to start reading data from.
/// The starting offset within to write data to.
- /// The number of items to read.
- /// The offset to start reading data from.
- internal unsafe void CopyTo(ReadBackBuffer destination, int destinationOffset, int length, int offset)
+ /// The number of items to read.
+ internal unsafe void CopyTo(ReadBackBuffer destination, int sourceOffset, int destinationOffset, int count)
{
GraphicsDevice.ThrowIfDisposed();
@@ -139,10 +139,12 @@ public abstract class StructuredBuffer : Buffer
destination.ThrowIfDeviceMismatch(GraphicsDevice);
destination.ThrowIfDisposed();
- Guard.IsInRange(offset, 0, Length, nameof(offset));
- Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(length));
+ Guard.IsBetweenOrEqualTo(count, 0, Length, nameof(count));
+ Guard.IsBetweenOrEqualTo(count, 0, destination.Length, nameof(count));
+ Guard.IsInRange(sourceOffset, 0, Length, nameof(sourceOffset));
+ Guard.IsLessThanOrEqualTo(sourceOffset + count, Length, nameof(sourceOffset));
Guard.IsInRange(destinationOffset, 0, destination.Length, nameof(destinationOffset));
- Guard.IsLessThanOrEqualTo(destinationOffset + length, destination.Length, nameof(length));
+ Guard.IsLessThanOrEqualTo(destinationOffset + count, destination.Length, nameof(destinationOffset));
if (GraphicsDevice.IsCacheCoherentUMA)
{
@@ -151,17 +153,17 @@ public abstract class StructuredBuffer : Buffer
MemoryHelper.Copy(
source: resource.Pointer,
destination: destination.MappedData,
- sourceElementOffset: (uint)offset,
+ sourceElementOffset: (uint)sourceOffset,
destinationElementOffset: (uint)destinationOffset,
sourceElementPitchInBytes: (uint)sizeof(T),
destinationElementPitchInBytes: (uint)sizeof(T),
- count: (uint)length);
+ count: (uint)count);
}
else
{
ulong byteDestinationOffset = (uint)destinationOffset * (uint)sizeof(T);
- ulong byteOffset = (uint)offset * (uint)sizeof(T);
- ulong byteLength = (uint)length * (uint)sizeof(T);
+ ulong byteOffset = (uint)sourceOffset * (uint)sizeof(T);
+ ulong byteLength = (uint)count * (uint)sizeof(T);
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
@@ -171,7 +173,7 @@ public abstract class StructuredBuffer : Buffer
}
///
- internal override unsafe void CopyFrom(ref T source, int length, int offset)
+ internal override unsafe void CopyFrom(ref T source, int offset, int length)
{
GraphicsDevice.ThrowIfDisposed();
@@ -229,9 +231,9 @@ public abstract class StructuredBuffer : Buffer
///
/// The input instance to read data from.
/// The starting offset within to read data from.
- /// The number of items to read.
- /// The offset to start reading writing data to.
- internal unsafe void CopyFrom(UploadBuffer source, int sourceOffset, int length, int offset)
+ /// The offset to start reading writing data to.
+ /// The number of items to read.
+ internal unsafe void CopyFrom(UploadBuffer source, int sourceOffset, int destinationOffset, int count)
{
GraphicsDevice.ThrowIfDisposed();
@@ -240,10 +242,12 @@ public abstract class StructuredBuffer : Buffer
source.ThrowIfDeviceMismatch(GraphicsDevice);
source.ThrowIfDisposed();
- Guard.IsInRange(offset, 0, Length, nameof(offset));
- Guard.IsLessThanOrEqualTo(offset + length, Length, nameof(length));
+ Guard.IsBetweenOrEqualTo(count, 0, Length, nameof(count));
+ Guard.IsBetweenOrEqualTo(count, 0, source.Length, nameof(count));
Guard.IsInRange(sourceOffset, 0, source.Length, nameof(sourceOffset));
- Guard.IsLessThanOrEqualTo(sourceOffset + length, source.Length, nameof(length));
+ Guard.IsLessThanOrEqualTo(sourceOffset + count, source.Length, nameof(sourceOffset));
+ Guard.IsInRange(destinationOffset, 0, Length, nameof(destinationOffset));
+ Guard.IsLessThanOrEqualTo(destinationOffset + count, Length, nameof(destinationOffset));
if (GraphicsDevice.IsCacheCoherentUMA)
{
@@ -253,16 +257,16 @@ public abstract class StructuredBuffer : Buffer
source: source.MappedData,
destination: resource.Pointer,
sourceElementOffset: (uint)sourceOffset,
- destinationElementOffset: (uint)offset,
+ destinationElementOffset: (uint)destinationOffset,
sourceElementPitchInBytes: (uint)sizeof(T),
destinationElementPitchInBytes: (uint)sizeof(T),
- count: (uint)length);
+ count: (uint)count);
}
else
{
ulong byteSourceOffset = (uint)sourceOffset * (uint)sizeof(T);
- ulong byteOffset = (uint)offset * (uint)sizeof(T);
- ulong byteLength = (uint)length * (uint)sizeof(T);
+ ulong byteOffset = (uint)destinationOffset * (uint)sizeof(T);
+ ulong byteLength = (uint)count * (uint)sizeof(T);
using CommandList copyCommandList = new(GraphicsDevice, D3D12_COMMAND_LIST_TYPE_COPY);
diff --git a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
index 87a9e671..38aa3b47 100644
--- a/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/ConstantBuffer{T}.cs
@@ -57,7 +57,7 @@ public sealed class ConstantBuffer : Buffer
}
///
- internal override unsafe void CopyTo(ref T destination, int length, int offset)
+ internal override unsafe void CopyTo(ref T destination, int offset, int length)
{
GraphicsDevice.ThrowIfDisposed();
@@ -117,7 +117,7 @@ public sealed class ConstantBuffer : Buffer
}
///
- internal override unsafe void CopyFrom(ref T source, int length, int offset)
+ internal override unsafe void CopyFrom(ref T source, int offset, int length)
{
GraphicsDevice.ThrowIfDisposed();
diff --git a/src/ComputeSharp/Graphics/Resources/Debug/BufferDebugView{T}.cs b/src/ComputeSharp/Graphics/Resources/Debug/BufferDebugView{T}.cs
index 7c761046..44a88976 100644
--- a/src/ComputeSharp/Graphics/Resources/Debug/BufferDebugView{T}.cs
+++ b/src/ComputeSharp/Graphics/Resources/Debug/BufferDebugView{T}.cs
@@ -20,7 +20,7 @@ internal sealed class BufferDebugView
{
var items = GC.AllocateUninitializedArray(buffer.Length);
- buffer.CopyTo(ref items[0], buffer.Length, 0);
+ buffer.CopyTo(ref items[0], 0, buffer.Length);
Items = items;
}
diff --git a/tests/ComputeSharp.Tests/TransferBufferTests.cs b/tests/ComputeSharp.Tests/TransferBufferTests.cs
index d3fb5e34..47cc9a66 100644
--- a/tests/ComputeSharp.Tests/TransferBufferTests.cs
+++ b/tests/ComputeSharp.Tests/TransferBufferTests.cs
@@ -124,7 +124,7 @@ public partial class TransferBufferTests
using ReadOnlyBuffer readOnlyBuffer = device.Get().AllocateReadOnlyBuffer(uploadBuffer.Length);
- uploadBuffer.CopyTo(readOnlyBuffer, destinationOffset, bufferOffset, count);
+ uploadBuffer.CopyTo(readOnlyBuffer, bufferOffset, destinationOffset, count);
int[] result = readOnlyBuffer.ToArray(destinationOffset, count);
@@ -164,7 +164,7 @@ public partial class TransferBufferTests
using ReadOnlyBuffer readOnlyBuffer = device.Get().AllocateReadOnlyBuffer(source);
using ReadBackBuffer readBackBuffer = device.Get().AllocateReadBackBuffer(readOnlyBuffer.Length);
- readOnlyBuffer.CopyTo(readBackBuffer, destinationOffset, bufferOffset, count);
+ readOnlyBuffer.CopyTo(readBackBuffer, bufferOffset, destinationOffset, count);
Assert.AreEqual(source.Length, readBackBuffer.Length);
Assert.IsTrue(source.AsSpan(bufferOffset, count).SequenceEqual(readBackBuffer.Span.Slice(destinationOffset, count)));