diff --git a/src/ComputeSharp.sln b/src/ComputeSharp.sln
index f6dfac4e..e28fc3f4 100644
--- a/src/ComputeSharp.sln
+++ b/src/ComputeSharp.sln
@@ -3,30 +3,54 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29201.188
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectX12GameEngine.Graphics", "DirectX12GameEngine.Graphics\DirectX12GameEngine.Graphics.csproj", "{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Graphics", "DirectX12GameEngine.Graphics\DirectX12GameEngine.Graphics.csproj", "{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectX12GameEngine.Shaders", "DirectX12GameEngine.Shaders\DirectX12GameEngine.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Shaders", "DirectX12GameEngine.Shaders\DirectX12GameEngine.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectX12GameEngine.Core", "DirectX12GameEngine.Core\DirectX12GameEngine.Core.csproj", "{314EB353-E7E3-4146-8111-685CC83EC1DE}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Core", "DirectX12GameEngine.Core\DirectX12GameEngine.Core.csproj", "{314EB353-E7E3-4146-8111-685CC83EC1DE}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectX12ComputeShaderSample", "DirectX12ComputeShaderSample\DirectX12ComputeShaderSample.csproj", "{7A48A85D-8866-4DED-A404-653ED09BF396}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Debug|x64.Build.0 = Debug|Any CPU
{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Release|x64.ActiveCfg = Release|Any CPU
+ {2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}.Release|x64.Build.0 = Release|Any CPU
{23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Debug|x64.Build.0 = Debug|Any CPU
{23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Release|Any CPU.ActiveCfg = Release|Any CPU
{23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Release|Any CPU.Build.0 = Release|Any CPU
+ {23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Release|x64.ActiveCfg = Release|Any CPU
+ {23AE6EED-79CD-4ADD-9A85-0148BD957D19}.Release|x64.Build.0 = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|Any CPU
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|Any CPU
+ {314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Debug|x64.Build.0 = Debug|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Release|Any CPU.Build.0 = Release|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Release|x64.ActiveCfg = Release|Any CPU
+ {7A48A85D-8866-4DED-A404-653ED09BF396}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj
new file mode 100644
index 00000000..0823373d
--- /dev/null
+++ b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj
@@ -0,0 +1,13 @@
+
+
+
+ Exe
+ netcoreapp3.0
+
+
+
+
+
+
+
+
diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs
new file mode 100644
index 00000000..d1c1e343
--- /dev/null
+++ b/src/DirectX12ComputeShaderSample/Program.cs
@@ -0,0 +1,120 @@
+using DirectX12GameEngine.Graphics;
+using DirectX12GameEngine.Shaders;
+using DirectX12GameEngine.Shaders.Numerics;
+using System;
+using System.Linq;
+
+using Buffer = DirectX12GameEngine.Graphics.Buffer;
+
+namespace DirectX12ComputeShaderSample
+{
+ public class MyComputeShader
+ {
+ [ConstantBufferResource] public uint Width;
+
+ [ShaderResource] public RWBufferResource Data;
+
+ [ShaderMethod]
+ [Shader("compute")]
+ [NumThreads(5, 5, 1)]
+ public void CSMain([SystemDispatchThreadIdSemantic] UInt3 id)
+ {
+ Data[id.X + id.Y * Width] *= 2;
+ }
+ }
+
+ public class Program
+ {
+ private static void Main()
+ {
+ // Generate computer shader
+
+ MyComputeShader myComputeShader = new MyComputeShader();
+ ShaderGenerator shaderGenerator = new ShaderGenerator(myComputeShader);
+ ShaderGenerationResult result = shaderGenerator.GenerateShader();
+
+ byte[] shaderBytecode = ShaderCompiler.CompileShader(result.ShaderSource, SharpDX.D3DCompiler.ShaderVersion.ComputeShader, result.ComputeShader);
+
+ // Create graphics device and pipeline state
+
+ using GraphicsDevice device = new GraphicsDevice(SharpDX.Direct3D.FeatureLevel.Level_12_1, true);
+
+ SharpDX.Direct3D12.RootParameter[] rootParameters = new SharpDX.Direct3D12.RootParameter[]
+ {
+ new SharpDX.Direct3D12.RootParameter(SharpDX.Direct3D12.ShaderVisibility.All,
+ new SharpDX.Direct3D12.RootConstants(0, 0, 1)),
+ new SharpDX.Direct3D12.RootParameter(SharpDX.Direct3D12.ShaderVisibility.All,
+ new SharpDX.Direct3D12.DescriptorRange(SharpDX.Direct3D12.DescriptorRangeType.UnorderedAccessView, 1, 0))
+ };
+
+ var rootSignatureDescription = new SharpDX.Direct3D12.RootSignatureDescription(SharpDX.Direct3D12.RootSignatureFlags.None, rootParameters);
+ var rootSignature = device.CreateRootSignature(rootSignatureDescription);
+
+ PipelineState pipelineState = new PipelineState(device, rootSignature, shaderBytecode);
+
+ // Create graphics buffer
+
+ int width = 10;
+ int height = 10;
+
+ float[] array = new float[width * height];
+
+ for (int i = 0; i < array.Length; i++)
+ {
+ array[i] = i + 1;
+ }
+
+ using Buffer inputBuffer = Buffer.New(device, array.AsSpan(), BufferFlags.UnorderedAccess, GraphicsHeapType.Default);
+
+ // Execute computer shader
+
+ using (CommandList commandList = new CommandList(device, CommandListType.Compute))
+ {
+ commandList.SetPipelineState(pipelineState);
+
+ commandList.SetComputeRoot32BitConstant(0, width, 0);
+ commandList.SetComputeRootDescriptorTable(1, inputBuffer);
+
+ commandList.Dispatch(2, 2, 1);
+ commandList.Flush(true);
+ }
+
+ // Copy data back to CPU
+
+ using Buffer outputBuffer = Buffer.New(device, array.Length, BufferFlags.None, GraphicsHeapType.Readback);
+
+ using (CommandList copyCommandList = new CommandList(device, CommandListType.Copy))
+ {
+ copyCommandList.CopyResource(inputBuffer, outputBuffer);
+ copyCommandList.Flush(true);
+ }
+
+ // Print matrix
+
+ Console.WriteLine("Before:");
+ PrintMatrix(array, width, height);
+
+ outputBuffer.GetData(array.AsSpan());
+
+ Console.WriteLine();
+ Console.WriteLine("After:");
+ PrintMatrix(array, width, height);
+ }
+
+ private static void PrintMatrix(float[] array, int width, int height)
+ {
+ int numberWidth = array.Max().ToString().Length;
+
+ for (int y = 0; y < height; y++)
+ {
+ for (int x = 0; x < width; x++)
+ {
+ Console.Write(array[x + y * width].ToString().PadLeft(numberWidth));
+ Console.Write(", ");
+ }
+
+ Console.WriteLine();
+ }
+ }
+ }
+}