diff --git a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationFactory{T}.cs b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationFactory{T}.cs
index 817e981f..91592432 100644
--- a/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationFactory{T}.cs
+++ b/samples/ComputeSharp.SwapChain/Backend/Win32ApplicationFactory{T}.cs
@@ -1,4 +1,5 @@
using System;
+using ComputeSharp.Descriptors;
using TerraFX.Interop.Windows;
namespace ComputeSharp.SwapChain.Backend;
@@ -11,7 +12,7 @@ namespace ComputeSharp.SwapChain.Backend;
/// The main point of this type is to hide the complexity of from the non-NativeAOT sample.
///
internal static class Win32ApplicationFactory
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
///
/// The instance used to create shaders to run.
diff --git a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs
index c16e6b14..adfff47f 100644
--- a/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs
+++ b/src/ComputeSharp.Dynamic/Shaders/Interop/ReflectionServices.cs
@@ -1,15 +1,13 @@
using System;
using System.Runtime.CompilerServices;
-using ComputeSharp.__Internals;
using ComputeSharp.Core.Extensions;
+using ComputeSharp.Descriptors;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
#if !NET6_0_OR_GREATER
using DirectX = TerraFX.Interop.DirectX.DirectX2;
#endif
-#pragma warning disable CS0618
-
namespace ComputeSharp.Interop;
///
@@ -32,7 +30,7 @@ public static class ReflectionServices
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
///
public static ShaderInfo GetShaderInfo()
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
return GetNonGenericShaderInfo(default(T));
}
@@ -49,7 +47,7 @@ public static class ReflectionServices
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
///
public static unsafe ShaderInfo GetShaderInfo(in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
return GetNonGenericShaderInfo(in shader);
}
@@ -70,7 +68,7 @@ public static class ReflectionServices
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
///
public static ShaderInfo GetShaderInfo()
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
return GetNonGenericShaderInfo(default(T));
@@ -89,7 +87,7 @@ public static class ReflectionServices
/// the APIs to dispatch a shader, the thread sizes would actually be set to a proper value insead.
///
public static unsafe ShaderInfo GetShaderInfo(in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
return GetNonGenericShaderInfo(in shader);
@@ -102,7 +100,7 @@ public static class ReflectionServices
/// The input shader to retrieve info for.
/// The resulting instance.
private static unsafe ShaderInfo GetNonGenericShaderInfo(in T shader)
- where T : struct, IShader
+ where T : struct, IComputeShaderDescriptor
{
string hlslSource = Unsafe.AsRef(in shader).HlslSource;
diff --git a/src/ComputeSharp.SourceGenerators/ComputeSharp/Core/Interfaces/__Internals/IShader.cs b/src/ComputeSharp.SourceGenerators/ComputeSharp/Core/Interfaces/__Internals/IShader.cs
deleted file mode 100644
index 2a41f8d2..00000000
--- a/src/ComputeSharp.SourceGenerators/ComputeSharp/Core/Interfaces/__Internals/IShader.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.ComponentModel;
-
-namespace ComputeSharp.__Internals;
-
-///
-/// A base representing a given shader that can be dispatched.
-///
-[EditorBrowsable(EditorBrowsableState.Never)]
-[Obsolete("This interface is not intended to be used directly by user code")]
-public interface IShader
-{
-}
\ No newline at end of file
diff --git a/src/ComputeSharp.WinUI/ShaderRunner{T}.cs b/src/ComputeSharp.WinUI/ShaderRunner{T}.cs
index 0ad131f0..f8a9d82a 100644
--- a/src/ComputeSharp.WinUI/ShaderRunner{T}.cs
+++ b/src/ComputeSharp.WinUI/ShaderRunner{T}.cs
@@ -1,4 +1,5 @@
using System;
+using ComputeSharp.Descriptors;
namespace ComputeSharp.WinUI;
@@ -8,7 +9,7 @@ namespace ComputeSharp.WinUI;
///
/// The type of shader to use to render frames.
public sealed class ShaderRunner : IShaderRunner
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
///
/// The instance used to create shaders to run.
diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs b/src/ComputeSharp/Core/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
similarity index 79%
rename from src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs
rename to src/ComputeSharp/Core/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
index 1669dcc5..55a550b6 100644
--- a/src/ComputeSharp/Core/Interfaces/__Internals/IShader.cs
+++ b/src/ComputeSharp/Core/Interfaces/Descriptors/IComputeShaderDescriptor{T}.cs
@@ -1,15 +1,16 @@
using System;
-using System.ComponentModel;
using ComputeSharp.Interop;
-namespace ComputeSharp.__Internals;
+namespace ComputeSharp.Descriptors;
///
-/// A base representing a given shader that can be dispatched.
+/// An interface for a descriptor for a given compute shader.
+/// Descriptors contain metadata associated to compute shaders,
+/// with all information needed to execute them at runtime.
///
-[EditorBrowsable(EditorBrowsableState.Never)]
-[Obsolete("This interface is not intended to be used directly by user code")]
-public interface IShader
+/// The type of compute shader being described.
+public interface IComputeShaderDescriptor
+ where T : struct
{
///
/// The number of threads in each thread group for the X axis.
@@ -63,18 +64,20 @@ public interface IShader
/// Loads the constant buffer of a given input shader.
///
/// The type of data loader being used.
+ /// The input shader to load the constant buffer for.
/// The instance to use to load the data.
/// The number of iterations to run on the X axis.
/// The number of iterations to run on the Y axis.
/// The number of iterations to run on the Z axis.
- void LoadConstantBuffer(ref TLoader loader, int x, int y, int z)
+ void LoadConstantBuffer(in T shader, ref TLoader loader, int x, int y, int z)
where TLoader : struct, IConstantBufferLoader;
///
/// Loads the graphics resources for the shader.
///
/// The type of graphics resource loader being used.
+ /// The input shader to load the graphics resources for.
/// The instance to use to load the data.
- void LoadGraphicsResources(ref TLoader loader)
+ void LoadGraphicsResources(in T shader, ref TLoader loader)
where TLoader : struct, IGraphicsResourceLoader;
}
\ No newline at end of file
diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IConstantBufferLoader.cs b/src/ComputeSharp/Core/Interfaces/Descriptors/IConstantBufferLoader.cs
similarity index 94%
rename from src/ComputeSharp/Core/Interfaces/__Internals/IConstantBufferLoader.cs
rename to src/ComputeSharp/Core/Interfaces/Descriptors/IConstantBufferLoader.cs
index 76c584af..07ffa616 100644
--- a/src/ComputeSharp/Core/Interfaces/__Internals/IConstantBufferLoader.cs
+++ b/src/ComputeSharp/Core/Interfaces/Descriptors/IConstantBufferLoader.cs
@@ -1,6 +1,6 @@
using System;
-namespace ComputeSharp.__Internals;
+namespace ComputeSharp.Descriptors;
///
/// A type representing a data loader for the constant buffer of a compute shader.
diff --git a/src/ComputeSharp/Core/Interfaces/__Internals/IGraphicsResourceLoader.cs b/src/ComputeSharp/Core/Interfaces/Descriptors/IGraphicsResourceLoader.cs
similarity index 96%
rename from src/ComputeSharp/Core/Interfaces/__Internals/IGraphicsResourceLoader.cs
rename to src/ComputeSharp/Core/Interfaces/Descriptors/IGraphicsResourceLoader.cs
index d5edd8c8..56cd09cc 100644
--- a/src/ComputeSharp/Core/Interfaces/__Internals/IGraphicsResourceLoader.cs
+++ b/src/ComputeSharp/Core/Interfaces/Descriptors/IGraphicsResourceLoader.cs
@@ -1,6 +1,6 @@
using System;
-namespace ComputeSharp.__Internals;
+namespace ComputeSharp.Descriptors;
///
/// A type representing a loader object for values used in compute shaders.
diff --git a/src/ComputeSharp/Core/Interfaces/IComputeShader.cs b/src/ComputeSharp/Core/Interfaces/IComputeShader.cs
index 1b4e7727..430cc54c 100644
--- a/src/ComputeSharp/Core/Interfaces/IComputeShader.cs
+++ b/src/ComputeSharp/Core/Interfaces/IComputeShader.cs
@@ -1,13 +1,9 @@
-using ComputeSharp.__Internals;
-
-#pragma warning disable CS0618
-
namespace ComputeSharp;
///
/// An representing a compute shader.
///
-public interface IComputeShader : IShader
+public interface IComputeShader
{
///
/// Executes the current compute shader.
diff --git a/src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs b/src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs
index c661f72d..614296c3 100644
--- a/src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs
+++ b/src/ComputeSharp/Core/Interfaces/IComputeShader{TPixel}.cs
@@ -1,7 +1,3 @@
-using ComputeSharp.__Internals;
-
-#pragma warning disable CS0618
-
namespace ComputeSharp;
///
@@ -11,7 +7,7 @@ namespace ComputeSharp;
///
/// This interface allows implementing logic analogous of pixel shaders, but via compute shaders.
///
-public interface IComputeShader : IShader
+public interface IComputeShader
where TPixel : unmanaged
{
///
diff --git a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs
index 6b026dd6..74420060 100644
--- a/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs
+++ b/src/ComputeSharp/Graphics/Extensions/GraphicsDeviceExtensions.Dispatching.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.CompilerServices;
+using ComputeSharp.Descriptors;
using ComputeSharp.Interop;
namespace ComputeSharp;
@@ -17,7 +18,7 @@ public static partial class GraphicsDeviceExtensions
/// The number of iterations to run on the X axis.
/// The input instance representing the compute shader to run.
public static void For(this GraphicsDevice device, int x, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
default(ArgumentNullException).ThrowIfNull(device);
@@ -35,7 +36,7 @@ public static partial class GraphicsDeviceExtensions
/// The number of iterations to run on the Y axis.
/// The input instance representing the compute shader to run.
public static void For(this GraphicsDevice device, int x, int y, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
default(ArgumentNullException).ThrowIfNull(device);
@@ -54,7 +55,7 @@ public static partial class GraphicsDeviceExtensions
/// The number of iterations to run on the Z axis.
/// The input instance representing the compute shader to run.
public static void For(this GraphicsDevice device, int x, int y, int z, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
default(ArgumentNullException).ThrowIfNull(device);
@@ -71,7 +72,7 @@ public static partial class GraphicsDeviceExtensions
/// The to use to run the shader.
/// The target texture to apply the pixel shader to.
public static void ForEach(this GraphicsDevice device, IReadWriteNormalizedTexture2D texture)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(device);
@@ -91,7 +92,7 @@ public static partial class GraphicsDeviceExtensions
/// The target texture to apply the pixel shader to.
/// The input instance representing the pixel shader to run.
public static void ForEach(this GraphicsDevice device, IReadWriteNormalizedTexture2D texture, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(device);
diff --git a/src/ComputeSharp/Shaders/ComputeContext.cs b/src/ComputeSharp/Shaders/ComputeContext.cs
index 7db08910..abcc71f8 100644
--- a/src/ComputeSharp/Shaders/ComputeContext.cs
+++ b/src/ComputeSharp/Shaders/ComputeContext.cs
@@ -2,6 +2,7 @@ using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
+using ComputeSharp.Descriptors;
using ComputeSharp.Graphics.Commands;
using ComputeSharp.Graphics.Extensions;
using ComputeSharp.Resources.Interop;
@@ -9,8 +10,6 @@ using ComputeSharp.Shaders.Dispatching;
using ComputeSharp.Shaders.Loading;
using TerraFX.Interop.DirectX;
-#pragma warning disable CS0618
-
namespace ComputeSharp;
///
@@ -123,7 +122,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
/// The number of iterations to run on the X axis.
/// The input instance representing the compute shader to run.
internal readonly unsafe void Run(int x, ref T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
Run(x, 1, 1, ref shader);
@@ -136,7 +135,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
/// The number of iterations to run on the Y axis.
/// The input instance representing the compute shader to run.
internal readonly unsafe void Run(int x, int y, ref T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
Run(x, y, 1, ref shader);
@@ -151,7 +150,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
/// The number of iterations to run on the Z axis.
/// The input instance representing the compute shader to run.
internal readonly unsafe void Run(int x, int y, int z, ref T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
default(InvalidOperationException).ThrowIf(this.device is null);
default(ArgumentOutOfRangeException).ThrowIfNegativeOrZero(x);
@@ -174,11 +173,11 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
D3D12GraphicsCommandListConstantBufferLoader dataLoader = new(commandList.D3D12GraphicsCommandList);
- shader.LoadConstantBuffer(ref dataLoader, x, y, z);
+ shader.LoadConstantBuffer(in shader, ref dataLoader, x, y, z);
D3D12GraphicsCommandListGraphicsResourceLoader graphicsResourceLoader = new(commandList.D3D12GraphicsCommandList, this.device, rootParameterOffset: 1);
- shader.LoadGraphicsResources(ref graphicsResourceLoader);
+ shader.LoadGraphicsResources(in shader, ref graphicsResourceLoader);
commandList.D3D12GraphicsCommandList->Dispatch((uint)groupsX, (uint)groupsY, (uint)groupsZ);
}
@@ -191,7 +190,7 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
/// The target texture to invoke the pixel shader upon.
/// The input instance representing the pixel shader to run.
internal readonly unsafe void Run(IReadWriteNormalizedTexture2D texture, ref T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
default(InvalidOperationException).ThrowIf(this.device is null);
@@ -212,11 +211,11 @@ public struct ComputeContext : IDisposable, IAsyncDisposable
D3D12GraphicsCommandListConstantBufferLoader constantBufferLoader = new(commandList.D3D12GraphicsCommandList);
- shader.LoadConstantBuffer(ref constantBufferLoader, x, y, 1);
+ shader.LoadConstantBuffer(in shader, ref constantBufferLoader, x, y, 1);
D3D12GraphicsCommandListGraphicsResourceLoader graphicsResourceLoader = new(commandList.D3D12GraphicsCommandList, this.device, rootParameterOffset: 2);
- shader.LoadGraphicsResources(ref graphicsResourceLoader);
+ shader.LoadGraphicsResources(in shader, ref graphicsResourceLoader);
// Load the implicit output texture
commandList.D3D12GraphicsCommandList->SetComputeRootDescriptorTable(
diff --git a/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListConstantBufferLoader.cs b/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListConstantBufferLoader.cs
index 5d8056a5..5984feb7 100644
--- a/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListConstantBufferLoader.cs
+++ b/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListConstantBufferLoader.cs
@@ -1,7 +1,7 @@
using System;
using System.Runtime.CompilerServices;
+using ComputeSharp.Descriptors;
using ComputeSharp.Graphics.Extensions;
-using ComputeSharp.__Internals;
using TerraFX.Interop.DirectX;
namespace ComputeSharp.Shaders.Dispatching;
diff --git a/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListGraphicsResourceLoader.cs b/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListGraphicsResourceLoader.cs
index 4858ee7e..80391e0f 100644
--- a/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListGraphicsResourceLoader.cs
+++ b/src/ComputeSharp/Shaders/Dispatching/D3D12GraphicsCommandListGraphicsResourceLoader.cs
@@ -1,8 +1,8 @@
using System;
using System.Runtime.CompilerServices;
-using ComputeSharp.__Internals;
-using TerraFX.Interop.DirectX;
using ComputeSharp.Resources.Interop;
+using ComputeSharp.Descriptors;
+using TerraFX.Interop.DirectX;
namespace ComputeSharp.Shaders.Dispatching;
diff --git a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs
index 0776a540..dcf2ad53 100644
--- a/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs
+++ b/src/ComputeSharp/Shaders/Extensions/ComputeContextExtensions.cs
@@ -1,5 +1,6 @@
using System;
using System.Runtime.CompilerServices;
+using ComputeSharp.Descriptors;
using ComputeSharp.Graphics.Helpers;
using ComputeSharp.Interop;
using ComputeSharp.Resources.Interop;
@@ -484,7 +485,7 @@ public static class ComputeContextExtensions
/// The number of iterations to run on the X axis.
/// The input instance representing the compute shader to run.
public static void For(this in ComputeContext context, int x, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
context.Run(x, ref Unsafe.AsRef(in shader));
}
@@ -498,7 +499,7 @@ public static class ComputeContextExtensions
/// The number of iterations to run on the Y axis.
/// The input instance representing the compute shader to run.
public static void For(this in ComputeContext context, int x, int y, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
context.Run(x, y, ref Unsafe.AsRef(in shader));
}
@@ -513,7 +514,7 @@ public static class ComputeContextExtensions
/// The number of iterations to run on the Z axis.
/// The input instance representing the compute shader to run.
public static void For(this in ComputeContext context, int x, int y, int z, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
{
context.Run(x, y, z, ref Unsafe.AsRef(in shader));
}
@@ -526,7 +527,7 @@ public static class ComputeContextExtensions
/// The to use to run the shader.
/// The target texture to apply the pixel shader to.
public static void ForEach(this in ComputeContext context, IReadWriteNormalizedTexture2D texture)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(texture);
@@ -543,7 +544,7 @@ public static class ComputeContextExtensions
/// The target texture to apply the pixel shader to.
/// The input instance representing the pixel shader to run.
public static void ForEach(this in ComputeContext context, IReadWriteNormalizedTexture2D texture, in T shader)
- where T : struct, IComputeShader
+ where T : struct, IComputeShader, IComputeShaderDescriptor
where TPixel : unmanaged
{
default(ArgumentNullException).ThrowIfNull(texture);
diff --git a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs
index 3366a4d6..ee9f2acd 100644
--- a/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs
+++ b/src/ComputeSharp/Shaders/Loading/PipelineDataLoader{T}.cs
@@ -2,14 +2,12 @@ using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using ComputeSharp.Shaders.Extensions;
+using ComputeSharp.Descriptors;
using ComputeSharp.Interop;
-using ComputeSharp.__Internals;
using TerraFX.Interop.DirectX;
using TerraFX.Interop.Windows;
using static TerraFX.Interop.DirectX.D3D12_DESCRIPTOR_RANGE_FLAGS;
-#pragma warning disable CS0618
-
namespace ComputeSharp.Shaders.Loading;
///
@@ -17,7 +15,7 @@ namespace ComputeSharp.Shaders.Loading;
///
/// The type of compute shader to load.
internal static unsafe class PipelineDataLoader
- where T : struct, IShader
+ where T : struct, IComputeShaderDescriptor
{
///
/// The map of cached instances for each GPU in use.