From de864f2875284d52c62cc72fed5b284e73edf744 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:23:26 +0200 Subject: [PATCH 01/21] Renamed main project, minor API changes --- src/ComputeSharp.sln | 4 ++-- .../ComputeSharp.csproj} | 0 .../Extensions/PointExtensions.cs | 0 .../Extensions/RectExtensions.cs | 0 .../Extensions/SizeExtensions.cs | 0 src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs | 2 +- .../DirectX12GameEngine.Graphics.csproj | 2 +- .../Helpers/MemoryHelper.cs | 2 +- .../DirectX12GameEngine.Shaders.csproj | 2 +- 9 files changed, 6 insertions(+), 6 deletions(-) rename src/{DirectX12GameEngine.Core/DirectX12GameEngine.Core.csproj => ComputeSharp/ComputeSharp.csproj} (100%) rename src/{DirectX12GameEngine.Core => ComputeSharp}/Extensions/PointExtensions.cs (100%) rename src/{DirectX12GameEngine.Core => ComputeSharp}/Extensions/RectExtensions.cs (100%) rename src/{DirectX12GameEngine.Core => ComputeSharp}/Extensions/SizeExtensions.cs (100%) rename src/{DirectX12GameEngine.Core => DirectX12GameEngine.Graphics}/Helpers/MemoryHelper.cs (97%) diff --git a/src/ComputeSharp.sln b/src/ComputeSharp.sln index e28fc3f4..08b4bd61 100644 --- a/src/ComputeSharp.sln +++ b/src/ComputeSharp.sln @@ -7,9 +7,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Graphic EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Shaders", "DirectX12GameEngine.Shaders\DirectX12GameEngine.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Core", "DirectX12GameEngine.Core\DirectX12GameEngine.Core.csproj", "{314EB353-E7E3-4146-8111-685CC83EC1DE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp", "ComputeSharp\ComputeSharp.csproj", "{314EB353-E7E3-4146-8111-685CC83EC1DE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DirectX12ComputeShaderSample", "DirectX12ComputeShaderSample\DirectX12ComputeShaderSample.csproj", "{7A48A85D-8866-4DED-A404-653ED09BF396}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12ComputeShaderSample", "DirectX12ComputeShaderSample\DirectX12ComputeShaderSample.csproj", "{7A48A85D-8866-4DED-A404-653ED09BF396}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/DirectX12GameEngine.Core/DirectX12GameEngine.Core.csproj b/src/ComputeSharp/ComputeSharp.csproj similarity index 100% rename from src/DirectX12GameEngine.Core/DirectX12GameEngine.Core.csproj rename to src/ComputeSharp/ComputeSharp.csproj diff --git a/src/DirectX12GameEngine.Core/Extensions/PointExtensions.cs b/src/ComputeSharp/Extensions/PointExtensions.cs similarity index 100% rename from src/DirectX12GameEngine.Core/Extensions/PointExtensions.cs rename to src/ComputeSharp/Extensions/PointExtensions.cs diff --git a/src/DirectX12GameEngine.Core/Extensions/RectExtensions.cs b/src/ComputeSharp/Extensions/RectExtensions.cs similarity index 100% rename from src/DirectX12GameEngine.Core/Extensions/RectExtensions.cs rename to src/ComputeSharp/Extensions/RectExtensions.cs diff --git a/src/DirectX12GameEngine.Core/Extensions/SizeExtensions.cs b/src/ComputeSharp/Extensions/SizeExtensions.cs similarity index 100% rename from src/DirectX12GameEngine.Core/Extensions/SizeExtensions.cs rename to src/ComputeSharp/Extensions/SizeExtensions.cs diff --git a/src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs b/src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs index db4052e0..2a4a4e87 100644 --- a/src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs +++ b/src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.CompilerServices; -using DirectX12GameEngine.Core.Helpers; using DirectX12GameEngine.Graphics.Buffers.Abstract; +using DirectX12GameEngine.Graphics.Helpers; using SharpDX.Direct3D12; namespace DirectX12GameEngine.Graphics.Buffers diff --git a/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj b/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj index e2b2653d..5157ea8f 100644 --- a/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj +++ b/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/DirectX12GameEngine.Core/Helpers/MemoryHelper.cs b/src/DirectX12GameEngine.Graphics/Helpers/MemoryHelper.cs similarity index 97% rename from src/DirectX12GameEngine.Core/Helpers/MemoryHelper.cs rename to src/DirectX12GameEngine.Graphics/Helpers/MemoryHelper.cs index 559eabee..b7b01f42 100644 --- a/src/DirectX12GameEngine.Core/Helpers/MemoryHelper.cs +++ b/src/DirectX12GameEngine.Graphics/Helpers/MemoryHelper.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.CompilerServices; -namespace DirectX12GameEngine.Core.Helpers +namespace DirectX12GameEngine.Graphics.Helpers { /// /// A with some helper methods to copy data between memory areas diff --git a/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj b/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj index 936e6672..9ef31fbd 100644 --- a/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj +++ b/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj @@ -18,7 +18,7 @@ - + From 6571390ef32333f3c900ea6623c7f4b39572587f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:31:36 +0200 Subject: [PATCH 02/21] Graphics project renamed, dependencies adjusted --- .../BufferDescription.cs | 0 .../BufferFlags.cs | 0 .../Buffers/Abstract/GraphicsResource.cs | 0 .../Buffers/Buffer.Constant.cs | 0 .../Buffers/Buffer.UnorderedAccess.cs | 0 .../Buffers/Buffer.cs | 0 .../CommandAllocatorPool.cs | 0 .../CommandList.cs | 0 .../CompiledCommandList.cs | 0 .../ComputeSharp.Graphics.csproj} | 8 ++++---- .../DescriptorAllocator.cs | 0 .../GraphicsDevice.cs | 0 .../GraphicsResourceUsage.cs | 0 .../Helpers/MemoryHelper.cs | 0 .../PipelineState.cs | 0 src/ComputeSharp.sln | 2 +- .../DirectX12ComputeShaderSample.csproj | 2 +- .../DirectX12GameEngine.Shaders.csproj | 3 +-- 18 files changed, 7 insertions(+), 8 deletions(-) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/BufferDescription.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/BufferFlags.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/Buffers/Abstract/GraphicsResource.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/Buffers/Buffer.Constant.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/Buffers/Buffer.UnorderedAccess.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/Buffers/Buffer.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/CommandAllocatorPool.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/CommandList.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/CompiledCommandList.cs (100%) rename src/{DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj => ComputeSharp.Graphics/ComputeSharp.Graphics.csproj} (51%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/DescriptorAllocator.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/GraphicsDevice.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/GraphicsResourceUsage.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/Helpers/MemoryHelper.cs (100%) rename src/{DirectX12GameEngine.Graphics => ComputeSharp.Graphics}/PipelineState.cs (100%) diff --git a/src/DirectX12GameEngine.Graphics/BufferDescription.cs b/src/ComputeSharp.Graphics/BufferDescription.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/BufferDescription.cs rename to src/ComputeSharp.Graphics/BufferDescription.cs diff --git a/src/DirectX12GameEngine.Graphics/BufferFlags.cs b/src/ComputeSharp.Graphics/BufferFlags.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/BufferFlags.cs rename to src/ComputeSharp.Graphics/BufferFlags.cs diff --git a/src/DirectX12GameEngine.Graphics/Buffers/Abstract/GraphicsResource.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/Buffers/Abstract/GraphicsResource.cs rename to src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs diff --git a/src/DirectX12GameEngine.Graphics/Buffers/Buffer.Constant.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/Buffers/Buffer.Constant.cs rename to src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs diff --git a/src/DirectX12GameEngine.Graphics/Buffers/Buffer.UnorderedAccess.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/Buffers/Buffer.UnorderedAccess.cs rename to src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs diff --git a/src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/Buffers/Buffer.cs rename to src/ComputeSharp.Graphics/Buffers/Buffer.cs diff --git a/src/DirectX12GameEngine.Graphics/CommandAllocatorPool.cs b/src/ComputeSharp.Graphics/CommandAllocatorPool.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/CommandAllocatorPool.cs rename to src/ComputeSharp.Graphics/CommandAllocatorPool.cs diff --git a/src/DirectX12GameEngine.Graphics/CommandList.cs b/src/ComputeSharp.Graphics/CommandList.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/CommandList.cs rename to src/ComputeSharp.Graphics/CommandList.cs diff --git a/src/DirectX12GameEngine.Graphics/CompiledCommandList.cs b/src/ComputeSharp.Graphics/CompiledCommandList.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/CompiledCommandList.cs rename to src/ComputeSharp.Graphics/CompiledCommandList.cs diff --git a/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj similarity index 51% rename from src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj rename to src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj index 5157ea8f..497079a7 100644 --- a/src/DirectX12GameEngine.Graphics/DirectX12GameEngine.Graphics.csproj +++ b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj @@ -8,11 +8,11 @@ + - - - - + + + diff --git a/src/DirectX12GameEngine.Graphics/DescriptorAllocator.cs b/src/ComputeSharp.Graphics/DescriptorAllocator.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/DescriptorAllocator.cs rename to src/ComputeSharp.Graphics/DescriptorAllocator.cs diff --git a/src/DirectX12GameEngine.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/GraphicsDevice.cs rename to src/ComputeSharp.Graphics/GraphicsDevice.cs diff --git a/src/DirectX12GameEngine.Graphics/GraphicsResourceUsage.cs b/src/ComputeSharp.Graphics/GraphicsResourceUsage.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/GraphicsResourceUsage.cs rename to src/ComputeSharp.Graphics/GraphicsResourceUsage.cs diff --git a/src/DirectX12GameEngine.Graphics/Helpers/MemoryHelper.cs b/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/Helpers/MemoryHelper.cs rename to src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs diff --git a/src/DirectX12GameEngine.Graphics/PipelineState.cs b/src/ComputeSharp.Graphics/PipelineState.cs similarity index 100% rename from src/DirectX12GameEngine.Graphics/PipelineState.cs rename to src/ComputeSharp.Graphics/PipelineState.cs diff --git a/src/ComputeSharp.sln b/src/ComputeSharp.sln index 08b4bd61..a5d6dea6 100644 --- a/src/ComputeSharp.sln +++ b/src/ComputeSharp.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29201.188 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Graphics", "DirectX12GameEngine.Graphics\DirectX12GameEngine.Graphics.csproj", "{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Graphics", "ComputeSharp.Graphics\ComputeSharp.Graphics.csproj", "{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Shaders", "DirectX12GameEngine.Shaders\DirectX12GameEngine.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}" EndProject diff --git a/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj index 0823373d..bb64e8b0 100644 --- a/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj +++ b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj @@ -6,7 +6,7 @@ - + diff --git a/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj b/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj index 9ef31fbd..1916128f 100644 --- a/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj +++ b/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj @@ -18,8 +18,7 @@ - - + From c178dd64e04f51a6360625a5a8dc930a3a5d6429 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:32:27 +0200 Subject: [PATCH 03/21] Adjusted namespaces in graphics project --- src/ComputeSharp.Graphics/BufferDescription.cs | 2 +- src/ComputeSharp.Graphics/BufferFlags.cs | 2 +- .../Buffers/Abstract/GraphicsResource.cs | 2 +- src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs | 2 +- src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs | 2 +- src/ComputeSharp.Graphics/Buffers/Buffer.cs | 6 +++--- src/ComputeSharp.Graphics/CommandAllocatorPool.cs | 2 +- src/ComputeSharp.Graphics/CommandList.cs | 4 ++-- src/ComputeSharp.Graphics/CompiledCommandList.cs | 2 +- src/ComputeSharp.Graphics/DescriptorAllocator.cs | 2 +- src/ComputeSharp.Graphics/GraphicsDevice.cs | 2 +- src/ComputeSharp.Graphics/GraphicsResourceUsage.cs | 2 +- src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs | 2 +- src/ComputeSharp.Graphics/PipelineState.cs | 2 +- src/DirectX12ComputeShaderSample/Gpu.cs | 6 +++--- src/DirectX12ComputeShaderSample/Program.cs | 4 ++-- src/DirectX12GameEngine.Shaders/ShaderLoader.cs | 2 +- src/DirectX12GameEngine.Shaders/ShaderResource.cs | 2 +- 18 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/ComputeSharp.Graphics/BufferDescription.cs b/src/ComputeSharp.Graphics/BufferDescription.cs index 89159df8..efc94f66 100644 --- a/src/ComputeSharp.Graphics/BufferDescription.cs +++ b/src/ComputeSharp.Graphics/BufferDescription.cs @@ -1,4 +1,4 @@ -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { public struct BufferDescription { diff --git a/src/ComputeSharp.Graphics/BufferFlags.cs b/src/ComputeSharp.Graphics/BufferFlags.cs index 1c0a26b5..ce2b64ed 100644 --- a/src/ComputeSharp.Graphics/BufferFlags.cs +++ b/src/ComputeSharp.Graphics/BufferFlags.cs @@ -1,6 +1,6 @@ using System; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { [Flags] public enum BufferFlags diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs index 1ffa6721..e8318b60 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs @@ -1,7 +1,7 @@ using System; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics.Buffers.Abstract +namespace ComputeSharp.Graphics.Buffers.Abstract { /// /// An abstract that represents a graphics resource object diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs index 7745734e..b1081bc6 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs @@ -1,6 +1,6 @@ using System; -namespace DirectX12GameEngine.Graphics.Buffers +namespace ComputeSharp.Graphics.Buffers { public partial class Buffer { diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs index 20ec576d..44d2aca3 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs @@ -1,6 +1,6 @@ using System; -namespace DirectX12GameEngine.Graphics.Buffers +namespace ComputeSharp.Graphics.Buffers { public partial class Buffer { diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs index 2a4a4e87..9b8c2728 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.cs @@ -1,10 +1,10 @@ using System; using System.Runtime.CompilerServices; -using DirectX12GameEngine.Graphics.Buffers.Abstract; -using DirectX12GameEngine.Graphics.Helpers; +using ComputeSharp.Graphics.Buffers.Abstract; +using ComputeSharp.Graphics.Helpers; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics.Buffers +namespace ComputeSharp.Graphics.Buffers { public partial class Buffer : GraphicsResource { diff --git a/src/ComputeSharp.Graphics/CommandAllocatorPool.cs b/src/ComputeSharp.Graphics/CommandAllocatorPool.cs index 1c130675..a14dccd0 100644 --- a/src/ComputeSharp.Graphics/CommandAllocatorPool.cs +++ b/src/ComputeSharp.Graphics/CommandAllocatorPool.cs @@ -2,7 +2,7 @@ using System.Collections.Generic; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { internal sealed class CommandAllocatorPool : IDisposable { diff --git a/src/ComputeSharp.Graphics/CommandList.cs b/src/ComputeSharp.Graphics/CommandList.cs index 341aa967..99702716 100644 --- a/src/ComputeSharp.Graphics/CommandList.cs +++ b/src/ComputeSharp.Graphics/CommandList.cs @@ -1,8 +1,8 @@ using System; -using DirectX12GameEngine.Graphics.Buffers.Abstract; +using ComputeSharp.Graphics.Buffers.Abstract; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { public sealed class CommandList : IDisposable { diff --git a/src/ComputeSharp.Graphics/CompiledCommandList.cs b/src/ComputeSharp.Graphics/CompiledCommandList.cs index a4bc4f07..57e2a7ff 100644 --- a/src/ComputeSharp.Graphics/CompiledCommandList.cs +++ b/src/ComputeSharp.Graphics/CompiledCommandList.cs @@ -1,6 +1,6 @@ using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { public sealed class CompiledCommandList { diff --git a/src/ComputeSharp.Graphics/DescriptorAllocator.cs b/src/ComputeSharp.Graphics/DescriptorAllocator.cs index ff795e41..5a041bf2 100644 --- a/src/ComputeSharp.Graphics/DescriptorAllocator.cs +++ b/src/ComputeSharp.Graphics/DescriptorAllocator.cs @@ -1,7 +1,7 @@ using System; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { internal sealed class DescriptorAllocator : IDisposable { diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs index 42be36df..893b4a2c 100644 --- a/src/ComputeSharp.Graphics/GraphicsDevice.cs +++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs @@ -3,7 +3,7 @@ using System.Threading; using SharpDX.Direct3D; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { public sealed class GraphicsDevice : IDisposable { diff --git a/src/ComputeSharp.Graphics/GraphicsResourceUsage.cs b/src/ComputeSharp.Graphics/GraphicsResourceUsage.cs index b4299070..64448684 100644 --- a/src/ComputeSharp.Graphics/GraphicsResourceUsage.cs +++ b/src/ComputeSharp.Graphics/GraphicsResourceUsage.cs @@ -1,4 +1,4 @@ -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { public enum GraphicsHeapType { diff --git a/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs b/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs index b7b01f42..6e3a516b 100644 --- a/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs +++ b/src/ComputeSharp.Graphics/Helpers/MemoryHelper.cs @@ -1,7 +1,7 @@ using System; using System.Runtime.CompilerServices; -namespace DirectX12GameEngine.Graphics.Helpers +namespace ComputeSharp.Graphics.Helpers { /// /// A with some helper methods to copy data between memory areas diff --git a/src/ComputeSharp.Graphics/PipelineState.cs b/src/ComputeSharp.Graphics/PipelineState.cs index c74c8967..c7dcdc5e 100644 --- a/src/ComputeSharp.Graphics/PipelineState.cs +++ b/src/ComputeSharp.Graphics/PipelineState.cs @@ -1,6 +1,6 @@ using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Graphics +namespace ComputeSharp.Graphics { /// /// A representing a custom pipeline state for a compute operation diff --git a/src/DirectX12ComputeShaderSample/Gpu.cs b/src/DirectX12ComputeShaderSample/Gpu.cs index 65f9f084..81a27c03 100644 --- a/src/DirectX12ComputeShaderSample/Gpu.cs +++ b/src/DirectX12ComputeShaderSample/Gpu.cs @@ -1,13 +1,13 @@ using System; using System.Linq; -using DirectX12GameEngine.Graphics; +using ComputeSharp.Graphics; using DirectX12GameEngine.Shaders; using DirectX12GameEngine.Shaders.Primitives; using DirectX12GameEngine.Shaders.Renderer; using DirectX12GameEngine.Shaders.Renderer.Models; using SharpDX.Direct3D12; -using CommandList = DirectX12GameEngine.Graphics.CommandList; -using PipelineState = DirectX12GameEngine.Graphics.PipelineState; +using CommandList = ComputeSharp.Graphics.CommandList; +using PipelineState = ComputeSharp.Graphics.PipelineState; using ShaderBytecode = SharpDX.Direct3D12.ShaderBytecode; namespace DirectX12ComputeShaderSample diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 48be6ecd..8f96bd63 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -1,9 +1,9 @@ using DirectX12GameEngine.Shaders; using System; using System.Linq; -using DirectX12GameEngine.Graphics.Buffers; +using ComputeSharp.Graphics.Buffers; using DirectX12GameEngine.Shaders.Primitives; -using Buffer = DirectX12GameEngine.Graphics.Buffers.Buffer; +using Buffer = ComputeSharp.Graphics.Buffers.Buffer; namespace DirectX12ComputeShaderSample { diff --git a/src/DirectX12GameEngine.Shaders/ShaderLoader.cs b/src/DirectX12GameEngine.Shaders/ShaderLoader.cs index 4f49fe48..2fac6a03 100644 --- a/src/DirectX12GameEngine.Shaders/ShaderLoader.cs +++ b/src/DirectX12GameEngine.Shaders/ShaderLoader.cs @@ -4,7 +4,7 @@ using System.Diagnostics.Contracts; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; -using DirectX12GameEngine.Graphics.Buffers.Abstract; +using ComputeSharp.Graphics.Buffers.Abstract; using DirectX12GameEngine.Shaders.Mappings; using DirectX12GameEngine.Shaders.Primitives; using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; diff --git a/src/DirectX12GameEngine.Shaders/ShaderResource.cs b/src/DirectX12GameEngine.Shaders/ShaderResource.cs index 2cf469ec..6d90e986 100644 --- a/src/DirectX12GameEngine.Shaders/ShaderResource.cs +++ b/src/DirectX12GameEngine.Shaders/ShaderResource.cs @@ -1,6 +1,6 @@ using System; using System.Numerics; -using DirectX12GameEngine.Graphics.Buffers; +using ComputeSharp.Graphics.Buffers; using Buffer = System.Buffer; namespace DirectX12GameEngine.Shaders From 031dd213b48e4a74915c56eabdb6fb0c1e51c524 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:35:38 +0200 Subject: [PATCH 04/21] Shaders project renamed --- .../Assets/ShaderTemplate.mustache | 0 .../ComputeSharp.Shaders.csproj} | 0 .../Mappings/HlslKnownMethods.cs | 0 .../Mappings/HlslKnownTypes.cs | 0 .../MethodDecompiler.cs | 0 .../Primitives/ThreadIds.cs | 0 .../Renderer/Models/Fields/Abstract/FieldInfoBase.cs | 0 .../Renderer/Models/Fields/ConstantBufferFieldInfo.cs | 0 .../Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs | 0 .../Renderer/Models/Fields/StaticScalarFieldInfo.cs | 0 .../Renderer/Models/ShaderInfo.cs | 0 .../Renderer/ShaderRenderer.cs | 0 .../ShaderCompiler.cs | 0 .../ShaderLoader.cs | 0 .../ShaderResource.cs | 0 .../ShaderSyntaxRewriter.cs | 0 .../SyntaxNodeExtensions.cs | 0 src/ComputeSharp.sln | 2 +- .../DirectX12ComputeShaderSample.csproj | 2 +- 19 files changed, 2 insertions(+), 2 deletions(-) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Assets/ShaderTemplate.mustache (100%) rename src/{DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj => ComputeSharp.Shaders/ComputeSharp.Shaders.csproj} (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Mappings/HlslKnownMethods.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Mappings/HlslKnownTypes.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/MethodDecompiler.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Primitives/ThreadIds.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/Models/Fields/Abstract/FieldInfoBase.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/Models/Fields/ConstantBufferFieldInfo.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/Models/Fields/StaticScalarFieldInfo.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/Models/ShaderInfo.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/Renderer/ShaderRenderer.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/ShaderCompiler.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/ShaderLoader.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/ShaderResource.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/ShaderSyntaxRewriter.cs (100%) rename src/{DirectX12GameEngine.Shaders => ComputeSharp.Shaders}/SyntaxNodeExtensions.cs (100%) diff --git a/src/DirectX12GameEngine.Shaders/Assets/ShaderTemplate.mustache b/src/ComputeSharp.Shaders/Assets/ShaderTemplate.mustache similarity index 100% rename from src/DirectX12GameEngine.Shaders/Assets/ShaderTemplate.mustache rename to src/ComputeSharp.Shaders/Assets/ShaderTemplate.mustache diff --git a/src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj similarity index 100% rename from src/DirectX12GameEngine.Shaders/DirectX12GameEngine.Shaders.csproj rename to src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj diff --git a/src/DirectX12GameEngine.Shaders/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Mappings/HlslKnownMethods.cs rename to src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs diff --git a/src/DirectX12GameEngine.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Mappings/HlslKnownTypes.cs rename to src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs diff --git a/src/DirectX12GameEngine.Shaders/MethodDecompiler.cs b/src/ComputeSharp.Shaders/MethodDecompiler.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/MethodDecompiler.cs rename to src/ComputeSharp.Shaders/MethodDecompiler.cs diff --git a/src/DirectX12GameEngine.Shaders/Primitives/ThreadIds.cs b/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Primitives/ThreadIds.cs rename to src/ComputeSharp.Shaders/Primitives/ThreadIds.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs rename to src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs rename to src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs rename to src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs rename to src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/Models/ShaderInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/Models/ShaderInfo.cs rename to src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs diff --git a/src/DirectX12GameEngine.Shaders/Renderer/ShaderRenderer.cs b/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/Renderer/ShaderRenderer.cs rename to src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs diff --git a/src/DirectX12GameEngine.Shaders/ShaderCompiler.cs b/src/ComputeSharp.Shaders/ShaderCompiler.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/ShaderCompiler.cs rename to src/ComputeSharp.Shaders/ShaderCompiler.cs diff --git a/src/DirectX12GameEngine.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/ShaderLoader.cs rename to src/ComputeSharp.Shaders/ShaderLoader.cs diff --git a/src/DirectX12GameEngine.Shaders/ShaderResource.cs b/src/ComputeSharp.Shaders/ShaderResource.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/ShaderResource.cs rename to src/ComputeSharp.Shaders/ShaderResource.cs diff --git a/src/DirectX12GameEngine.Shaders/ShaderSyntaxRewriter.cs b/src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/ShaderSyntaxRewriter.cs rename to src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs diff --git a/src/DirectX12GameEngine.Shaders/SyntaxNodeExtensions.cs b/src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs similarity index 100% rename from src/DirectX12GameEngine.Shaders/SyntaxNodeExtensions.cs rename to src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs diff --git a/src/ComputeSharp.sln b/src/ComputeSharp.sln index a5d6dea6..a8415a79 100644 --- a/src/ComputeSharp.sln +++ b/src/ComputeSharp.sln @@ -5,7 +5,7 @@ VisualStudioVersion = 16.0.29201.188 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Graphics", "ComputeSharp.Graphics\ComputeSharp.Graphics.csproj", "{2499CC74-BC9A-4B30-A3B6-05F9C7BF9B34}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectX12GameEngine.Shaders", "DirectX12GameEngine.Shaders\DirectX12GameEngine.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.Shaders", "ComputeSharp.Shaders\ComputeSharp.Shaders.csproj", "{23AE6EED-79CD-4ADD-9A85-0148BD957D19}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp", "ComputeSharp\ComputeSharp.csproj", "{314EB353-E7E3-4146-8111-685CC83EC1DE}" EndProject diff --git a/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj index bb64e8b0..a9e9535e 100644 --- a/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj +++ b/src/DirectX12ComputeShaderSample/DirectX12ComputeShaderSample.csproj @@ -7,7 +7,7 @@ - + From e381de2c7ce6882ac7354a5a7a2f8b031b140653 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:37:33 +0200 Subject: [PATCH 05/21] Adjusted namespaces in shaders project --- src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs | 2 +- src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs | 3 +-- src/ComputeSharp.Shaders/MethodDecompiler.cs | 2 +- src/ComputeSharp.Shaders/Primitives/ThreadIds.cs | 2 +- .../Renderer/Models/Fields/Abstract/FieldInfoBase.cs | 2 +- .../Renderer/Models/Fields/ConstantBufferFieldInfo.cs | 4 ++-- .../Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs | 4 ++-- .../Renderer/Models/Fields/StaticScalarFieldInfo.cs | 4 ++-- src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs | 4 ++-- src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs | 4 ++-- src/ComputeSharp.Shaders/ShaderCompiler.cs | 2 +- src/ComputeSharp.Shaders/ShaderLoader.cs | 9 ++++----- src/ComputeSharp.Shaders/ShaderResource.cs | 4 +--- src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs | 2 +- src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs | 4 ++-- src/DirectX12ComputeShaderSample/Gpu.cs | 8 ++++---- src/DirectX12ComputeShaderSample/Program.cs | 6 +++--- 17 files changed, 31 insertions(+), 35 deletions(-) diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs index 6e33493c..f7d7fe7d 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs @@ -3,7 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using Microsoft.CodeAnalysis; -namespace DirectX12GameEngine.Shaders.Mappings +namespace ComputeSharp.Shaders.Mappings { /// /// A that contains and maps known HLSL method names to common .NET method diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index c6038358..d1712543 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -3,9 +3,8 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Numerics; using System.Text.RegularExpressions; -using DirectX12GameEngine.Shaders.Primitives; -namespace DirectX12GameEngine.Shaders.Mappings +namespace ComputeSharp.Shaders.Mappings { /// /// A that contains and maps known HLSL type names to common .NET types diff --git a/src/ComputeSharp.Shaders/MethodDecompiler.cs b/src/ComputeSharp.Shaders/MethodDecompiler.cs index 031f2e21..0c09ad67 100644 --- a/src/ComputeSharp.Shaders/MethodDecompiler.cs +++ b/src/ComputeSharp.Shaders/MethodDecompiler.cs @@ -12,7 +12,7 @@ using ICSharpCode.Decompiler.Metadata; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { /// /// A that is able to decompile arbitrary methods diff --git a/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs b/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs index 08cf64b3..219f4ef9 100644 --- a/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs +++ b/src/ComputeSharp.Shaders/Primitives/ThreadIds.cs @@ -1,4 +1,4 @@ -namespace DirectX12GameEngine.Shaders.Primitives +namespace ComputeSharp { /// /// A that indicates the ids of a given GPU thread running a compute shader diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs index ead23005..ff7cc533 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/Abstract/FieldInfoBase.cs @@ -1,4 +1,4 @@ -namespace DirectX12GameEngine.Shaders.Renderer.Models.Abstract +namespace ComputeSharp.Shaders.Renderer.Models.Fields.Abstract { /// /// A that contains info on a shader field diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs index aa453dab..1f8c3160 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ConstantBufferFieldInfo.cs @@ -1,6 +1,6 @@ -using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; -namespace DirectX12GameEngine.Shaders.Renderer.Models.Fields +namespace ComputeSharp.Shaders.Renderer.Models.Fields { /// /// A that contains info on a constant buffer field diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs index abfb06c9..e7280bc2 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/ReadWriteBufferFieldInfo.cs @@ -1,6 +1,6 @@ -using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; -namespace DirectX12GameEngine.Shaders.Renderer.Models.Fields +namespace ComputeSharp.Shaders.Renderer.Models.Fields { /// /// A that contains info on a read write buffer field diff --git a/src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs index ff41f95e..ab6ca039 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/Fields/StaticScalarFieldInfo.cs @@ -1,6 +1,6 @@ -using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; -namespace DirectX12GameEngine.Shaders.Renderer.Models.Fields +namespace ComputeSharp.Shaders.Renderer.Models.Fields { /// /// A that contains info on a static scalar field diff --git a/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs b/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs index 64ba1e8d..598568ef 100644 --- a/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs +++ b/src/ComputeSharp.Shaders/Renderer/Models/ShaderInfo.cs @@ -1,9 +1,9 @@ using System.Collections.Generic; -using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; #pragma warning disable CS8618 // Non-nullable field is uninitialized -namespace DirectX12GameEngine.Shaders.Renderer.Models +namespace ComputeSharp.Shaders.Renderer.Models { /// /// A that contains info to render a shader source to compile diff --git a/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs b/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs index 5533346f..e5b40be2 100644 --- a/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs +++ b/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs @@ -2,9 +2,9 @@ using System.Diagnostics.Contracts; using System.IO; using System.Reflection; -using DirectX12GameEngine.Shaders.Renderer.Models; +using ComputeSharp.Shaders.Renderer.Models; -namespace DirectX12GameEngine.Shaders.Renderer +namespace ComputeSharp.Shaders.Renderer { /// /// A that uses the mustache templating system to render HLSL shaders diff --git a/src/ComputeSharp.Shaders/ShaderCompiler.cs b/src/ComputeSharp.Shaders/ShaderCompiler.cs index ea64c675..fc21b010 100644 --- a/src/ComputeSharp.Shaders/ShaderCompiler.cs +++ b/src/ComputeSharp.Shaders/ShaderCompiler.cs @@ -3,7 +3,7 @@ using System.Diagnostics.Contracts; using DotNetDxc; using SharpDX.Direct3D12; -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { /// /// A that uses the APIs to compile compute shaders diff --git a/src/ComputeSharp.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs index 2fac6a03..6688be7a 100644 --- a/src/ComputeSharp.Shaders/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/ShaderLoader.cs @@ -5,17 +5,16 @@ using System.Linq; using System.Reflection; using System.Text.RegularExpressions; using ComputeSharp.Graphics.Buffers.Abstract; -using DirectX12GameEngine.Shaders.Mappings; -using DirectX12GameEngine.Shaders.Primitives; -using DirectX12GameEngine.Shaders.Renderer.Models.Abstract; -using DirectX12GameEngine.Shaders.Renderer.Models.Fields; +using ComputeSharp.Shaders.Mappings; +using ComputeSharp.Shaders.Renderer.Models.Fields; +using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp.Syntax; using SharpDX.Direct3D12; #pragma warning disable CS8618 // Non-nullable field is uninitialized -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { /// /// A responsible for loading and processing instances diff --git a/src/ComputeSharp.Shaders/ShaderResource.cs b/src/ComputeSharp.Shaders/ShaderResource.cs index 6d90e986..5ca82346 100644 --- a/src/ComputeSharp.Shaders/ShaderResource.cs +++ b/src/ComputeSharp.Shaders/ShaderResource.cs @@ -1,9 +1,7 @@ using System; -using System.Numerics; using ComputeSharp.Graphics.Buffers; -using Buffer = System.Buffer; -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { public abstract class ShaderResource { diff --git a/src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs b/src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs index f2e9c018..65063848 100644 --- a/src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs +++ b/src/ComputeSharp.Shaders/ShaderSyntaxRewriter.cs @@ -4,7 +4,7 @@ using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { public class ShaderSyntaxRewriter : CSharpSyntaxRewriter { diff --git a/src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs b/src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs index b2e0f0fb..7660be33 100644 --- a/src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs +++ b/src/ComputeSharp.Shaders/SyntaxNodeExtensions.cs @@ -1,10 +1,10 @@ using System.Linq; -using DirectX12GameEngine.Shaders.Mappings; +using ComputeSharp.Shaders.Mappings; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; using Microsoft.CodeAnalysis.CSharp.Syntax; -namespace DirectX12GameEngine.Shaders +namespace ComputeSharp.Shaders { public static class SyntaxNodeExtensions { diff --git a/src/DirectX12ComputeShaderSample/Gpu.cs b/src/DirectX12ComputeShaderSample/Gpu.cs index 81a27c03..970ae4b7 100644 --- a/src/DirectX12ComputeShaderSample/Gpu.cs +++ b/src/DirectX12ComputeShaderSample/Gpu.cs @@ -1,10 +1,10 @@ using System; using System.Linq; +using ComputeSharp; using ComputeSharp.Graphics; -using DirectX12GameEngine.Shaders; -using DirectX12GameEngine.Shaders.Primitives; -using DirectX12GameEngine.Shaders.Renderer; -using DirectX12GameEngine.Shaders.Renderer.Models; +using ComputeSharp.Shaders; +using ComputeSharp.Shaders.Renderer; +using ComputeSharp.Shaders.Renderer.Models; using SharpDX.Direct3D12; using CommandList = ComputeSharp.Graphics.CommandList; using PipelineState = ComputeSharp.Graphics.PipelineState; diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 8f96bd63..3b280ca1 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -1,8 +1,8 @@ -using DirectX12GameEngine.Shaders; -using System; +using System; using System.Linq; +using ComputeSharp; using ComputeSharp.Graphics.Buffers; -using DirectX12GameEngine.Shaders.Primitives; +using ComputeSharp.Shaders; using Buffer = ComputeSharp.Graphics.Buffers.Buffer; namespace DirectX12ComputeShaderSample From e370068ff6e7118a1e373575bd0c9d06717e13d9 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:41:44 +0200 Subject: [PATCH 06/21] Fixed refactoring glitch --- src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs index f7d7fe7d..143e087e 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs @@ -30,9 +30,9 @@ namespace ComputeSharp.Shaders.Mappings ["System.MathF.PI"] = "3.14159274f", // ThreadIds - ["DirectX12GameEngine.Shaders.Primitives.ThreadIds.X"] = ".x", - ["DirectX12GameEngine.Shaders.Primitives.ThreadIds.Y"] = ".y", - ["DirectX12GameEngine.Shaders.Primitives.ThreadIds.Z"] = ".z", + ["ComputeSharp.ThreadIds.X"] = ".x", + ["ComputeSharp.ThreadIds.Y"] = ".y", + ["ComputeSharp.ThreadIds.Z"] = ".z", // Vector3 ["System.Numerics.Vector3.X"] = ".x", From 0896d368e44d524c8b5c5fc417f2e1c493da115b Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 02:43:03 +0200 Subject: [PATCH 07/21] Minor code refactoring --- src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj | 6 +----- src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs | 2 +- .../{Assets => Renderer/Templates}/ShaderTemplate.mustache | 0 3 files changed, 2 insertions(+), 6 deletions(-) rename src/ComputeSharp.Shaders/{Assets => Renderer/Templates}/ShaderTemplate.mustache (100%) diff --git a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj index 1916128f..086f0e66 100644 --- a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj +++ b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj @@ -35,11 +35,7 @@ - - - - - + PreserveNewest diff --git a/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs b/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs index e5b40be2..f9aeb680 100644 --- a/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs +++ b/src/ComputeSharp.Shaders/Renderer/ShaderRenderer.cs @@ -24,7 +24,7 @@ namespace ComputeSharp.Shaders.Renderer string assemblyPath = Assembly.GetExecutingAssembly().Location, assemblyDirectory = Path.GetDirectoryName(assemblyPath) ?? throw new InvalidOperationException("Can't find the assembly directory"), - templatePath = Path.Combine(assemblyDirectory, "Assets", "ShaderTemplate.mustache"); + templatePath = Path.Combine(assemblyDirectory, "Renderer", "Templates", "ShaderTemplate.mustache"); Template = File.ReadAllText(templatePath); } diff --git a/src/ComputeSharp.Shaders/Assets/ShaderTemplate.mustache b/src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache similarity index 100% rename from src/ComputeSharp.Shaders/Assets/ShaderTemplate.mustache rename to src/ComputeSharp.Shaders/Renderer/Templates/ShaderTemplate.mustache From bc593c655d0d8d2668d6c670853e7e2ddde007dc Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 11:13:00 +0200 Subject: [PATCH 08/21] Minor bug fixes --- .../Buffers/Abstract/GraphicsResource.cs | 4 ++-- src/ComputeSharp.Graphics/CommandList.cs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs index e8318b60..46f42eec 100644 --- a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs +++ b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs @@ -35,12 +35,12 @@ namespace ComputeSharp.Graphics.Buffers.Abstract /// /// Gets the instance for the current resource /// - protected internal CpuDescriptorHandle NativeCpuDescriptorHandle { get; protected set; } + protected internal CpuDescriptorHandle? NativeCpuDescriptorHandle { get; protected set; } /// /// Gets the instance for the current resource /// - protected internal GpuDescriptorHandle NativeGpuDescriptorHandle { get; protected set; } + protected internal GpuDescriptorHandle? NativeGpuDescriptorHandle { get; protected set; } /// /// Maps the current resource to a specified subresource diff --git a/src/ComputeSharp.Graphics/CommandList.cs b/src/ComputeSharp.Graphics/CommandList.cs index 99702716..355f1981 100644 --- a/src/ComputeSharp.Graphics/CommandList.cs +++ b/src/ComputeSharp.Graphics/CommandList.cs @@ -110,7 +110,8 @@ namespace ComputeSharp.Graphics public void SetGraphicsRootDescriptorTable(int rootParameterIndex, GraphicsResource resource) { - SetGraphicsRootDescriptorTable(rootParameterIndex, resource.NativeGpuDescriptorHandle); + if (resource.NativeGpuDescriptorHandle == null) throw new InvalidOperationException("Invalid graphics resource GPU descriptor"); + SetGraphicsRootDescriptorTable(rootParameterIndex, resource.NativeGpuDescriptorHandle.Value); } public void SetGraphicsRootDescriptorTable(int rootParameterIndex, GpuDescriptorHandle baseDescriptor) @@ -130,7 +131,8 @@ namespace ComputeSharp.Graphics public void SetComputeRootDescriptorTable(int rootParameterIndex, GraphicsResource resource) { - SetComputeRootDescriptorTable(rootParameterIndex, resource.NativeGpuDescriptorHandle); + if (resource.NativeGpuDescriptorHandle == null) throw new InvalidOperationException("Invalid graphics resource GPU descriptor"); + SetComputeRootDescriptorTable(rootParameterIndex, resource.NativeGpuDescriptorHandle.Value); } public void SetComputeRootDescriptorTable(int rootParameterIndex, GpuDescriptorHandle baseDescriptor) From b7e05ec85bad13df76a218d8e87499f77464bef8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 11:47:26 +0200 Subject: [PATCH 09/21] Added initial Buffer2 implementation --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 109 +++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 src/ComputeSharp.Graphics/Buffers/Buffer2.cs diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs new file mode 100644 index 00000000..df75a923 --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -0,0 +1,109 @@ +using System.Diagnostics.Contracts; +using System.Runtime.CompilerServices; +using ComputeSharp.Graphics.Buffers.Abstract; +using SharpDX.Direct3D12; + +namespace ComputeSharp.Graphics.Buffers +{ + /// + /// A representing a typed buffer stored on GPU memory + /// + /// The type of items stored on the buffer + public sealed class Buffer2 : GraphicsResource where T : unmanaged + { + /// + /// Creates a new instance with the specified parameters + /// + /// The associated with the current instance + /// The number of items to store in the current buffer + /// The heap type for the current buffer + public Buffer2(GraphicsDevice device, int size, HeapType heapType) : base(device) + { + Size = size; + ElementSizeInBytes = Unsafe.SizeOf(); + SizeInBytes = Size * ElementSizeInBytes; + HeapType = heapType; + + ResourceFlags flags = heapType == HeapType.Default ? ResourceFlags.AllowUnorderedAccess : ResourceFlags.None; + ResourceDescription description = ResourceDescription.Buffer(ElementSizeInBytes, flags); + ResourceStates resourceStates = heapType switch + { + HeapType.Upload => ResourceStates.GenericRead, + HeapType.Readback => ResourceStates.CopyDestination, + _ => ResourceStates.CopyDestination + }; + + NativeResource = GraphicsDevice.NativeDevice.CreateCommittedResource(new HeapProperties(heapType), HeapFlags.None, description, resourceStates); + + (NativeCpuDescriptorHandle, NativeGpuDescriptorHandle) = heapType switch + { + HeapType.Default => CreateUnorderedAccessView(), + HeapType.Upload => CreateConstantBufferView(), + _ => default + }; + } + + /// + /// Creates the descriptors for a constant buffer + /// + /// The CPU and GPU handles for a constant buffer + [Pure] + private (CpuDescriptorHandle, GpuDescriptorHandle) CreateConstantBufferView() + { + (CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle) = GraphicsDevice.ShaderResourceViewAllocator.Allocate(1); + + int constantBufferSize = (SizeInBytes + 255) & ~255; + + ConstantBufferViewDescription description = new ConstantBufferViewDescription + { + BufferLocation = NativeResource!.GPUVirtualAddress, + SizeInBytes = constantBufferSize + }; + + GraphicsDevice.NativeDevice.CreateConstantBufferView(description, cpuHandle); + + return (cpuHandle, gpuHandle); + } + + /// + /// Creates the descriptors for a read write buffer + /// + /// The CPU and GPU handles for a read write buffer + [Pure] + private (CpuDescriptorHandle, GpuDescriptorHandle) CreateUnorderedAccessView() + { + (CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle) = GraphicsDevice.ShaderResourceViewAllocator.Allocate(1); + + UnorderedAccessViewDescription description = new UnorderedAccessViewDescription + { + Format = SharpDX.DXGI.Format.R32_Float, + Dimension = UnorderedAccessViewDimension.Buffer, + Buffer = { ElementCount = Size } + }; + + GraphicsDevice.NativeDevice.CreateUnorderedAccessView(NativeResource, null, description, cpuHandle); + + return (cpuHandle, gpuHandle); + } + + /// + /// Gets the size of the current buffer, as in the number of values it contains + /// + public int Size { get; } + + /// + /// Gets the size in bytes of the current buffer + /// + public int SizeInBytes { get; } + + /// + /// Gets the size in bytes of each value contained in the buffer + /// + public int ElementSizeInBytes { get; } + + /// + /// Gets the heap type being targeted by the current buffer + /// + public HeapType HeapType { get; } + } +} From 0a389d81ecaca9b449fa79c1b9947502e46e6bd2 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 11:57:41 +0200 Subject: [PATCH 10/21] Added APIs to read and write data to Buffer2 --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 54 +++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index df75a923..740de6b8 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -1,6 +1,8 @@ -using System.Diagnostics.Contracts; +using System; +using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; using ComputeSharp.Graphics.Buffers.Abstract; +using ComputeSharp.Graphics.Helpers; using SharpDX.Direct3D12; namespace ComputeSharp.Graphics.Buffers @@ -105,5 +107,55 @@ namespace ComputeSharp.Graphics.Buffers /// Gets the heap type being targeted by the current buffer /// public HeapType HeapType { get; } + + /// + /// Reads the contents of the current instance and writes them into a target + /// + /// The input to write data to + public void GetData(Span span) + { + // Create a temporary readback buffer if the current buffer type is read write (can't be read from directly) + if (HeapType == HeapType.Default) + { + using Buffer2 readbackBaffer = new Buffer2(GraphicsDevice, Size, HeapType.Readback); + using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); + + copyCommandList.CopyBufferRegion(this, 0, readbackBaffer, 0, SizeInBytes); + copyCommandList.Flush(true); + + readbackBaffer.GetData(span); + } + else + { + // Map and read the memory back directly + Map(0); + MemoryHelper.Copy(MappedResource, span); + Unmap(0); + } + } + + /// + /// Writes the contents of a given to the current instance + /// + /// The input to read data from + public void SetData(Span span) + { + // Create a temporary upload buffer if the current buffer type is read write (can't be written to directly) + if (HeapType == HeapType.Default) + { + using Buffer2 uploadBuffer = new Buffer2(GraphicsDevice, Size, HeapType.Upload); + using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); + + copyCommandList.CopyBufferRegion(uploadBuffer, 0, this, 0, SizeInBytes); + copyCommandList.Flush(true); + } + else + { + // Map and copy the memory directly + Map(0); + MemoryHelper.Copy(span, MappedResource); + Unmap(0); + } + } } } From bde2f35fe6079c0eee8c1d94cfb162fb4f4335c6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 12:01:29 +0200 Subject: [PATCH 11/21] Added Bufffer2 indexer --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index 740de6b8..bf4b2d5b 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -108,6 +108,17 @@ namespace ComputeSharp.Graphics.Buffers /// public HeapType HeapType { get; } + /// + /// Gets or sets a single value from the current buffer + /// + /// The index of the value to get or set + /// This API can only be used from a compute shader, and will always throw if used anywhere else + public T this[int i] + { + get => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); + set => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); + } + /// /// Reads the contents of the current instance and writes them into a target /// From 79c4df4a096c9584d36f4d5279c49934d4549383 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 12:04:16 +0200 Subject: [PATCH 12/21] Added Buffer2.GetData() overload --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index bf4b2d5b..26f4d91d 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -119,6 +119,19 @@ namespace ComputeSharp.Graphics.Buffers set => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); } + /// + /// Reads the contents of the current instance and returns an array + /// + /// A array with the contents of the current buffer + [Pure] + public T[] GetData() + { + T[] data = new T[Size]; + GetData(data); + + return data; + } + /// /// Reads the contents of the current instance and writes them into a target /// From 207a26006a223a093f57fed7e653e550094492f0 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 12:48:42 +0200 Subject: [PATCH 13/21] Added BufferExtensions class --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 2 +- .../Buffers/BufferExtensions.cs | 61 +++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index 26f4d91d..24d8873d 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -19,7 +19,7 @@ namespace ComputeSharp.Graphics.Buffers /// The associated with the current instance /// The number of items to store in the current buffer /// The heap type for the current buffer - public Buffer2(GraphicsDevice device, int size, HeapType heapType) : base(device) + internal Buffer2(GraphicsDevice device, int size, HeapType heapType) : base(device) { Size = size; ElementSizeInBytes = Unsafe.SizeOf(); diff --git a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs new file mode 100644 index 00000000..318698bb --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs @@ -0,0 +1,61 @@ +using System; +using System.Diagnostics.Contracts; +using System.Runtime.CompilerServices; +using SharpDX.Direct3D12; + +namespace ComputeSharp.Graphics.Buffers +{ + /// + /// A with extension methods for the type to allocate buffers + /// + public static class BufferExtensions + { + /// + /// Allocates a new read write buffer with the specified parameters + /// + /// The type of items to store in the buffer + /// The instance to use to allocate the buffer + /// The size of the buffer to allocate + /// A zeroed read write instance of size + [Pure] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged + { + return new Buffer2(device, size, HeapType.Default); + } + + /// + /// Allocates a new read write buffer with the specified parameters + /// + /// The type of items to store in the buffer + /// The instance to use to allocate the buffer + /// The input with the data to copy on the allocated buffer + /// A read write instance with the contents of the input + [Pure] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged + { + Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Default); + buffer.SetData(span); + + return buffer; + } + + /// + /// Allocates a new constant buffer with the specified parameters + /// + /// The type of items to store in the buffer + /// The instance to use to allocate the buffer + /// The input with the data to copy on the allocated buffer + /// A constant instance with the contents of the input + [Pure] + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static Buffer2 AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged + { + Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Upload); + buffer.SetData(span); + + return buffer; + } + } +} From c12dffdba0ab479539b1c502e5d398a217c82550 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 12:56:41 +0200 Subject: [PATCH 14/21] Fixed Buffer2 indexer argument type to conform to HLSL --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index 24d8873d..1abed2c6 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -113,7 +113,7 @@ namespace ComputeSharp.Graphics.Buffers /// /// The index of the value to get or set /// This API can only be used from a compute shader, and will always throw if used anywhere else - public T this[int i] + public T this[uint i] { get => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); set => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); From 0ce0c94611b53f986e10aa47232396f79db41391 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:15:39 +0200 Subject: [PATCH 15/21] Bug fixes in the Buffer2 type --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index 1abed2c6..919a7c6e 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -27,12 +27,12 @@ namespace ComputeSharp.Graphics.Buffers HeapType = heapType; ResourceFlags flags = heapType == HeapType.Default ? ResourceFlags.AllowUnorderedAccess : ResourceFlags.None; - ResourceDescription description = ResourceDescription.Buffer(ElementSizeInBytes, flags); + ResourceDescription description = ResourceDescription.Buffer(SizeInBytes, flags); ResourceStates resourceStates = heapType switch { HeapType.Upload => ResourceStates.GenericRead, HeapType.Readback => ResourceStates.CopyDestination, - _ => ResourceStates.CopyDestination + _ => ResourceStates.Common }; NativeResource = GraphicsDevice.NativeDevice.CreateCommittedResource(new HeapProperties(heapType), HeapFlags.None, description, resourceStates); From 9e253144b44ddaf98da2c3fc95cd3ff67d08418c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:26:48 +0200 Subject: [PATCH 16/21] Fixed bug in SetData API for the Buffer2 type --- src/ComputeSharp.Graphics/Buffers/Buffer2.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs index 919a7c6e..1a17cf3a 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer2.cs @@ -170,6 +170,7 @@ namespace ComputeSharp.Graphics.Buffers using Buffer2 uploadBuffer = new Buffer2(GraphicsDevice, Size, HeapType.Upload); using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); + uploadBuffer.SetData(span); copyCommandList.CopyBufferRegion(uploadBuffer, 0, this, 0, SizeInBytes); copyCommandList.Flush(true); } From 08ed370fd83f91f58b9621bcd80df8196be00d0c Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:32:30 +0200 Subject: [PATCH 17/21] Implemented handling of captured buffers in shaders --- .../Mappings/HlslKnownTypes.cs | 11 ++++---- src/ComputeSharp.Shaders/ShaderLoader.cs | 8 +++--- src/ComputeSharp.Shaders/ShaderResource.cs | 26 ------------------- src/DirectX12ComputeShaderSample/Program.cs | 8 ++---- 4 files changed, 12 insertions(+), 41 deletions(-) delete mode 100644 src/ComputeSharp.Shaders/ShaderResource.cs diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index d1712543..17eeb5ba 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics.Contracts; using System.Numerics; using System.Text.RegularExpressions; +using ComputeSharp.Graphics.Buffers; namespace ComputeSharp.Shaders.Mappings { @@ -26,7 +27,7 @@ namespace ComputeSharp.Shaders.Mappings [typeof(Vector4).FullName] = "float4", [typeof(Matrix4x4).FullName] = "float4x4", [typeof(ThreadIds).FullName] = "uint3", - [typeof(RWBufferResource<>).FullName] = "RWBuffer" + [typeof(Buffer2<>).FullName] = "RWBuffer" }; /// @@ -53,13 +54,13 @@ namespace ComputeSharp.Shaders.Mappings type == typeof(Matrix4x4); /// - /// Checks whether or not the input type is a value + /// Checks whether or not the input type is a value /// /// The input instance to check - /// A indicating whether the input is in fact a instance + /// A indicating whether the input is in fact a instance [Pure] - public static bool IsReadWriteBufferType(Type type) => type.IsGenericType && - type.GetGenericTypeDefinition() == typeof(RWBufferResource<>); + public static bool IsBufferType(Type type) => type.IsGenericType && + type.GetGenericTypeDefinition() == typeof(Buffer2<>); /// /// Checks whether or not a given is an HLSL known type diff --git a/src/ComputeSharp.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs index 6688be7a..05d6d235 100644 --- a/src/ComputeSharp.Shaders/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/ShaderLoader.cs @@ -4,6 +4,7 @@ using System.Diagnostics.Contracts; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; +using ComputeSharp.Graphics.Buffers; using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Renderer.Models.Fields; @@ -115,16 +116,15 @@ namespace ComputeSharp.Shaders FieldInfoBase processedFieldInfo; // Read write buffer - if (HlslKnownTypes.IsReadWriteBufferType(fieldType)) + if (HlslKnownTypes.IsBufferType(fieldType) && + (HeapType)fieldType.GetProperty(nameof(Buffer2.HeapType)).GetValue(fieldValue) == HeapType.Default) { // Root parameter for a read write buffer DescriptorRange range = new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, readWriteBuffersCount); descriptorRanges.Add(range); // Reference to the underlying buffer - object readWriteBuffer = fieldInfo.GetValue(ShaderInstance); - GraphicsResource resource = (GraphicsResource)fieldType.GetProperty(nameof(RWBufferResource.Buffer)).GetValue(readWriteBuffer); - readWriteBuffers.Add(resource); + readWriteBuffers.Add((GraphicsResource)fieldValue); string typeName = HlslKnownTypes.GetMappedName(fieldType); processedFieldInfo = new ReadWriteBufferFieldInfo(typeName, fieldName, readWriteBuffersCount++); diff --git a/src/ComputeSharp.Shaders/ShaderResource.cs b/src/ComputeSharp.Shaders/ShaderResource.cs deleted file mode 100644 index 5ca82346..00000000 --- a/src/ComputeSharp.Shaders/ShaderResource.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using ComputeSharp.Graphics.Buffers; - -namespace ComputeSharp.Shaders -{ - public abstract class ShaderResource - { - } - - public sealed class RWBufferResource : ShaderResource where T : unmanaged - { - internal RWBufferResource(Buffer buffer) => Buffer = buffer; - - public Buffer Buffer { get; } - - public T this[uint index] { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } - } - - public static class RWBufferResourceExtensions - { - public static RWBufferResource GetGpuResource(this Buffer buffer) where T : unmanaged - { - return new RWBufferResource(buffer); - } - } -} diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 3b280ca1..9bee1a7d 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -20,16 +20,12 @@ namespace DirectX12ComputeShaderSample array[i] = i + 1; } - using Buffer gpuBuffer = Buffer.UnorderedAccess.New(Gpu.Default, array.AsSpan()); - - // Variables for closure - uint size = (uint)width; - var data = gpuBuffer.GetGpuResource(); + using Buffer2 gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); // Shader body Action action = id => { - data[id.X + id.Y * size] *= 2; + gpuBuffer[id.X + id.Y * (uint)width] *= 2; }; // Run the shader From d75e84c61881db0fb2be3637c70c78a596ca60ae Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:34:58 +0200 Subject: [PATCH 18/21] Removed unnecessary types --- .../BufferDescription.cs | 18 -- src/ComputeSharp.Graphics/BufferFlags.cs | 19 -- .../Buffers/Buffer.Constant.cs | 25 -- .../Buffers/Buffer.UnorderedAccess.cs | 25 -- src/ComputeSharp.Graphics/Buffers/Buffer.cs | 232 ------------------ src/DirectX12ComputeShaderSample/Program.cs | 2 - 6 files changed, 321 deletions(-) delete mode 100644 src/ComputeSharp.Graphics/BufferDescription.cs delete mode 100644 src/ComputeSharp.Graphics/BufferFlags.cs delete mode 100644 src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs delete mode 100644 src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs delete mode 100644 src/ComputeSharp.Graphics/Buffers/Buffer.cs diff --git a/src/ComputeSharp.Graphics/BufferDescription.cs b/src/ComputeSharp.Graphics/BufferDescription.cs deleted file mode 100644 index efc94f66..00000000 --- a/src/ComputeSharp.Graphics/BufferDescription.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace ComputeSharp.Graphics -{ - public struct BufferDescription - { - public BufferDescription(int sizeInBytes, BufferFlags bufferFlags, GraphicsHeapType heapType) - { - SizeInBytes = sizeInBytes; - Flags = bufferFlags; - HeapType = heapType; - } - - public int SizeInBytes; - - public BufferFlags Flags; - - public GraphicsHeapType HeapType; - } -} diff --git a/src/ComputeSharp.Graphics/BufferFlags.cs b/src/ComputeSharp.Graphics/BufferFlags.cs deleted file mode 100644 index ce2b64ed..00000000 --- a/src/ComputeSharp.Graphics/BufferFlags.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; - -namespace ComputeSharp.Graphics -{ - [Flags] - public enum BufferFlags - { - None = 0, - ConstantBuffer = 1, - IndexBuffer = 2, - VertexBuffer = 4, - RenderTarget = 8, - ShaderResource = 16, - UnorderedAccess = 32, - StructuredBuffer = 64, - RawBuffer = 512, - ArgumentBuffer = 1024 - } -} diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs deleted file mode 100644 index b1081bc6..00000000 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.Constant.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace ComputeSharp.Graphics.Buffers -{ - public partial class Buffer - { - public static class Constant - { - public static unsafe Buffer New(GraphicsDevice device, int size, GraphicsHeapType heapType = GraphicsHeapType.Upload) - { - return Buffer.New(device, size, BufferFlags.ConstantBuffer, heapType); - } - - public static unsafe Buffer New(GraphicsDevice device, in T data, GraphicsHeapType heapType = GraphicsHeapType.Upload) where T : unmanaged - { - return Buffer.New(device, data, BufferFlags.ConstantBuffer, heapType); - } - - public static unsafe Buffer New(GraphicsDevice device, Span data, GraphicsHeapType heapType = GraphicsHeapType.Upload) where T : unmanaged - { - return Buffer.New(device, data, BufferFlags.ConstantBuffer, heapType); - } - } - } -} diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs deleted file mode 100644 index 44d2aca3..00000000 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.UnorderedAccess.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; - -namespace ComputeSharp.Graphics.Buffers -{ - public partial class Buffer - { - public static class UnorderedAccess - { - public static unsafe Buffers.Buffer New(GraphicsDevice device, int size, GraphicsHeapType heapType = GraphicsHeapType.Default) - { - return Buffers.Buffer.New(device, size, BufferFlags.UnorderedAccess, heapType); - } - - public static unsafe Buffer New(GraphicsDevice device, in T data, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged - { - return Buffers.Buffer.New(device, data, BufferFlags.UnorderedAccess, heapType); - } - - public static unsafe Buffer New(GraphicsDevice device, Span data, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged - { - return Buffers.Buffer.New(device, data, BufferFlags.UnorderedAccess, heapType); - } - } - } -} \ No newline at end of file diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs deleted file mode 100644 index 9b8c2728..00000000 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.cs +++ /dev/null @@ -1,232 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using ComputeSharp.Graphics.Buffers.Abstract; -using ComputeSharp.Graphics.Helpers; -using SharpDX.Direct3D12; - -namespace ComputeSharp.Graphics.Buffers -{ - public partial class Buffer : GraphicsResource - { - protected Buffer(GraphicsDevice device) : base(device) - { - } - - public BufferDescription Description { get; private set; } - - public int SizeInBytes => Description.SizeInBytes; - - public BufferFlags Flags => Description.Flags; - - public GraphicsHeapType Usage => Description.HeapType; - - public int ElementCount { get; protected set; } - - public T[] GetData() where T : unmanaged - { - T[] data = new T[SizeInBytes / Unsafe.SizeOf()]; - GetData(data.AsSpan()); - - return data; - } - - public unsafe void GetData(ref T data, int offsetInBytes = 0) where T : unmanaged - { - fixed (T* pointer = &data) - { - GetData(new Span(pointer, 1), offsetInBytes); - } - } - - public void GetData(Span data, int offsetInBytes = 0) where T : unmanaged - { - if (Usage == GraphicsHeapType.Default) - { - using Buffer readbackBaffer = New(GraphicsDevice, data.Length, BufferFlags.None, GraphicsHeapType.Readback); - using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); - - copyCommandList.CopyBufferRegion(this, offsetInBytes, readbackBaffer, 0, data.Length * Unsafe.SizeOf()); - copyCommandList.Flush(true); - - readbackBaffer.GetData(data); - } - else - { - Map(0); - MemoryHelper.Copy(MappedResource + offsetInBytes, data); - Unmap(0); - } - } - - public unsafe void SetData(in T data, int offsetInBytes = 0) where T : unmanaged - { - fixed (T* pointer = &data) - { - SetData(new Span(pointer, 1), offsetInBytes); - } - } - - public void SetData(Span data, int offsetInBytes = 0) where T : unmanaged - { - if (Usage == GraphicsHeapType.Default) - { - using Buffer uploadBuffer = New(GraphicsDevice, data, BufferFlags.None, GraphicsHeapType.Upload); - using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); - - copyCommandList.CopyBufferRegion(uploadBuffer, 0, this, offsetInBytes, data.Length * Unsafe.SizeOf()); - copyCommandList.Flush(true); - } - else - { - Map(0); - MemoryHelper.Copy(data, MappedResource + offsetInBytes); - Unmap(0); - } - } - - public Buffers.Buffer ToReadback() - { - BufferDescription description = Description; - description.HeapType = GraphicsHeapType.Readback; - description.Flags = BufferFlags.None; - - return New(GraphicsDevice, description); - } - - public static Buffers.Buffer New(GraphicsDevice device, BufferDescription description) - { - return new Buffers.Buffer(device).InitializeFrom(description); - } - - public static Buffers.Buffer New(GraphicsDevice device, int size, BufferFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) - { - return New(device, new BufferDescription(size, bufferFlags, heapType)); - } - - public static Buffer New(GraphicsDevice device, int elementCount, BufferFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged - { - int bufferSize = elementCount * Unsafe.SizeOf(); - - return new Buffer(device, bufferSize, bufferFlags, heapType); - } - - public static unsafe Buffer New(GraphicsDevice device, in T data, BufferFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged - { - fixed (T* pointer = &data) - { - return New(device, new Span(pointer, 1), bufferFlags, heapType); - } - } - - public static Buffer New(GraphicsDevice device, Span data, BufferFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) where T : unmanaged - { - Buffer buffer = New(device, data.Length, bufferFlags, heapType); - buffer.SetData(data); - - return buffer; - } - - protected internal Buffers.Buffer InitializeFrom(BufferDescription description) - { - ResourceStates resourceStates = ResourceStates.Common; - - if (description.HeapType == GraphicsHeapType.Upload) - { - resourceStates = ResourceStates.GenericRead; - } - else if (description.HeapType == GraphicsHeapType.Readback) - { - resourceStates = ResourceStates.CopyDestination; - } - - NativeResource ??= GraphicsDevice.NativeDevice.CreateCommittedResource( - new HeapProperties((HeapType)description.HeapType), HeapFlags.None, - ConvertToNativeDescription(description), resourceStates); - - Description = description; - - (NativeCpuDescriptorHandle, NativeGpuDescriptorHandle) = description.Flags switch - { - BufferFlags.ConstantBuffer => CreateConstantBufferView(), - BufferFlags.ShaderResource => CreateShaderResourceView(), - BufferFlags.UnorderedAccess => CreateUnorderedAccessView(), - _ => default - }; - - return this; - } - - private static ResourceDescription ConvertToNativeDescription(BufferDescription description) - { - int size = description.SizeInBytes; - ResourceFlags flags = ResourceFlags.None; - - if (description.Flags.HasFlag(BufferFlags.UnorderedAccess)) - { - flags |= ResourceFlags.AllowUnorderedAccess; - //flags |= ResourceFlags.AllowSimultaneousAccess; - } - - return ResourceDescription.Buffer(size, flags); - } - - private (CpuDescriptorHandle, GpuDescriptorHandle) CreateConstantBufferView() - { - (CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle) = GraphicsDevice.ShaderResourceViewAllocator.Allocate(1); - - int constantBufferSize = (SizeInBytes + 255) & ~255; - - ConstantBufferViewDescription cbvDescription = new ConstantBufferViewDescription - { - BufferLocation = NativeResource.GPUVirtualAddress, - SizeInBytes = constantBufferSize - }; - - GraphicsDevice.NativeDevice.CreateConstantBufferView(cbvDescription, cpuHandle); - - return (cpuHandle, gpuHandle); - } - - private (CpuDescriptorHandle, GpuDescriptorHandle) CreateShaderResourceView() - { - (CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle) = GraphicsDevice.ShaderResourceViewAllocator.Allocate(1); - GraphicsDevice.NativeDevice.CreateShaderResourceView(NativeResource, null, cpuHandle); - - return (cpuHandle, gpuHandle); - } - - private (CpuDescriptorHandle, GpuDescriptorHandle) CreateUnorderedAccessView() - { - (CpuDescriptorHandle cpuHandle, GpuDescriptorHandle gpuHandle) = GraphicsDevice.ShaderResourceViewAllocator.Allocate(1); - - var description = new UnorderedAccessViewDescription - { - Format = SharpDX.DXGI.Format.R32_Float, - Dimension = UnorderedAccessViewDimension.Buffer, - Buffer = - { - ElementCount = ElementCount, - } - }; - - GraphicsDevice.NativeDevice.CreateUnorderedAccessView(NativeResource, null, description, cpuHandle); - - return (cpuHandle, gpuHandle); - } - } - - public class Buffer : Buffers.Buffer where T : unmanaged - { - protected internal Buffer(GraphicsDevice device, int size, BufferFlags bufferFlags, GraphicsHeapType heapType = GraphicsHeapType.Default) : base(device) - { - ElementSize = Unsafe.SizeOf(); - ElementCount = size / ElementSize; - - InitializeFrom(new BufferDescription(size, bufferFlags, heapType)); - } - - public int ElementSize { get; } - - public T[] GetData() => GetData(); - } -} diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 9bee1a7d..347d721b 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -2,8 +2,6 @@ using System.Linq; using ComputeSharp; using ComputeSharp.Graphics.Buffers; -using ComputeSharp.Shaders; -using Buffer = ComputeSharp.Graphics.Buffers.Buffer; namespace DirectX12ComputeShaderSample { From acf2aa9fce1c1ed0fe6f36cd0c801fe63b6f8729 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:37:58 +0200 Subject: [PATCH 19/21] Renamed Buffer2 type --- .../Buffers/{Buffer2.cs => Buffer.cs} | 16 ++++++++-------- .../Buffers/BufferExtensions.cs | 18 +++++++++--------- .../Mappings/HlslKnownTypes.cs | 8 ++++---- src/ComputeSharp.Shaders/ShaderLoader.cs | 2 +- src/DirectX12ComputeShaderSample/Program.cs | 2 +- 5 files changed, 23 insertions(+), 23 deletions(-) rename src/ComputeSharp.Graphics/Buffers/{Buffer2.cs => Buffer.cs} (90%) diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs similarity index 90% rename from src/ComputeSharp.Graphics/Buffers/Buffer2.cs rename to src/ComputeSharp.Graphics/Buffers/Buffer.cs index 1a17cf3a..1cbc6ad9 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer2.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.cs @@ -11,15 +11,15 @@ namespace ComputeSharp.Graphics.Buffers /// A representing a typed buffer stored on GPU memory /// /// The type of items stored on the buffer - public sealed class Buffer2 : GraphicsResource where T : unmanaged + public sealed class Buffer : GraphicsResource where T : unmanaged { /// - /// Creates a new instance with the specified parameters + /// Creates a new instance with the specified parameters /// /// The associated with the current instance /// The number of items to store in the current buffer /// The heap type for the current buffer - internal Buffer2(GraphicsDevice device, int size, HeapType heapType) : base(device) + internal Buffer(GraphicsDevice device, int size, HeapType heapType) : base(device) { Size = size; ElementSizeInBytes = Unsafe.SizeOf(); @@ -120,7 +120,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Reads the contents of the current instance and returns an array + /// Reads the contents of the current instance and returns an array /// /// A array with the contents of the current buffer [Pure] @@ -133,7 +133,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Reads the contents of the current instance and writes them into a target + /// Reads the contents of the current instance and writes them into a target /// /// The input to write data to public void GetData(Span span) @@ -141,7 +141,7 @@ namespace ComputeSharp.Graphics.Buffers // Create a temporary readback buffer if the current buffer type is read write (can't be read from directly) if (HeapType == HeapType.Default) { - using Buffer2 readbackBaffer = new Buffer2(GraphicsDevice, Size, HeapType.Readback); + using Buffer readbackBaffer = new Buffer(GraphicsDevice, Size, HeapType.Readback); using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); copyCommandList.CopyBufferRegion(this, 0, readbackBaffer, 0, SizeInBytes); @@ -159,7 +159,7 @@ namespace ComputeSharp.Graphics.Buffers } /// - /// Writes the contents of a given to the current instance + /// Writes the contents of a given to the current instance /// /// The input to read data from public void SetData(Span span) @@ -167,7 +167,7 @@ namespace ComputeSharp.Graphics.Buffers // Create a temporary upload buffer if the current buffer type is read write (can't be written to directly) if (HeapType == HeapType.Default) { - using Buffer2 uploadBuffer = new Buffer2(GraphicsDevice, Size, HeapType.Upload); + using Buffer uploadBuffer = new Buffer(GraphicsDevice, Size, HeapType.Upload); using CommandList copyCommandList = new CommandList(GraphicsDevice, CommandListType.Copy); uploadBuffer.SetData(span); diff --git a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs index 318698bb..e424961e 100644 --- a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs @@ -16,12 +16,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The size of the buffer to allocate - /// A zeroed read write instance of size + /// A zeroed read write instance of size [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged + public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged { - return new Buffer2(device, size, HeapType.Default); + return new Buffer(device, size, HeapType.Default); } /// @@ -30,12 +30,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A read write instance with the contents of the input + /// A read write instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Default); + Buffer buffer = new Buffer(device, span.Length, HeapType.Default); buffer.SetData(span); return buffer; @@ -47,12 +47,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A constant instance with the contents of the input + /// A constant instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer2 AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static Buffer AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer2 buffer = new Buffer2(device, span.Length, HeapType.Upload); + Buffer buffer = new Buffer(device, span.Length, HeapType.Upload); buffer.SetData(span); return buffer; diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index 17eeb5ba..e1847415 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -27,7 +27,7 @@ namespace ComputeSharp.Shaders.Mappings [typeof(Vector4).FullName] = "float4", [typeof(Matrix4x4).FullName] = "float4x4", [typeof(ThreadIds).FullName] = "uint3", - [typeof(Buffer2<>).FullName] = "RWBuffer" + [typeof(Buffer<>).FullName] = "RWBuffer" }; /// @@ -54,13 +54,13 @@ namespace ComputeSharp.Shaders.Mappings type == typeof(Matrix4x4); /// - /// Checks whether or not the input type is a value + /// Checks whether or not the input type is a value /// /// The input instance to check - /// A indicating whether the input is in fact a instance + /// A indicating whether the input is in fact a instance [Pure] public static bool IsBufferType(Type type) => type.IsGenericType && - type.GetGenericTypeDefinition() == typeof(Buffer2<>); + type.GetGenericTypeDefinition() == typeof(Buffer<>); /// /// Checks whether or not a given is an HLSL known type diff --git a/src/ComputeSharp.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs index 05d6d235..a0f362db 100644 --- a/src/ComputeSharp.Shaders/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/ShaderLoader.cs @@ -117,7 +117,7 @@ namespace ComputeSharp.Shaders // Read write buffer if (HlslKnownTypes.IsBufferType(fieldType) && - (HeapType)fieldType.GetProperty(nameof(Buffer2.HeapType)).GetValue(fieldValue) == HeapType.Default) + (HeapType)fieldType.GetProperty(nameof(Buffer.HeapType)).GetValue(fieldValue) == HeapType.Default) { // Root parameter for a read write buffer DescriptorRange range = new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, readWriteBuffersCount); diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 347d721b..78958d04 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -18,7 +18,7 @@ namespace DirectX12ComputeShaderSample array[i] = i + 1; } - using Buffer2 gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); + using Buffer gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); // Shader body Action action = id => From 13ee3e942209d4c23f23a68cd8bdf4b4c3fd01d5 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:48:35 +0200 Subject: [PATCH 20/21] Added specific writeable and readonly buffer types --- src/ComputeSharp.Graphics/Buffers/Buffer.cs | 15 ++-------- .../Buffers/BufferExtensions.cs | 18 +++++------ .../Buffers/ReadOnlyBuffer{T}.cs | 26 ++++++++++++++++ .../Buffers/ReadWriteBuffer{T}.cs | 30 +++++++++++++++++++ .../Mappings/HlslKnownTypes.cs | 10 +++---- src/ComputeSharp.Shaders/ShaderLoader.cs | 4 +-- src/DirectX12ComputeShaderSample/Program.cs | 2 +- 7 files changed, 74 insertions(+), 31 deletions(-) create mode 100644 src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs create mode 100644 src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer.cs b/src/ComputeSharp.Graphics/Buffers/Buffer.cs index 1cbc6ad9..703bc324 100644 --- a/src/ComputeSharp.Graphics/Buffers/Buffer.cs +++ b/src/ComputeSharp.Graphics/Buffers/Buffer.cs @@ -11,7 +11,7 @@ namespace ComputeSharp.Graphics.Buffers /// A representing a typed buffer stored on GPU memory /// /// The type of items stored on the buffer - public sealed class Buffer : GraphicsResource where T : unmanaged + public class Buffer : GraphicsResource where T : unmanaged { /// /// Creates a new instance with the specified parameters @@ -19,7 +19,7 @@ namespace ComputeSharp.Graphics.Buffers /// The associated with the current instance /// The number of items to store in the current buffer /// The heap type for the current buffer - internal Buffer(GraphicsDevice device, int size, HeapType heapType) : base(device) + protected internal Buffer(GraphicsDevice device, int size, HeapType heapType) : base(device) { Size = size; ElementSizeInBytes = Unsafe.SizeOf(); @@ -108,17 +108,6 @@ namespace ComputeSharp.Graphics.Buffers /// public HeapType HeapType { get; } - /// - /// Gets or sets a single value from the current buffer - /// - /// The index of the value to get or set - /// This API can only be used from a compute shader, and will always throw if used anywhere else - public T this[uint i] - { - get => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); - set => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); - } - /// /// Reads the contents of the current instance and returns an array /// diff --git a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs index e424961e..ae6e41c5 100644 --- a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs @@ -16,12 +16,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The size of the buffer to allocate - /// A zeroed read write instance of size + /// A zeroed instance of size [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged + public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, int size) where T : unmanaged { - return new Buffer(device, size, HeapType.Default); + return new ReadWriteBuffer(device, size); } /// @@ -30,12 +30,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A read write instance with the contents of the input + /// A read write instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static ReadWriteBuffer AllocateReadWriteBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer buffer = new Buffer(device, span.Length, HeapType.Default); + ReadWriteBuffer buffer = new ReadWriteBuffer(device, span.Length); buffer.SetData(span); return buffer; @@ -47,12 +47,12 @@ namespace ComputeSharp.Graphics.Buffers /// The type of items to store in the buffer /// The instance to use to allocate the buffer /// The input with the data to copy on the allocated buffer - /// A constant instance with the contents of the input + /// A constant instance with the contents of the input [Pure] [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Buffer AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged + public static ReadOnlyBuffer AllocateConstantBuffer(this GraphicsDevice device, Span span) where T : unmanaged { - Buffer buffer = new Buffer(device, span.Length, HeapType.Upload); + ReadOnlyBuffer buffer = new ReadOnlyBuffer(device, span.Length); buffer.SetData(span); return buffer; diff --git a/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs new file mode 100644 index 00000000..c86d4084 --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/ReadOnlyBuffer{T}.cs @@ -0,0 +1,26 @@ +using System; +using SharpDX.Direct3D12; + +namespace ComputeSharp.Graphics.Buffers +{ + /// + /// A representing a typed read write buffer stored on GPU memory + /// + /// The type of items stored on the buffer + public sealed class ReadOnlyBuffer : Buffer where T : unmanaged + { + /// + /// Creates a new instance with the specified parameters + /// + /// The associated with the current instance + /// The number of items to store in the current buffer + internal ReadOnlyBuffer(GraphicsDevice device, int size) : base(device, size, HeapType.Upload) { } + + /// + /// Gets a single value from the current read write buffer + /// + /// The index of the value to get + /// This API can only be used from a compute shader, and will always throw if used anywhere else + public T this[uint i] => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); + } +} diff --git a/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs new file mode 100644 index 00000000..ded6d1e9 --- /dev/null +++ b/src/ComputeSharp.Graphics/Buffers/ReadWriteBuffer{T}.cs @@ -0,0 +1,30 @@ +using System; +using SharpDX.Direct3D12; + +namespace ComputeSharp.Graphics.Buffers +{ + /// + /// A representing a typed read write buffer stored on GPU memory + /// + /// The type of items stored on the buffer + public sealed class ReadWriteBuffer : Buffer where T : unmanaged + { + /// + /// Creates a new instance with the specified parameters + /// + /// The associated with the current instance + /// The number of items to store in the current buffer + internal ReadWriteBuffer(GraphicsDevice device, int size) : base(device, size, HeapType.Default) { } + + /// + /// Gets or sets a single value from the current read write buffer + /// + /// The index of the value to get or set + /// This API can only be used from a compute shader, and will always throw if used anywhere else + public T this[uint i] + { + get => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); + set => throw new InvalidOperationException("The indexer APIs can only be used from a compute shader"); + } + } +} diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs index e1847415..32bf790d 100644 --- a/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs +++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownTypes.cs @@ -27,7 +27,7 @@ namespace ComputeSharp.Shaders.Mappings [typeof(Vector4).FullName] = "float4", [typeof(Matrix4x4).FullName] = "float4x4", [typeof(ThreadIds).FullName] = "uint3", - [typeof(Buffer<>).FullName] = "RWBuffer" + [typeof(ReadWriteBuffer<>).FullName] = "RWBuffer" }; /// @@ -54,13 +54,13 @@ namespace ComputeSharp.Shaders.Mappings type == typeof(Matrix4x4); /// - /// Checks whether or not the input type is a value + /// Checks whether or not the input type is a value /// /// The input instance to check - /// A indicating whether the input is in fact a instance + /// A indicating whether the input is in fact a instance [Pure] - public static bool IsBufferType(Type type) => type.IsGenericType && - type.GetGenericTypeDefinition() == typeof(Buffer<>); + public static bool IsReadWriteBufferType(Type type) => type.IsGenericType && + type.GetGenericTypeDefinition() == typeof(ReadWriteBuffer<>); /// /// Checks whether or not a given is an HLSL known type diff --git a/src/ComputeSharp.Shaders/ShaderLoader.cs b/src/ComputeSharp.Shaders/ShaderLoader.cs index a0f362db..aabd5bb8 100644 --- a/src/ComputeSharp.Shaders/ShaderLoader.cs +++ b/src/ComputeSharp.Shaders/ShaderLoader.cs @@ -4,7 +4,6 @@ using System.Diagnostics.Contracts; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; -using ComputeSharp.Graphics.Buffers; using ComputeSharp.Graphics.Buffers.Abstract; using ComputeSharp.Shaders.Mappings; using ComputeSharp.Shaders.Renderer.Models.Fields; @@ -116,8 +115,7 @@ namespace ComputeSharp.Shaders FieldInfoBase processedFieldInfo; // Read write buffer - if (HlslKnownTypes.IsBufferType(fieldType) && - (HeapType)fieldType.GetProperty(nameof(Buffer.HeapType)).GetValue(fieldValue) == HeapType.Default) + if (HlslKnownTypes.IsReadWriteBufferType(fieldType)) { // Root parameter for a read write buffer DescriptorRange range = new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, readWriteBuffersCount); diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index 78958d04..ed6ba932 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -18,7 +18,7 @@ namespace DirectX12ComputeShaderSample array[i] = i + 1; } - using Buffer gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); + using ReadWriteBuffer gpuBuffer = Gpu.Default.AllocateReadWriteBuffer(array.AsSpan()); // Shader body Action action = id => From d015e97ca573bb498a30d45a2659ee942ae308f8 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 12 Aug 2019 13:49:16 +0200 Subject: [PATCH 21/21] Minor code refactoring --- .../Buffers/{ => Extensions}/BufferExtensions.cs | 3 +-- src/DirectX12ComputeShaderSample/Program.cs | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) rename src/ComputeSharp.Graphics/Buffers/{ => Extensions}/BufferExtensions.cs (97%) diff --git a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs similarity index 97% rename from src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs rename to src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs index ae6e41c5..70dacfb5 100644 --- a/src/ComputeSharp.Graphics/Buffers/BufferExtensions.cs +++ b/src/ComputeSharp.Graphics/Buffers/Extensions/BufferExtensions.cs @@ -1,9 +1,8 @@ using System; using System.Diagnostics.Contracts; using System.Runtime.CompilerServices; -using SharpDX.Direct3D12; -namespace ComputeSharp.Graphics.Buffers +namespace ComputeSharp.Graphics.Buffers.Extensions { /// /// A with extension methods for the type to allocate buffers diff --git a/src/DirectX12ComputeShaderSample/Program.cs b/src/DirectX12ComputeShaderSample/Program.cs index ed6ba932..813bd5b1 100644 --- a/src/DirectX12ComputeShaderSample/Program.cs +++ b/src/DirectX12ComputeShaderSample/Program.cs @@ -2,6 +2,7 @@ using System.Linq; using ComputeSharp; using ComputeSharp.Graphics.Buffers; +using ComputeSharp.Graphics.Buffers.Extensions; namespace DirectX12ComputeShaderSample {