diff --git a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
index 41a706ae..019811a5 100644
--- a/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
+++ b/samples/ComputeSharp.Benchmark/ComputeSharp.Benchmark.csproj
@@ -11,6 +11,11 @@
+
diff --git a/samples/ComputeSharp.Benchmark/Dnn.cs b/samples/ComputeSharp.Benchmark/Dnn.cs
index 904ddd78..422c4c5b 100644
--- a/samples/ComputeSharp.Benchmark/Dnn.cs
+++ b/samples/ComputeSharp.Benchmark/Dnn.cs
@@ -6,7 +6,7 @@ namespace ComputeSharp.Benchmark
///
/// A that contains primitives to run certain operations of a neural network
///
- internal static class Dnn
+ internal static partial class Dnn
{
///
/// Executes the forward pass on a fully connected layer on the CPU
@@ -72,36 +72,17 @@ namespace ComputeSharp.Benchmark
///
/// Kernel for
///
- private readonly struct FullyConnectedForwardKernel : IComputeShader
+ [AutoConstructor]
+ private readonly partial struct FullyConnectedForwardKernel : IComputeShader
{
private readonly int n;
private readonly int m;
private readonly int p;
-
private readonly ReadOnlyBuffer x;
private readonly ReadOnlyBuffer w;
private readonly ReadOnlyBuffer b;
private readonly ReadWriteBuffer y;
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public FullyConnectedForwardKernel(
- int n,
- int m,
- int p,
- ReadOnlyBuffer x,
- ReadOnlyBuffer w,
- ReadOnlyBuffer b,
- ReadWriteBuffer y)
- {
- this.n = n;
- this.m = m;
- this.p = p;
- this.x = x;
- this.w = w;
- this.b = b;
- this.y = y;
- }
-
///
public void Execute(ThreadIds ids)
{
diff --git a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
index e2d3d73c..b7d2e6a1 100644
--- a/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
+++ b/samples/ComputeSharp.ImageProcessing/ComputeSharp.ImageProcessing.csproj
@@ -21,6 +21,11 @@
+
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
index 7e46ecb5..f03884dc 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
@@ -18,7 +18,7 @@ namespace ComputeSharp.BokehBlur.Processors
///
/// The pixel format
/// This processor is based on the code from Mike Pound, see github.com/mikepound/convolve
- public sealed class HlslBokehBlurProcessor : ImageProcessor
+ public sealed partial class HlslBokehBlurProcessor : ImageProcessor
where TPixel : unmanaged, IPixel
{
///
@@ -301,22 +301,23 @@ namespace ComputeSharp.BokehBlur.Processors
int height = Source.Height;
int width = Source.Width;
- Gpu.Default.For(width, height, new VerticalConvolutionProcessor
- {
- width = width,
- maxY = height - 1,
- maxX = width - 1,
- kernelLength = kernel.Length,
- source = source,
- target = target,
- kernel = kernel
- });
+ VerticalConvolutionProcessor shader = new(
+ width,
+ maxY: height - 1,
+ maxX: width - 1,
+ kernelLength: kernel.Size,
+ source,
+ target,
+ kernel);
+
+ Gpu.Default.For(width, height, in shader);
}
///
/// Kernel for
///
- private struct VerticalConvolutionProcessor : IComputeShader
+ [AutoConstructor]
+ private partial struct VerticalConvolutionProcessor : IComputeShader
{
public int width;
public int maxY;
@@ -371,24 +372,25 @@ namespace ComputeSharp.BokehBlur.Processors
int height = Source.Height;
int width = Source.Width;
- Gpu.Default.For(width, height, new HorizontalConvolutionAndAccumulatePartialsProcessor
- {
- width = width,
- maxY = height - 1,
- maxX = width - 1,
- kernelLength = kernel.Length,
- z = z,
- w = w,
- source = source,
- target = target,
- kernel = kernel
- });
+ HorizontalConvolutionAndAccumulatePartialsProcessor shader = new(
+ width,
+ maxY: height - 1,
+ maxX: width - 1,
+ kernelLength: kernel.Size,
+ z,
+ w,
+ source,
+ target,
+ kernel);
+
+ Gpu.Default.For(width, height, in shader);
}
///
/// Kernel for
///
- private struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
+ [AutoConstructor]
+ private partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
{
public int width;
public int maxY;
@@ -450,7 +452,8 @@ namespace ComputeSharp.BokehBlur.Processors
///
/// The processor for
///
- private readonly struct GetExposedVector4BufferProcessor : IRowOperation
+ [AutoConstructor]
+ private readonly partial struct GetExposedVector4BufferProcessor : IRowOperation
{
private readonly int width;
private readonly float exp;
@@ -459,21 +462,6 @@ namespace ComputeSharp.BokehBlur.Processors
private readonly Memory target;
private readonly Configuration configuration;
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public GetExposedVector4BufferProcessor(
- int width,
- float exp,
- Memory source,
- Memory target,
- Configuration configuration)
- {
- this.width = width;
- this.exp = exp;
- this.source = source;
- this.target = target;
- this.configuration = configuration;
- }
-
///
public void Invoke(int y)
{
@@ -514,7 +502,8 @@ namespace ComputeSharp.BokehBlur.Processors
///
/// The processor for
///
- private readonly struct ApplyInverseGammaExposureProcessor : IRowOperation
+ [AutoConstructor]
+ private readonly partial struct ApplyInverseGammaExposureProcessor : IRowOperation
{
private readonly int width;
private readonly float exp;
@@ -523,21 +512,6 @@ namespace ComputeSharp.BokehBlur.Processors
private readonly Memory target;
private readonly Configuration configuration;
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- public ApplyInverseGammaExposureProcessor(
- int width,
- float exp,
- Memory source,
- Memory target,
- Configuration configuration)
- {
- this.width = width;
- this.exp = exp;
- this.source = source;
- this.target = target;
- this.configuration = configuration;
- }
-
///
public void Invoke(int y)
{
diff --git a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
index eadcd9c9..ff930af1 100644
--- a/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
+++ b/samples/ComputeSharp.Sample/ComputeSharp.Sample.csproj
@@ -3,11 +3,15 @@
Exe
net5.0-windows10.0.19041.0
- preview
+
diff --git a/samples/ComputeSharp.Sample/Program.cs b/samples/ComputeSharp.Sample/Program.cs
index 752f58e5..6af1c266 100644
--- a/samples/ComputeSharp.Sample/Program.cs
+++ b/samples/ComputeSharp.Sample/Program.cs
@@ -5,7 +5,7 @@ using System.Runtime.CompilerServices;
namespace ComputeSharp.Sample
{
- class Program
+ partial class Program
{
static void Main()
{
diff --git a/src/ComputeSharp/ComputeSharp.csproj b/src/ComputeSharp/ComputeSharp.csproj
index 7665f77c..e2f82a06 100644
--- a/src/ComputeSharp/ComputeSharp.csproj
+++ b/src/ComputeSharp/ComputeSharp.csproj
@@ -8,11 +8,6 @@
-