diff --git a/src/ComputeSharp.Core/Extensions/SpanExtensions.cs b/src/ComputeSharp.Core/Extensions/SpanExtensions.cs deleted file mode 100644 index 47bedcf8d..000000000 --- a/src/ComputeSharp.Core/Extensions/SpanExtensions.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System.Diagnostics.Contracts; -using System.Runtime.InteropServices; - -namespace System -{ - /// - /// A that contains extension methods for the - /// - public static class SpanExtensions - { - /// - /// Creates a from a given 2D array - /// - /// The type of items in the input array - /// The input 2D array - /// A that maps all the items of the input array - [Pure] - public static Span AsSpan(this T[,] array) - { - ref T r0 = ref array[0, 0]; - - return MemoryMarshal.CreateSpan(ref r0, array.Length); - } - - /// - /// Creates a from a given 2D array - /// - /// The type of items in the input array - /// The input 2D array - /// The index of the initial row to map from the input array - /// A that maps the desired items of the input array - [Pure] - public static Span AsSpan(this T[,] array, Index startIndex) - { - int - rows = array.GetLength(0), - offset = startIndex.GetOffset(rows), - interval = rows - offset; - ref T r0 = ref array[offset, 0]; - - return MemoryMarshal.CreateSpan(ref r0, interval * array.GetLength(1)); - } - - /// - /// Creates a from a given 2D array - /// - /// The type of items in the input array - /// The input 2D array - /// The index of the initial row to map from the input array - /// A that maps the desired items of the input array - [Pure] - public static Span AsSpan(this T[,] array, int start) - { - int interval = array.GetLength(0) - start; - ref T r0 = ref array[start, 0]; - - return MemoryMarshal.CreateSpan(ref r0, interval * array.GetLength(1)); - } - - /// - /// Creates a from a given 2D array - /// - /// The type of items in the input array - /// The input 2D array - /// The index of the initial row to map from the input array - /// The number of rows to map from the input array - /// A that maps the desired items of the input array - [Pure] - public static Span AsSpan(this T[,] array, int start, int length) - { - ref T r0 = ref array[start, 0]; - - return MemoryMarshal.CreateSpan(ref r0, length * array.GetLength(1)); - } - - /// - /// Creates a from a given 2D array - /// - /// The type of items in the input array - /// The input 2D array - /// The range of rows to map from the input array - /// A that maps the desired items of the input array - [Pure] - public static Span AsSpan(this T[,] array, Range range) - { - var indices = range.GetOffsetAndLength(array.GetLength(0)); - ref T r0 = ref array[indices.Offset, 0]; - - return MemoryMarshal.CreateSpan(ref r0, indices.Length * array.GetLength(1)); - } - } -} diff --git a/src/ComputeSharp.Core/Extensions/Primitives/VectorExtensions.cs b/src/ComputeSharp.Core/Extensions/VectorExtensions.cs similarity index 100% rename from src/ComputeSharp.Core/Extensions/Primitives/VectorExtensions.cs rename to src/ComputeSharp.Core/Extensions/VectorExtensions.cs diff --git a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs index 2c805394a..e2ab354bd 100644 --- a/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs @@ -3,6 +3,7 @@ using System.Runtime.CompilerServices; using ComputeSharp.Graphics; using ComputeSharp.Graphics.Buffers.Abstract; +using Microsoft.Toolkit.HighPerformance.Extensions; namespace ComputeSharp { diff --git a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj index 57c67582a..a80c8d676 100644 --- a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj +++ b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj @@ -8,7 +8,7 @@ - + diff --git a/src/ComputeSharp/ComputeSharp.nuspec b/src/ComputeSharp/ComputeSharp.nuspec index d2c4be2cf..3e632143e 100644 --- a/src/ComputeSharp/ComputeSharp.nuspec +++ b/src/ComputeSharp/ComputeSharp.nuspec @@ -17,7 +17,7 @@ - +