diff --git a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
index 002e1078..678e0982 100644
--- a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
+++ b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
index 72f57439..12ecc013 100644
--- a/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Imaging/ImagingBenchmark.cs
@@ -31,6 +31,8 @@ public class ImagingBenchmark : IDisposable
[GlobalSetup]
public void Setup()
{
+ Configuration.Default.PreferContiguousImageBuffers = true;
+
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
this.image = Image.Load(path);
diff --git a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
index 59564f49..76b697a3 100644
--- a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
+++ b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
index 4d3e7888..b9187cf0 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
@@ -263,12 +263,12 @@ public sealed partial class HlslBokehBlurProcessor
///
protected override void OnFrameApply(ImageFrame source)
{
- if (!source.TryGetSinglePixelSpan(out Span pixelSpan))
+ if (!source.DangerousTryGetSinglePixelMemory(out Memory pixelMemory))
{
ThrowHelper.ThrowInvalidOperationException("Cannot process image frames wrapping discontiguous memory.");
}
- Span span = MemoryMarshal.Cast(pixelSpan);
+ Span span = MemoryMarshal.Cast(pixelMemory.Span);
using ReadWriteTexture2D texture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
using ReadWriteTexture2D temporary = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear);
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
index 33aa5541..d6edd6e6 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
@@ -93,12 +93,12 @@ public sealed partial class HlslGaussianBlurProcessor
///
protected override void OnFrameApply(ImageFrame source)
{
- if (!source.TryGetSinglePixelSpan(out Span pixelSpan))
+ if (!source.DangerousTryGetSinglePixelMemory(out Memory pixelMemory))
{
ThrowHelper.ThrowInvalidOperationException("Cannot process image frames wrapping discontiguous memory.");
}
- Span span = MemoryMarshal.Cast(pixelSpan);
+ Span span = MemoryMarshal.Cast(pixelMemory.Span);
using ReadWriteTexture2D sourceTexture = GraphicsDevice.AllocateReadWriteTexture2D(span, source.Width, source.Height);
using ReadWriteTexture2D firstPassTexture = GraphicsDevice.AllocateReadWriteTexture2D(source.Width, source.Height);
diff --git a/samples/ComputeSharp.ImageProcessing/Program.cs b/samples/ComputeSharp.ImageProcessing/Program.cs
index 0318a63e..9d862a93 100644
--- a/samples/ComputeSharp.ImageProcessing/Program.cs
+++ b/samples/ComputeSharp.ImageProcessing/Program.cs
@@ -7,38 +7,34 @@ using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
-namespace ComputeSharp.ImageProcessing;
+Configuration.Default.PreferContiguousImageBuffers = true;
-class Program
+Console.WriteLine(">> Loading image");
+
+string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg");
+using Image image = Image.Load(path);
+
+// Apply a series of processors and save the results
+foreach (var effect in new (string Name, IImageProcessor Processor)[]
{
- static void Main()
+ ("bokeh", new HlslBokehBlurProcessor(80, 2)),
+ ("gaussian", new HlslGaussianBlurProcessor(80))
+})
+{
+ Console.WriteLine($">> Applying {effect.Name}");
+
+ using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor));
+
+ Console.WriteLine($">> Saving {effect.Name} to disk");
+
+ string targetPath = Path.GetDirectoryName(path)!;
+
+ while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing")
{
- Console.WriteLine(">> Loading image");
- string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg");
- using Image image = Image.Load(path);
-
- // Apply a series of processors and save the results
- foreach (var effect in new (string Name, IImageProcessor Processor)[]
- {
- ("bokeh", new HlslBokehBlurProcessor(80, 2)),
- ("gaussian", new HlslGaussianBlurProcessor(80))
- })
- {
- Console.WriteLine($">> Applying {effect.Name}");
- using Image copy = image.Clone(c => c.ApplyProcessor(effect.Processor));
-
- Console.WriteLine($">> Saving {effect.Name} to disk");
-
- string targetPath = Path.GetDirectoryName(path)!;
-
- while (Path.GetFileName(targetPath) != "ComputeSharp.ImageProcessing")
- {
- targetPath = Path.GetDirectoryName(targetPath)!;
- }
-
- targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
-
- copy.Save(targetPath);
- }
+ targetPath = Path.GetDirectoryName(targetPath)!;
}
+
+ targetPath = Path.Combine(targetPath, $"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
+
+ copy.Save(targetPath);
}
diff --git a/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj b/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj
index f559a565..ae682324 100644
--- a/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj
+++ b/samples/ComputeSharp.Sample.FSharp/ComputeSharp.Sample.FSharp.fsproj
@@ -7,7 +7,7 @@
-
+
diff --git a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
index a5be5595..a4c2592c 100644
--- a/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
+++ b/samples/ComputeSharp.SwapChain.Uwp/ComputeSharp.SwapChain.Uwp.csproj
@@ -208,10 +208,10 @@
8.0.0-preview1
- 4.5.0
+ 4.5.1
- 4.5.0
+ 4.5.1
6.0.0
@@ -226,7 +226,7 @@
7.1.2
- 2.7.0
+ 2.7.1
diff --git a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
index 454356e5..ff2c1bff 100644
--- a/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
+++ b/samples/ComputeSharp.SwapChain.WinUI/ComputeSharp.SwapChain.WinUI.csproj
@@ -27,7 +27,7 @@
-
+
@@ -36,7 +36,7 @@
-
+
diff --git a/src/ComputeSharp.Core/ComputeSharp.Core.csproj b/src/ComputeSharp.Core/ComputeSharp.Core.csproj
index 8aa6a689..1c1f7a70 100644
--- a/src/ComputeSharp.Core/ComputeSharp.Core.csproj
+++ b/src/ComputeSharp.Core/ComputeSharp.Core.csproj
@@ -14,7 +14,7 @@
-
+
diff --git a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj
index 653a3a30..76c8e66e 100644
--- a/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj
+++ b/src/ComputeSharp.D2D1/ComputeSharp.D2D1.csproj
@@ -17,7 +17,7 @@
-
+
diff --git a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj
index 6062ddd5..5b141cc4 100644
--- a/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj
+++ b/src/ComputeSharp.WinUI/ComputeSharp.WinUI.csproj
@@ -23,7 +23,7 @@
-
+
diff --git a/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj b/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj
index 16fd9b98..d5bc6487 100644
--- a/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj
+++ b/tests/ComputeSharp.D2D1.Tests/ComputeSharp.D2D1.Tests.csproj
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/tests/ComputeSharp.D2D1.Tests/EndToEndTests.cs b/tests/ComputeSharp.D2D1.Tests/EndToEndTests.cs
index a8e2fc4d..c44fb1c0 100644
--- a/tests/ComputeSharp.D2D1.Tests/EndToEndTests.cs
+++ b/tests/ComputeSharp.D2D1.Tests/EndToEndTests.cs
@@ -6,6 +6,7 @@ using ComputeSharp.D2D1.Tests.Effects;
using ComputeSharp.D2D1.Tests.Helpers;
using ComputeSharp.Tests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SixLabors.ImageSharp;
namespace ComputeSharp.D2D1.Tests;
@@ -13,6 +14,12 @@ namespace ComputeSharp.D2D1.Tests;
[TestCategory("EndToEnd")]
public class EndToEndTests
{
+ [AssemblyInitialize]
+ public static void ConfigureImageSharp()
+ {
+ Configuration.Default.PreferContiguousImageBuffers = true;
+ }
+
[TestMethod]
public unsafe void Invert()
{
diff --git a/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj b/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj
index ea6ed60b..7f7bae0f 100644
--- a/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj
+++ b/tests/ComputeSharp.Tests.DisableDynamicCompilation/ComputeSharp.Tests.DisableDynamicCompilation.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
index fb26bd84..1365ca64 100644
--- a/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
+++ b/tests/ComputeSharp.Tests/ComputeSharp.Tests.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/tests/ComputeSharp.Tests/Extensions/ImagingExtensions.cs b/tests/ComputeSharp.Tests/Extensions/ImagingExtensions.cs
index bf4a3ddc..8470ebb3 100644
--- a/tests/ComputeSharp.Tests/Extensions/ImagingExtensions.cs
+++ b/tests/ComputeSharp.Tests/Extensions/ImagingExtensions.cs
@@ -28,9 +28,9 @@ public static class ImagingExtensions
Image image = new(texture.Width, texture.Height);
- Assert.IsTrue(image.TryGetSinglePixelSpan(out Span span));
+ Assert.IsTrue(image.DangerousTryGetSinglePixelMemory(out Memory memory));
- Span pixels = MemoryMarshal.Cast(span);
+ Span pixels = MemoryMarshal.Cast(memory.Span);
texture.CopyTo(pixels);
@@ -53,9 +53,9 @@ public static class ImagingExtensions
Image image = new(texture.Width, texture.Height);
- Assert.IsTrue(image.TryGetSinglePixelSpan(out Span span));
+ Assert.IsTrue(image.DangerousTryGetSinglePixelMemory(out Memory memory));
- Span pixels = MemoryMarshal.Cast(span);
+ Span pixels = MemoryMarshal.Cast(memory.Span);
texture.CopyTo(pixels, 0, 0, depth, texture.Width, texture.Height, 1);
diff --git a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs
index 1c7c16ef..4f3594c3 100644
--- a/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs
+++ b/tests/ComputeSharp.Tests/Helpers/TolerantImageComparer.cs
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;
-using SixLabors.ImageSharp;
-using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
+using System.Runtime.CompilerServices;
using Microsoft.VisualStudio.TestTools.UnitTesting;
+using SixLabors.ImageSharp;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Advanced;
-using System.Runtime.CompilerServices;
+using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
namespace ComputeSharp.Tests.Helpers;
@@ -61,11 +61,11 @@ internal static class TolerantImageComparer
for (int y = 0; y < actual.Height; y++)
{
- Span aSpan = expected.GetPixelRowSpan(y);
- Span bSpan = actual.GetPixelRowSpan(y);
+ Memory aMemory = expected.DangerousGetPixelRowMemory(y);
+ Memory bMemory = actual.DangerousGetPixelRowMemory(y);
- PixelOperations.Instance.ToRgba32(actual.GetConfiguration(), aSpan, aBuffer);
- PixelOperations.Instance.ToRgba32(actual.GetConfiguration(), bSpan, bBuffer);
+ PixelOperations.Instance.ToRgba32(actual.GetConfiguration(), aMemory.Span, aBuffer);
+ PixelOperations.Instance.ToRgba32(actual.GetConfiguration(), bMemory.Span, bBuffer);
for (int x = 0; x < width; x++)
{
diff --git a/tests/ComputeSharp.Tests/ImagingTests.cs b/tests/ComputeSharp.Tests/ImagingTests.cs
index 75849c9a..2ef5ba13 100644
--- a/tests/ComputeSharp.Tests/ImagingTests.cs
+++ b/tests/ComputeSharp.Tests/ImagingTests.cs
@@ -6,12 +6,12 @@ using CommunityToolkit.HighPerformance.Buffers;
using ComputeSharp.Resources;
using ComputeSharp.Tests.Attributes;
using ComputeSharp.Tests.Extensions;
+using ComputeSharp.Tests.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using SixLabors.ImageSharp;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
using ImageSharpBgra32 = SixLabors.ImageSharp.PixelFormats.Bgra32;
using ImageSharpL8 = SixLabors.ImageSharp.PixelFormats.L8;
-using ComputeSharp.Tests.Helpers;
namespace ComputeSharp.Tests;
@@ -19,6 +19,12 @@ namespace ComputeSharp.Tests;
[TestCategory("Imaging")]
public class ImagingTests
{
+ [AssemblyInitialize]
+ public static void ConfigureImageSharp()
+ {
+ Configuration.Default.PreferContiguousImageBuffers = true;
+ }
+
[CombinatorialTestMethod]
[AllDevices]
[Resource(typeof(ReadOnlyTexture2D<,>))]
diff --git a/tests/ComputeSharp.Tests/ShadersTests.cs b/tests/ComputeSharp.Tests/ShadersTests.cs
index bc04c844..515a829d 100644
--- a/tests/ComputeSharp.Tests/ShadersTests.cs
+++ b/tests/ComputeSharp.Tests/ShadersTests.cs
@@ -186,9 +186,9 @@ public class ShadersTests
action.Method.GetGenericMethodDefinition().MakeGenericMethod(shaderType).Invoke(null, new[] { texture });
}
- _ = image.TryGetSinglePixelSpan(out Span span);
+ _ = image.DangerousTryGetSinglePixelMemory(out Memory memory);
- texture.CopyTo(MemoryMarshal.Cast(span));
+ texture.CopyTo(MemoryMarshal.Cast(memory.Span));
}
string actualPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Shaders", $"{shaderType.Name}.png");
@@ -246,9 +246,9 @@ public class ShadersTests
texture.GraphicsDevice.ForEach(texture, pixelFactory(texture));
}
- _ = image.TryGetSinglePixelSpan(out Span span);
+ _ = image.DangerousTryGetSinglePixelMemory(out Memory memory);
- texture.CopyTo(MemoryMarshal.Cast(span));
+ texture.CopyTo(MemoryMarshal.Cast(memory.Span));
}
string actualPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Shaders", $"{shaderType.Name}.png");