diff --git a/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
new file mode 100644
index 00000000..bf61fc4e
--- /dev/null
+++ b/src/ComputeSharp/Extensions/GraphicsDeviceExtensions.cs
@@ -0,0 +1,28 @@
+using System;
+using ComputeSharp.Graphics;
+using ComputeSharp.Shaders;
+
+namespace ComputeSharp
+{
+ ///
+ /// A that contains extension methods for the type, used to run compute shaders
+ ///
+ public static class GraphicsDeviceExtensions
+ {
+ ///
+ /// The default number of threads in a thead froup
+ ///
+ public const int DefaultThreadGroupCount = 64;
+
+ ///
+ /// Compiles and runs the input shader on a target instance, with the specified parameters
+ ///
+ /// The to use to run the shader
+ /// The number of threads to run on the X axis
+ /// The input representing the compute shader to run
+ public static void For(this GraphicsDevice device, int x, Action action)
+ {
+ ShaderRunner.Run(device, (x, 1), (1, 1), action);
+ }
+ }
+}
diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs
index 8fc43d6b..7af82c16 100644
--- a/src/ComputeSharp/Gpu.cs
+++ b/src/ComputeSharp/Gpu.cs
@@ -1,14 +1,4 @@
-using System;
-using System.Linq;
-using ComputeSharp.Graphics;
-using ComputeSharp.Shaders;
-using ComputeSharp.Shaders.Renderer;
-using ComputeSharp.Shaders.Renderer.Models;
-using ComputeSharp.Shaders.Translation;
-using SharpDX.Direct3D12;
-using CommandList = ComputeSharp.Graphics.CommandList;
-using PipelineState = ComputeSharp.Graphics.PipelineState;
-using ShaderBytecode = SharpDX.Direct3D12.ShaderBytecode;
+using ComputeSharp.Graphics;
namespace ComputeSharp
{
@@ -24,47 +14,4 @@ namespace ComputeSharp
///
public static GraphicsDevice Default => _Default ??= new GraphicsDevice(true);
}
-
- public static class GraphicsDeviceExtensions
- {
- public static void For(this GraphicsDevice device, int n, Action action)
- {
- // Load the input shader
- ShaderLoader shaderLoader = ShaderLoader.Load(action);
-
- // Render the loaded shader
- ShaderInfo shaderInfo = new ShaderInfo
- {
- FieldsList = shaderLoader.FieldsInfo,
- ThreadsX = n,
- ThreadsY = 1,
- ThreadsZ = 1,
- ThreadsIdsVariableName = shaderLoader.ThreadsIdsVariableName,
- ShaderBody = shaderLoader.MethodBody
- };
- string shaderSource = ShaderRenderer.Instance.Render(shaderInfo);
-
- // Compile the loaded shader to HLSL bytecode
- ShaderBytecode shaderBytecode = ShaderCompiler.Instance.CompileShader(shaderSource);
-
- // Create the root signature for the pipeline and the pipeline state
- RootSignatureDescription rootSignatureDescription = new RootSignatureDescription(RootSignatureFlags.None, shaderLoader.RootParameters);
- RootSignature rootSignature = device.CreateRootSignature(rootSignatureDescription);
- PipelineState pipelineState = new PipelineState(device, rootSignature, shaderBytecode);
-
- // Create the commands list
- using CommandList commandList = new CommandList(device, CommandListType.Compute);
- commandList.SetPipelineState(pipelineState);
-
- // Load the captured buffers
- foreach (var buffer in shaderLoader.ReadWriteBuffers.Select((r, i) => (Resource: r, Index: i)))
- {
- commandList.SetComputeRootDescriptorTable(buffer.Index, buffer.Resource);
- }
-
- // Dispatch and wait for completion
- commandList.Dispatch(1, 1, 1);
- commandList.Flush(true);
- }
- }
}