diff --git a/.gitignore b/.gitignore
index fd8f3e38..b266c367 100644
--- a/.gitignore
+++ b/.gitignore
@@ -330,4 +330,7 @@ ASALocalRun/
.mfractor/
# Sample images
-**/city_*.jpg
+samples/**/city_*.jpg
+
+# XML docs files
+src/**/ComputeSharp*.xml
\ No newline at end of file
diff --git a/nuget.config b/nuget.config
index e71007c9..4f62278c 100644
--- a/nuget.config
+++ b/nuget.config
@@ -5,5 +5,6 @@
+
diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
index 870b1966..a27608c6 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasBenchmark.cs
@@ -153,7 +153,7 @@ namespace ComputeSharp.Benchmark.Blas
using ReadOnlyBuffer x = Gpu.Default.AllocateReadOnlyBuffer(X);
using ReadOnlyBuffer w = Gpu.Default.AllocateReadOnlyBuffer(W);
using ReadOnlyBuffer b = Gpu.Default.AllocateReadOnlyBuffer(B);
- using ReadWriteBuffer y = Gpu.Default.AllocateReadWriteBuffer(Y);
+ using ReadWriteBuffer y = Gpu.Default.AllocateReadWriteBuffer(Y.Length);
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, x, w, b, y);
diff --git a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
index 6634e708..d1e3df0a 100644
--- a/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
+++ b/samples/ComputeSharp.Benchmark/Blas/BlasHelpers.cs
@@ -1,6 +1,5 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
-using ComputeSharp.Graphics;
namespace ComputeSharp.Benchmark.Blas
{
@@ -93,17 +92,17 @@ namespace ComputeSharp.Benchmark.Blas
public readonly ReadWriteBuffer y;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
- int x_offset = ids.X * n * p + ids.Y * m;
+ int x_offset = ThreadIds.X * n * p + ThreadIds.Y * m;
float result = 0f;
for (int k = 0; k < m; k++)
{
- result += x[x_offset + k] * w[k * p + ids.Z];
+ result += x[x_offset + k] * w[k * p + ThreadIds.Z];
}
- y[ids.X * n * p + ids.Y * p + ids.Z] = result + b[ids.Z];
+ y[ThreadIds.X * n * p + ThreadIds.Y * p + ThreadIds.Z] = result + b[ThreadIds.Z];
}
}
}
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
index 25d0d23b..864389ed 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslBokehBlurProcessor{TPixel}.cs
@@ -1,7 +1,6 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
-using System.Diagnostics.Contracts;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
@@ -257,61 +256,38 @@ namespace ComputeSharp.BokehBlur.Processors
Span span = MemoryMarshal.Cast(pixelSpan);
- using ReadWriteTexture2D sourceTexture = Gpu.Default.AllocateReadWriteTexture2D(span, source.Width, source.Height);
- using ReadWriteTexture2D processingTexture = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadWriteTexture2D realTexture = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadWriteTexture2D imaginaryTexture = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
- using ReadOnlyBuffer kernelBuffer = Gpu.Default.AllocateReadOnlyBuffer(KernelSize);
+ using ReadWriteTexture2D texture = Gpu.Default.AllocateReadWriteTexture2D(span, source.Width, source.Height);
+ using ReadWriteTexture2D temporary = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height, AllocationMode.Clear);
+ using ReadWriteTexture2D reals = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadWriteTexture2D imaginaries = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadOnlyBuffer kernel = Gpu.Default.AllocateReadOnlyBuffer(KernelSize);
// Preliminary gamma highlight pass
- ApplyGammaHighlight(sourceTexture);
-
- ref Vector4 param0 = ref MemoryMarshal.GetArrayDataReference(KernelParameters);
+ Gpu.Default.For(source.Height, new(texture));
// Perform two 1D convolutions for each component in the current instance
for (int j = 0; j < Kernels.Length; j++)
{
- kernelBuffer.SetData(Kernels[j]);
- Vector4 parameters = Unsafe.Add(ref param0, j);
+ Vector4 parameters = KernelParameters[j];
- ApplyVerticalConvolution(sourceTexture, realTexture, imaginaryTexture, kernelBuffer);
- ApplyHorizontalConvolutionAndAccumulatePartials(realTexture, imaginaryTexture, processingTexture, kernelBuffer, parameters.Z, parameters.W);
+ kernel.SetData(Kernels[j]);
+
+ Gpu.Default.For(
+ source.Width,
+ source.Height,
+ new(texture, reals, imaginaries, kernel));
+
+ Gpu.Default.For(
+ source.Width,
+ source.Height,
+ new(parameters.Z, parameters.W, reals, imaginaries, temporary, kernel));
}
// Apply the inverse gamma exposure pass
- ApplyInverseGammaExposure(processingTexture, sourceTexture);
+ Gpu.Default.For(source.Height, new(temporary, texture));
// Write the final pixel data
- sourceTexture.GetData(span);
- }
-
- ///
- /// Performs a vertical 1D complex convolution with the specified parameters.
- ///
- /// The source to read data from.
- /// The target to write the real results to.
- /// The target to write the imaginary results to.
- /// The with the values for the current complex kernel.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ApplyVerticalConvolution(
- ReadWriteTexture2D source,
- ReadWriteTexture2D reals,
- ReadWriteTexture2D imaginaries,
- ReadOnlyBuffer kernel)
- {
- int height = Source.Height;
- int width = Source.Width;
-
- VerticalConvolutionProcessor shader = new(
- maxY: height - 1,
- maxX: width - 1,
- kernelLength: kernel.Length,
- source,
- reals,
- imaginaries,
- kernel);
-
- Gpu.Default.For(width, height, in shader);
+ texture.GetData(span);
}
///
@@ -320,27 +296,25 @@ namespace ComputeSharp.BokehBlur.Processors
[AutoConstructor]
internal partial struct VerticalConvolutionProcessor : IComputeShader
{
- public int maxY;
- public int maxX;
- public int kernelLength;
-
- public ReadWriteTexture2D source;
+ public IReadWriteTexture2D source;
public ReadWriteTexture2D reals;
public ReadWriteTexture2D imaginaries;
public ReadOnlyBuffer kernel;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
Vector4 real = Vector4.Zero;
Vector4 imaginary = Vector4.Zero;
+ int maxY = source.Height;
+ int maxX = source.Width;
+ int kernelLength = kernel.Length;
int radiusY = kernelLength >> 1;
- int sourceOffsetColumnBase = ids.X;
for (int i = 0; i < kernelLength; i++)
{
- int offsetY = Hlsl.Clamp(ids.Y + i - radiusY, 0, maxY);
- int offsetX = Hlsl.Clamp(sourceOffsetColumnBase, 0, maxX);
+ int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
+ int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
Vector4 color = source[offsetX, offsetY];
Complex64 factors = kernel[i];
@@ -348,54 +322,17 @@ namespace ComputeSharp.BokehBlur.Processors
imaginary += factors.Imaginary * color;
}
- reals[ids.XY] = real;
- imaginaries[ids.XY] = imaginary;
+ reals[ThreadIds.XY] = real;
+ imaginaries[ThreadIds.XY] = imaginary;
}
}
- ///
- /// Performs an horizontal 1D complex convolution with the specified parameters.
- ///
- /// The source to read the real results from.
- /// The source to read the imaginary results from.
- /// The with the values for the current complex kernel.
- /// The weight factor for the real component of the complex pixel values.
- /// The weight factor for the imaginary component of the complex pixel values.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ApplyHorizontalConvolutionAndAccumulatePartials(
- ReadWriteTexture2D reals,
- ReadWriteTexture2D imaginaries,
- ReadWriteTexture2D target,
- ReadOnlyBuffer kernel,
- float z,
- float w)
- {
- int height = Source.Height;
- int width = Source.Width;
-
- HorizontalConvolutionAndAccumulatePartialsProcessor shader = new(
- maxY: height - 1,
- maxX: width - 1,
- kernelLength: kernel.Length,
- z,
- w,
- reals,
- imaginaries,
- target,
- kernel);
-
- Gpu.Default.For(width, height, in shader);
- }
-
///
/// Kernel for the horizontal convolution pass.
///
[AutoConstructor]
internal partial struct HorizontalConvolutionAndAccumulatePartialsProcessor : IComputeShader
{
- public int maxY;
- public int maxX;
- public int kernelLength;
public float z;
public float w;
@@ -405,17 +342,19 @@ namespace ComputeSharp.BokehBlur.Processors
public ReadOnlyBuffer kernel;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
Vector4 real = Vector4.Zero;
Vector4 imaginary = Vector4.Zero;
+ int maxY = target.Height;
+ int maxX = target.Width;
+ int kernelLength = kernel.Length;
int radiusX = kernelLength >> 1;
- int sourceOffsetColumnBase = ids.X;
- int offsetY = Hlsl.Clamp(ids.Y, 0, maxY);
+ int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
for (int i = 0; i < kernelLength; i++)
{
- int offsetX = Hlsl.Clamp(sourceOffsetColumnBase + i - radiusX, 0, maxX);
+ int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
Vector4 sourceReal = reals[offsetX, offsetY];
Vector4 sourceImaginary = imaginaries[offsetX, offsetY];
Complex64 factors = kernel[i];
@@ -424,79 +363,56 @@ namespace ComputeSharp.BokehBlur.Processors
imaginary += factors.Real * sourceImaginary + factors.Imaginary * sourceReal;
}
- target[ids.XY] += real * z + imaginary * w;
+ target[ThreadIds.XY] += real * z + imaginary * w;
}
}
- ///
- /// Applies the gamma highlight pass to compute the final pixel values for a target image.
- ///
- /// The source instance to modify.
- [Pure]
- private void ApplyGammaHighlight(ReadWriteTexture2D source)
- {
- Gpu.Default.For(source.Height, new GammaHighlightProcessor(source.Width, source));
- }
-
///
/// Kernel for the gamma highlight pass.
///
[AutoConstructor]
internal readonly partial struct GammaHighlightProcessor : IComputeShader
{
- public readonly int width;
-
- public readonly ReadWriteTexture2D source;
+ public readonly IReadWriteTexture2D source;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
+ int width = source.Width;
+
for (int i = 0; i < width; i++)
{
- Float4 v = source[i, ids.X];
+ Float4 v = source[i, ThreadIds.X];
v.XYZ = v.XYZ * v.XYZ * v.XYZ;
- source[i, ids.X] = v;
+ source[i, ThreadIds.X] = v;
}
}
}
- ///
- /// Applies the inverse gamma highlight pass to compute the final pixel values for a target image.
- ///
- /// The source instance to read from.
- /// The target instance to write to.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ApplyInverseGammaExposure(
- ReadWriteTexture2D source,
- ReadWriteTexture2D target)
- {
- Gpu.Default.For(source.Height, new InverseGammaHighlightProcessor(source.Width, source, target));
- }
-
///
/// Kernel for the inverse gamma highlight pass.
///
[AutoConstructor]
internal readonly partial struct InverseGammaHighlightProcessor : IComputeShader
{
- public readonly int width;
-
public readonly ReadWriteTexture2D source;
- public readonly ReadWriteTexture2D target;
+ public readonly IReadWriteTexture2D target;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
+ int width = source.Width;
+
for (int i = 0; i < width; i++)
{
- Float4 v = source[i, ids.X];
+ Float4 v = source[i, ThreadIds.X];
v.XYZ = Hlsl.Clamp(v.XYZ, 0, float.MaxValue);
v.XYZ = Hlsl.Pow(v.XYZ, 1 / 3f);
- target[i, ids.X] = v;
+ target[i, ThreadIds.X] = v;
}
}
}
diff --git a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
index 5f1fa2f5..9a8721a6 100644
--- a/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
+++ b/samples/ComputeSharp.ImageProcessing/Processors/HlslGaussianBlurProcessor{TPixel}.cs
@@ -95,132 +95,76 @@ namespace ComputeSharp.BokehBlur.Processors
Span span = MemoryMarshal.Cast(pixelSpan);
using ReadWriteTexture2D sourceTexture = Gpu.Default.AllocateReadWriteTexture2D(span, source.Width, source.Height);
- using ReadWriteTexture2D firstPassTexture = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
+ using ReadWriteTexture2D firstPassTexture = Gpu.Default.AllocateReadWriteTexture2D(source.Width, source.Height);
using ReadOnlyBuffer kernelBuffer = Gpu.Default.AllocateReadOnlyBuffer(Kernel);
- ApplyVerticalConvolution(sourceTexture, firstPassTexture, kernelBuffer);
- ApplyHorizontalConvolution(firstPassTexture, sourceTexture, kernelBuffer);
+ Gpu.Default.For(source.Width, source.Height, new(sourceTexture, firstPassTexture, kernelBuffer));
+ Gpu.Default.For(source.Width, source.Height, new(firstPassTexture, sourceTexture, kernelBuffer));
sourceTexture.GetData(span);
}
- ///
- /// Performs a vertical 1D complex convolution with the specified parameters.
- ///
- /// The source to read data from.
- /// The target to write the results to.
- /// The with the values for the current complex kernel.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ApplyVerticalConvolution(
- ReadWriteTexture2D source,
- ReadWriteTexture2D target,
- ReadOnlyBuffer kernel)
- {
- int height = Source.Height;
- int width = Source.Width;
-
- VerticalConvolutionProcessor shader = new(
- maxY: height - 1,
- maxX: width - 1,
- kernel.Length,
- source,
- target,
- kernel);
-
- Gpu.Default.For(width, height, in shader);
- }
-
///
/// Kernel for the vertical convolution pass.
///
[AutoConstructor]
internal readonly partial struct VerticalConvolutionProcessor : IComputeShader
{
- public readonly int maxY;
- public readonly int maxX;
- public readonly int kernelLength;
-
- public readonly ReadWriteTexture2D source;
- public readonly ReadWriteTexture2D target;
+ public readonly IReadWriteTexture2D source;
+ public readonly IReadWriteTexture2D target;
public readonly ReadOnlyBuffer kernel;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
Vector4 result = Vector4.Zero;
+ int maxY = source.Height - 1;
+ int maxX = source.Width - 1;
+ int kernelLength = kernel.Length;
int radiusY = kernelLength >> 1;
- int sourceOffsetColumnBase = ids.X;
for (int i = 0; i < kernelLength; i++)
{
- int offsetY = Hlsl.Clamp(ids.Y + i - radiusY, 0, maxY);
- int offsetX = Hlsl.Clamp(sourceOffsetColumnBase, 0, maxX);
+ int offsetY = Hlsl.Clamp(ThreadIds.Y + i - radiusY, 0, maxY);
+ int offsetX = Hlsl.Clamp(ThreadIds.X, 0, maxX);
Vector4 color = source[offsetX, offsetY];
result += kernel[i] * color;
}
- target[ids.XY] = result;
+ target[ThreadIds.XY] = result;
}
}
- ///
- /// Performs an horizontal 1D complex convolution with the specified parameters.
- ///
- /// The source to read data from.
- /// The target to write the results to.
- /// The with the values for the current complex kernel.
- [MethodImpl(MethodImplOptions.AggressiveInlining)]
- private void ApplyHorizontalConvolution(
- ReadWriteTexture2D source,
- ReadWriteTexture2D target,
- ReadOnlyBuffer kernel)
- {
- int height = Source.Height;
- int width = Source.Width;
-
- HorizontalConvolutionProcessor shader = new(
- maxY: height - 1,
- maxX: width - 1,
- kernel.Length,
- source,
- target,
- kernel);
-
- Gpu.Default.For(width, height, in shader);
- }
-
///
/// Kernel for the horizontal convolution pass.
///
[AutoConstructor]
internal readonly partial struct HorizontalConvolutionProcessor : IComputeShader
{
- public readonly int maxY;
- public readonly int maxX;
- public readonly int kernelLength;
-
- public readonly ReadWriteTexture2D source;
- public readonly ReadWriteTexture2D target;
+ public readonly IReadWriteTexture2D source;
+ public readonly IReadWriteTexture2D target;
public readonly ReadOnlyBuffer kernel;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
Vector4 result = Vector4.Zero;
+ int maxY = source.Height - 1;
+ int maxX = source.Width - 1;
+ int kernelLength = kernel.Length;
int radiusX = kernelLength >> 1;
- int sourceOffsetColumnBase = ids.X;
- int offsetY = Hlsl.Clamp(ids.Y, 0, maxY);
+ int offsetY = Hlsl.Clamp(ThreadIds.Y, 0, maxY);
for (int i = 0; i < kernelLength; i++)
{
- int offsetX = Hlsl.Clamp(sourceOffsetColumnBase + i - radiusX, 0, maxX);
+ int offsetX = Hlsl.Clamp(ThreadIds.X + i - radiusX, 0, maxX);
Vector4 color = source[offsetX, offsetY];
result += kernel[i] * color;
}
- target[ids.XY] = result;
+ target[ThreadIds.XY] = result;
}
}
}
diff --git a/samples/ComputeSharp.Sample.Shared/Program.cs b/samples/ComputeSharp.Sample.Shared/Program.cs
index b56d467d..e20ef49d 100644
--- a/samples/ComputeSharp.Sample.Shared/Program.cs
+++ b/samples/ComputeSharp.Sample.Shared/Program.cs
@@ -47,9 +47,9 @@ namespace ComputeSharp.Sample
public readonly ReadWriteBuffer buffer;
///
- public void Execute(ThreadIds ids)
+ public void Execute()
{
- buffer[ids.X] *= 2;
+ buffer[ThreadIds.X] *= 2;
}
}
diff --git a/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs b/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
index bd4dc3e7..c5db9978 100644
--- a/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/AutoConstructorAttribute.cs
@@ -5,7 +5,7 @@ namespace ComputeSharp
///
/// An attribute that indicates that a target shader type should get an automatic constructor for all fields.
///
- [AttributeUsage(AttributeTargets.Struct)]
+ [AttributeUsage(AttributeTargets.Struct, AllowMultiple = false)]
public sealed class AutoConstructorAttribute : Attribute
{
}
diff --git a/src/ComputeSharp.Core/Attributes/GroupSharedAttribute.cs b/src/ComputeSharp.Core/Attributes/GroupSharedAttribute.cs
new file mode 100644
index 00000000..06f561ba
--- /dev/null
+++ b/src/ComputeSharp.Core/Attributes/GroupSharedAttribute.cs
@@ -0,0 +1,46 @@
+using System;
+
+namespace ComputeSharp
+{
+ ///
+ /// An attribute that indicates that an array static field in a shader type will be shared in a thread group.
+ ///
+ /// This attribute can be used to declare fields as follows:
+ ///
+ /// struct MyShader : IComputeShader
+ /// {
+ /// [GroupShared(32)]
+ /// static float[] MyBuffer;
+ /// }
+ ///
+ ///
+ /// The buffer shouldn't be manually initialized, as each shader invocation will automatically receive the
+ /// right buffer in use for the thread group it belongs to. If there is an assignment for the field, it
+ /// will just be ignored in the shader. Additionally, buffer types are not allowed as array items.
+ ///
+ [AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
+ public sealed class GroupSharedAttribute : Attribute
+ {
+ ///
+ /// Creates a new instance with the specified parameters.
+ ///
+ public GroupSharedAttribute()
+ {
+ }
+
+ ///
+ /// Creates a new instance with the specified parameters.
+ ///
+ /// The size of the shared buffer to declare.
+ public GroupSharedAttribute(int size)
+ {
+ Size = size;
+ }
+
+ ///
+ /// Gets the size of the shared buffer being declared.
+ /// If , the thread group size will be used.
+ ///
+ public int? Size { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Attributes/ShaderMethodAttribute.cs b/src/ComputeSharp.Core/Attributes/ShaderMethodAttribute.cs
index 9eae4f37..d644045c 100644
--- a/src/ComputeSharp.Core/Attributes/ShaderMethodAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/ShaderMethodAttribute.cs
@@ -9,7 +9,7 @@ namespace ComputeSharp
/// correctly, wrapped methods need to have this attribute manually applied to them.
/// Methods also need to be static, though this can only be tested at runtime.
///
- [AttributeUsage(AttributeTargets.Method)]
+ [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
public sealed class ShaderMethodAttribute : Attribute
{
}
diff --git a/src/ComputeSharp.Core/Attributes/__Internals/ComputeRoot32BitConstantsAttribute.cs b/src/ComputeSharp.Core/Attributes/__Internals/ComputeRoot32BitConstantsAttribute.cs
new file mode 100644
index 00000000..3277c05b
--- /dev/null
+++ b/src/ComputeSharp.Core/Attributes/__Internals/ComputeRoot32BitConstantsAttribute.cs
@@ -0,0 +1,29 @@
+using System;
+using System.ComponentModel;
+
+namespace ComputeSharp.__Internals
+{
+ ///
+ /// An attribute that contains info on the number of 32 bit constants for a given shader.
+ ///
+ /// This attribute is not meant to be directly used by applications using ComputeSharp.
+ [AttributeUsage(AttributeTargets.ReturnValue, AllowMultiple = false)]
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ [Obsolete("This attribute is not intended to be used directly by user code")]
+ public sealed class ComputeRoot32BitConstantsAttribute : Attribute
+ {
+ ///
+ /// Creates a new instance with the specified parameters.
+ ///
+ /// The number of 32 bit constants for the annotated method.
+ public ComputeRoot32BitConstantsAttribute(int count)
+ {
+ Count = count;
+ }
+
+ ///
+ /// Gets the number of 32 bit constants for the annotated method.
+ ///
+ internal int Count { get; }
+ }
+}
\ No newline at end of file
diff --git a/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
index 163d3d5d..ce076d16 100644
--- a/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
+++ b/src/ComputeSharp.Core/Attributes/__Internals/IComputeShaderSourceAttribute.cs
@@ -24,13 +24,24 @@ namespace ComputeSharp.__Internals
/// The mapped collection of shader fields.
/// The source code for the method.
/// The collection of processed methods.
- public IComputeShaderSourceAttribute(string shaderTypeName, string[] types, object[] args, string executeMethod, string[] methods)
+ /// The collection of discovered constants.
+ /// The collection of group shared buffers.
+ public IComputeShaderSourceAttribute(
+ string shaderTypeName,
+ string[] types,
+ object[] args,
+ string executeMethod,
+ string[] methods,
+ object[] constants,
+ object[] sharedBuffers)
{
ShaderTypeName = shaderTypeName;
Types = types;
Fields = args.Cast().ToDictionary(static arg => arg[0], static arg => (arg[1], arg[2]));
ExecuteMethod = executeMethod;
Methods = methods;
+ Constants = constants.Cast().ToDictionary(static c => c[0], static c => c[1]);
+ SharedBuffers = sharedBuffers.Cast