diff --git a/lib/win-x64/dxcompiler.dll b/lib/win-x64/dxcompiler.dll
deleted file mode 100644
index 75a7284c..00000000
Binary files a/lib/win-x64/dxcompiler.dll and /dev/null differ
diff --git a/lib/win-x64/dxil.dll b/lib/win-x64/dxil.dll
deleted file mode 100644
index 56372771..00000000
Binary files a/lib/win-x64/dxil.dll and /dev/null differ
diff --git a/lib/win-x86/dxcompiler.dll b/lib/win-x86/dxcompiler.dll
deleted file mode 100644
index 1c8e5059..00000000
Binary files a/lib/win-x86/dxcompiler.dll and /dev/null differ
diff --git a/lib/win-x86/dxil.dll b/lib/win-x86/dxil.dll
deleted file mode 100644
index 84a67122..00000000
Binary files a/lib/win-x86/dxil.dll and /dev/null differ
diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
index cc32bf05..184df405 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/GraphicsResource.cs
@@ -1,5 +1,5 @@
using System;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Buffers.Abstract
{
@@ -28,9 +28,9 @@ namespace ComputeSharp.Graphics.Buffers.Abstract
internal IntPtr MappedResource { get; private set; }
///
- /// Gets the object currently mapped
+ /// Gets the object currently mapped
///
- protected internal Resource? NativeResource { get; set; }
+ protected internal ID3D12Resource? NativeResource { get; set; }
///
/// Gets the instance for the current resource
diff --git a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
index 29a747f7..d4fea65b 100644
--- a/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Abstract/HlslStructuredBuffer{T}.cs
@@ -2,7 +2,7 @@
using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Helpers;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
namespace ComputeSharp.Graphics.Buffers.Abstract
diff --git a/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
index c08a8304..7ccd975e 100644
--- a/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/Buffer{T}.cs
@@ -3,7 +3,7 @@ using System.Diagnostics.Contracts;
using System.Runtime.CompilerServices;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Buffers
{
@@ -112,8 +112,8 @@ namespace ComputeSharp.Graphics.Buffers
ShaderResourceViewDescription description = new ShaderResourceViewDescription
{
Shader4ComponentMapping = 5768,
- Dimension = ShaderResourceViewDimension.Buffer,
- Buffer = { ElementCount = Size, StructureByteStride = ElementSizeInBytes }
+ ViewDimension = ShaderResourceViewDimension.Buffer,
+ Buffer = { NumElements = Size, StructureByteStride = ElementSizeInBytes }
};
GraphicsDevice.NativeDevice.CreateShaderResourceView(NativeResource, description, cpuHandle);
@@ -132,8 +132,8 @@ namespace ComputeSharp.Graphics.Buffers
UnorderedAccessViewDescription description = new UnorderedAccessViewDescription
{
- Dimension = UnorderedAccessViewDimension.Buffer,
- Buffer = { ElementCount = Size, StructureByteStride = ElementSizeInBytes }
+ ViewDimension = UnorderedAccessViewDimension.Buffer,
+ Buffer = { NumElements = Size, StructureByteStride = ElementSizeInBytes }
};
GraphicsDevice.NativeDevice.CreateUnorderedAccessView(NativeResource, null, description, cpuHandle);
diff --git a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
index 7302eee3..ae4c072d 100644
--- a/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
+++ b/src/ComputeSharp.Graphics/Buffers/ConstantBuffer{T}.cs
@@ -7,7 +7,7 @@ using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Buffers.Enums;
using ComputeSharp.Graphics.Helpers;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
namespace ComputeSharp
diff --git a/src/ComputeSharp.Graphics/Commands/Abstract/CommandController.cs b/src/ComputeSharp.Graphics/Commands/Abstract/CommandController.cs
index b2f13e42..2c0d895e 100644
--- a/src/ComputeSharp.Graphics/Commands/Abstract/CommandController.cs
+++ b/src/ComputeSharp.Graphics/Commands/Abstract/CommandController.cs
@@ -1,5 +1,5 @@
using System;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Commands.Abstract
{
diff --git a/src/ComputeSharp.Graphics/Commands/CommandAllocatorPool.cs b/src/ComputeSharp.Graphics/Commands/CommandAllocatorPool.cs
index a5bcb7a0..8beff52f 100644
--- a/src/ComputeSharp.Graphics/Commands/CommandAllocatorPool.cs
+++ b/src/ComputeSharp.Graphics/Commands/CommandAllocatorPool.cs
@@ -2,29 +2,29 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using ComputeSharp.Graphics.Commands.Abstract;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Commands
{
///
- /// A that acts as a pool to get new instances wheen needed
+ /// A that acts as a pool to get new instances wheen needed
///
internal sealed class CommandAllocatorPool : CommandController
{
///
- /// The queue of currently pooled instances
+ /// The queue of currently pooled instances
///
- private readonly Queue<(CommandAllocator CommandAllocator, long FenceValue)> CommandAllocatorQueue = new Queue<(CommandAllocator, long)>();
+ private readonly Queue<(ID3D12CommandAllocator CommandAllocator, long FenceValue)> CommandAllocatorQueue = new Queue<(ID3D12CommandAllocator, long)>();
///
public CommandAllocatorPool(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType) { }
///
- /// Adds a new item to the internal pool queue
+ /// Adds a new item to the internal pool queue
///
- /// The input to enqueue
- /// The fence value for the input
- public void Enqueue(CommandAllocator commandAllocator, long fenceValue)
+ /// The input to enqueue
+ /// The fence value for the input
+ public void Enqueue(ID3D12CommandAllocator commandAllocator, long fenceValue)
{
lock (CommandAllocatorQueue)
{
@@ -33,16 +33,16 @@ namespace ComputeSharp.Graphics.Commands
}
///
- /// Gets a new or reused item to use to issue GPU commands
+ /// Gets a new or reused item to use to issue GPU commands
///
[Pure]
- public CommandAllocator GetCommandAllocator()
+ public ID3D12CommandAllocator GetCommandAllocator()
{
lock (CommandAllocatorQueue)
{
if (CommandAllocatorQueue.Count > 0)
{
- (CommandAllocator commandAllocator, long fenceValue) = CommandAllocatorQueue.Peek();
+ (ID3D12CommandAllocator commandAllocator, long fenceValue) = CommandAllocatorQueue.Peek();
long completedValue = CommandListType switch
{
@@ -70,7 +70,7 @@ namespace ComputeSharp.Graphics.Commands
{
lock (CommandAllocatorQueue)
{
- foreach ((CommandAllocator commandAllocator, long _) in CommandAllocatorQueue)
+ foreach ((ID3D12CommandAllocator commandAllocator, long _) in CommandAllocatorQueue)
{
commandAllocator.Dispose();
}
diff --git a/src/ComputeSharp.Graphics/Commands/CommandList.cs b/src/ComputeSharp.Graphics/Commands/CommandList.cs
index b26c690f..de0a4d99 100644
--- a/src/ComputeSharp.Graphics/Commands/CommandList.cs
+++ b/src/ComputeSharp.Graphics/Commands/CommandList.cs
@@ -1,7 +1,7 @@
using System;
using ComputeSharp.Graphics.Buffers.Abstract;
using ComputeSharp.Graphics.Commands.Abstract;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Commands
{
@@ -22,23 +22,23 @@ namespace ComputeSharp.Graphics.Commands
};
NativeCommandList = GraphicsDevice.NativeDevice.CreateCommandList(CommandListType, CommandAllocator, null);
- // Set the heap descriptor if the command list is for copy operations
+ // Set the heap descriptor if the command list is not for copy operations
if (CommandListType != CommandListType.Copy)
{
- NativeCommandList.SetDescriptorHeaps(GraphicsDevice.ShaderResourceViewAllocator.DescriptorHeap);
+ NativeCommandList.SetDescriptorHeaps(1, new[] { GraphicsDevice.ShaderResourceViewAllocator.DescriptorHeap });
}
}
///
- /// Gets the object in use by the current instance
+ /// Gets the object in use by the current instance
///
- public CommandAllocator CommandAllocator { get; }
+ public ID3D12CommandAllocator CommandAllocator { get; }
///
- /// Gets the object in use by the current instance
+ /// Gets the object in use by the current instance
///
- public GraphicsCommandList NativeCommandList { get; }
+ public ID3D12GraphicsCommandList NativeCommandList { get; }
///
/// Copies a memory region from one resource to another
@@ -71,7 +71,7 @@ namespace ComputeSharp.Graphics.Commands
public void SetPipelineState(PipelineState pipelineState)
{
NativeCommandList.SetComputeRootSignature(pipelineState.RootSignature);
- NativeCommandList.PipelineState = pipelineState.NativePipelineState;
+ NativeCommandList.SetPipelineState(pipelineState.NativePipelineState);
}
///
diff --git a/src/ComputeSharp.Graphics/Commands/PipelineState.cs b/src/ComputeSharp.Graphics/Commands/PipelineState.cs
index 33bc2e86..64350e46 100644
--- a/src/ComputeSharp.Graphics/Commands/PipelineState.cs
+++ b/src/ComputeSharp.Graphics/Commands/PipelineState.cs
@@ -1,4 +1,4 @@
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Commands
{
@@ -11,25 +11,19 @@ namespace ComputeSharp.Graphics.Commands
/// Creates a new instance with the specified parameters
///
/// The to use
- /// The value for the current shader
+ /// The value for the current shader
/// The bytecode for the compute shader to run
- public PipelineState(GraphicsDevice device, RootSignature rootSignature, ShaderBytecode computeShader)
+ public PipelineState(GraphicsDevice device, ID3D12RootSignature rootSignature, ShaderBytecode computeShader)
{
- RootSignaturePointer = rootSignature;
+ RootSignature = rootSignature;
ComputeShader = computeShader;
- RootSignature = RootSignaturePointer;
NativePipelineState = device.NativeDevice.CreateComputePipelineState(this);
}
///
- /// Gets the value for the current shader
+ /// Gets the instance for the current object
///
- public RootSignature RootSignature { get; }
-
- ///
- /// Gets the instance for the current object
- ///
- public SharpDX.Direct3D12.PipelineState NativePipelineState { get; }
+ public ID3D12PipelineState NativePipelineState { get; }
}
}
diff --git a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj
index 6452507c..c9360703 100644
--- a/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj
+++ b/src/ComputeSharp.Graphics/ComputeSharp.Graphics.csproj
@@ -8,8 +8,8 @@
-
+
diff --git a/src/ComputeSharp.Graphics/DescriptorAllocator.cs b/src/ComputeSharp.Graphics/DescriptorAllocator.cs
index ee34f95f..b222f967 100644
--- a/src/ComputeSharp.Graphics/DescriptorAllocator.cs
+++ b/src/ComputeSharp.Graphics/DescriptorAllocator.cs
@@ -1,5 +1,5 @@
using System;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics
{
@@ -56,14 +56,14 @@ namespace ComputeSharp.Graphics
DescriptorHeap = device.NativeDevice.CreateDescriptorHeap(descriptorHeapDescription);
_RemainingHandles = DescriptorsPerHeap;
- _CurrentCpuHandle = DescriptorHeap.CPUDescriptorHandleForHeapStart;
- _CurrentGpuHandle = DescriptorHeap.GPUDescriptorHandleForHeapStart;
+ _CurrentCpuHandle = DescriptorHeap.GetCPUDescriptorHandleForHeapStart();
+ _CurrentGpuHandle = DescriptorHeap.GetGPUDescriptorHandleForHeapStart();
}
///
- /// Gets the object in use for the current instance
+ /// Gets the object in use for the current instance
///
- public DescriptorHeap DescriptorHeap { get; }
+ public ID3D12DescriptorHeap DescriptorHeap { get; }
///
/// Allocates a new CPU and GPU handle pair to use in a memory buffer
@@ -76,8 +76,8 @@ namespace ComputeSharp.Graphics
if (_RemainingHandles == 0)
{
_RemainingHandles = DescriptorHeap.Description.DescriptorCount;
- _CurrentCpuHandle = DescriptorHeap.CPUDescriptorHandleForHeapStart;
- _CurrentGpuHandle = DescriptorHeap.GPUDescriptorHandleForHeapStart;
+ _CurrentCpuHandle = DescriptorHeap.GetCPUDescriptorHandleForHeapStart();
+ _CurrentGpuHandle = DescriptorHeap.GetGPUDescriptorHandleForHeapStart();
}
CpuDescriptorHandle cpuDescriptorHandle = _CurrentCpuHandle;
diff --git a/src/ComputeSharp.Graphics/GraphicsDevice.cs b/src/ComputeSharp.Graphics/GraphicsDevice.cs
index dc3983d2..8094c30a 100644
--- a/src/ComputeSharp.Graphics/GraphicsDevice.cs
+++ b/src/ComputeSharp.Graphics/GraphicsDevice.cs
@@ -1,11 +1,10 @@
using System;
using System.Threading;
using ComputeSharp.Graphics.Commands;
-using SharpDX.Direct3D;
-using SharpDX.Direct3D12;
-using SharpDX.DXGI;
+using Vortice.DirectX.Direct3D;
+using Vortice.DirectX.Direct3D12;
+using Vortice.DirectX.DXGI;
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
-using Device = SharpDX.Direct3D12.Device;
namespace ComputeSharp.Graphics
{
@@ -15,9 +14,9 @@ namespace ComputeSharp.Graphics
public sealed class GraphicsDevice : IDisposable
{
///
- /// Gets the value that needs to be supported by GPUs mapped to a instance
+ /// Gets the value that needs to be supported by GPUs mapped to a instance
///
- public const FeatureLevel FeatureLevel = SharpDX.Direct3D.FeatureLevel.Level_12_1;
+ public const FeatureLevel FeatureLevel = Vortice.DirectX.Direct3D.FeatureLevel.Level_12_1;
///
/// The instance used to wait for completion when executing commands
@@ -25,26 +24,26 @@ namespace ComputeSharp.Graphics
private readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
///
- /// The instance to use for compute operations
+ /// The instance to use for compute operations
///
- private readonly CommandQueue NativeComputeCommandQueue;
+ private readonly ID3D12CommandQueue NativeComputeCommandQueue;
///
- /// The instance to use for copy operations
+ /// The instance to use for copy operations
///
- private readonly CommandQueue NativeCopyCommandQueue;
+ private readonly ID3D12CommandQueue NativeCopyCommandQueue;
///
- /// The instance to use for direct operations
+ /// The instance to use for direct operations
///
- private readonly CommandQueue NativeDirectCommandQueue;
+ private readonly ID3D12CommandQueue NativeDirectCommandQueue;
///
- /// Creates a new instance for the input
+ /// Creates a new instance for the input
///
- /// The to use for the new instance
+ /// The to use for the new instance
/// The available info for the new instance
- public GraphicsDevice(Device device, AdapterDescription description)
+ public GraphicsDevice(ID3D12Device device, AdapterDescription description)
{
NativeDevice = device;
Description = description;
@@ -58,9 +57,9 @@ namespace ComputeSharp.Graphics
CopyAllocatorPool = new CommandAllocatorPool(this, CommandListType.Copy);
DirectAllocatorPool = new CommandAllocatorPool(this, CommandListType.Direct);
- NativeComputeFence = NativeDevice.CreateFence(0, FenceFlags.None);
- NativeCopyFence = NativeDevice.CreateFence(0, FenceFlags.None);
- NativeDirectFence = NativeDevice.CreateFence(0, FenceFlags.None);
+ NativeComputeFence = NativeDevice.CreateFence(0);
+ NativeCopyFence = NativeDevice.CreateFence(0);
+ NativeDirectFence = NativeDevice.CreateFence(0);
ShaderResourceViewAllocator = new DescriptorAllocator(this);
}
@@ -76,9 +75,9 @@ namespace ComputeSharp.Graphics
public int WavefrontSize { get; }
///
- /// Gets the object wrapped by the current instance
+ /// Gets the object wrapped by the current instance
///
- internal Device NativeDevice { get; }
+ internal ID3D12Device NativeDevice { get; }
///
/// Gets the object for the current instance, used when allocating new buffers
@@ -101,19 +100,19 @@ namespace ComputeSharp.Graphics
internal CommandAllocatorPool DirectAllocatorPool { get; }
///
- /// Gets the instance used for compute operations
+ /// Gets the instance used for compute operations
///
- internal Fence NativeComputeFence { get; }
+ internal ID3D12Fence NativeComputeFence { get; }
///
- /// Gets the instance used for copy operations
+ /// Gets the instance used for copy operations
///
- internal Fence NativeCopyFence { get; }
+ internal ID3D12Fence NativeCopyFence { get; }
///
- /// Gets the instance used for direct operations
+ /// Gets the instance used for direct operations
///
- internal Fence NativeDirectFence { get; }
+ internal ID3D12Fence NativeDirectFence { get; }
///
/// Gets the next fence value for compute operations
@@ -131,13 +130,13 @@ namespace ComputeSharp.Graphics
internal long NextDirectFenceValue { get; private set; } = 1;
///
- /// Creates a instance from a description
+ /// Creates a instance from a description
///
- /// A instance with the info for the new object to create
- /// A new instance to use in a compute shader
- internal RootSignature CreateRootSignature(RootSignatureDescription rootSignatureDescription)
+ /// A instance with the info for the new object to create
+ /// A new instance to use in a compute shader
+ internal ID3D12RootSignature CreateRootSignature(VersionedRootSignatureDescription rootSignatureDescription)
{
- return NativeDevice.CreateRootSignature(rootSignatureDescription.Serialize());
+ return NativeDevice.CreateRootSignature(rootSignatureDescription);
}
///
@@ -146,7 +145,7 @@ namespace ComputeSharp.Graphics
/// The input to execute
internal void ExecuteCommandList(CommandList commandList)
{
- Fence fence = commandList.CommandListType switch
+ ID3D12Fence fence = commandList.CommandListType switch
{
CommandListType.Direct => NativeDirectFence,
CommandListType.Compute => NativeComputeFence,
@@ -173,8 +172,8 @@ namespace ComputeSharp.Graphics
private long GetFenceValueForCommandList(CommandList commandList)
{
CommandAllocatorPool commandAllocatorPool;
- CommandQueue commandQueue;
- Fence fence;
+ ID3D12CommandQueue commandQueue;
+ ID3D12Fence fence;
long fenceValue;
switch (commandList.CommandListType)
diff --git a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs
index 4bcd4b67..7b19ebd9 100644
--- a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs
+++ b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs
@@ -1,7 +1,8 @@
using System.Collections.Generic;
using System.Diagnostics.Contracts;
-using SharpDX.DXGI;
-using Device = SharpDX.Direct3D12.Device;
+using Vortice.DirectX.Direct3D;
+using Vortice.DirectX.Direct3D12;
+using Vortice.DirectX.DXGI;
namespace ComputeSharp.Graphics.Helpers
{
@@ -13,28 +14,29 @@ namespace ComputeSharp.Graphics.Helpers
///
/// Gets a collection of all the supported devices on the current machine
///
- /// The collection of objects with support for DX12.1
+ /// The collection of objects with support for DX12.1
[Pure]
- public static IReadOnlyList<(Device, AdapterDescription)> QueryAllSupportedDevices()
+ public static IReadOnlyList<(ID3D12Device, AdapterDescription)> QueryAllSupportedDevices()
{
- using Factory factory = new Factory1();
- List<(Device, AdapterDescription)> devices = new List<(Device, AdapterDescription)>();
-
- foreach (Adapter adapter in factory.Adapters)
+ if (!DXGI.CreateDXGIFactory1(out IDXGIFactory1 factory).Success) return new (ID3D12Device, AdapterDescription)[0];
+ try
{
- if (adapter.Description.DedicatedVideoMemory == 0) continue;
- try
- {
- Device device = new Device(adapter, GraphicsDevice.FeatureLevel);
- devices.Add((device, adapter.Description));
- }
- catch
- {
- // Unsupported device
- }
- }
+ List<(ID3D12Device, AdapterDescription)> devices = new List<(ID3D12Device, AdapterDescription)>();
- return devices;
+ foreach (IDXGIAdapter1 adapter in factory.EnumAdapters1())
+ {
+ if (adapter.Description.DedicatedVideoMemory == 0) continue;
+ if (D3D12.D3D12CreateDevice(adapter, FeatureLevel.Level_12_1, out ID3D12Device device).Success)
+ devices.Add((device, adapter.Description));
+ }
+
+ return devices;
+ }
+ finally
+ {
+ // Explicit using statement
+ factory?.Dispose();
+ }
}
}
}
diff --git a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
index 7ed13e1c..726a7283 100644
--- a/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
+++ b/src/ComputeSharp.Shaders/ComputeSharp.Shaders.csproj
@@ -8,24 +8,16 @@
-
- native
-
+
-
-
- PreserveNewest
-
-
-
Never
diff --git a/src/ComputeSharp.Shaders/ShaderRunner.cs b/src/ComputeSharp.Shaders/ShaderRunner.cs
index 0af20faf..01f3818d 100644
--- a/src/ComputeSharp.Shaders/ShaderRunner.cs
+++ b/src/ComputeSharp.Shaders/ShaderRunner.cs
@@ -8,7 +8,7 @@ using ComputeSharp.Graphics.Buffers.Extensions;
using ComputeSharp.Shaders.Renderer;
using ComputeSharp.Shaders.Renderer.Models;
using ComputeSharp.Shaders.Translation;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
using CommandList = ComputeSharp.Graphics.Commands.CommandList;
using PipelineState = ComputeSharp.Graphics.Commands.PipelineState;
@@ -95,8 +95,8 @@ namespace ComputeSharp.Shaders
}
// Create the root signature for the pipeline and get the pipeline state
- RootSignatureDescription rootSignatureDescription = new RootSignatureDescription(RootSignatureFlags.None, shaderData.Loader.RootParameters);
- RootSignature rootSignature = device.CreateRootSignature(rootSignatureDescription);
+ VersionedRootSignatureDescription rootSignatureDescription = new VersionedRootSignatureDescription(new RootSignatureDescription1(RootSignatureFlags.None, shaderData.Loader.RootParameters));
+ ID3D12RootSignature rootSignature = device.CreateRootSignature(rootSignatureDescription);
PipelineState pipelineState = new PipelineState(device, rootSignature, shaderData.Bytecode);
// Create the commands list and set the pipeline state
diff --git a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs
index f73ee23c..b96e6d2e 100644
--- a/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs
+++ b/src/ComputeSharp.Shaders/Translation/MethodDecompiler.cs
@@ -38,16 +38,6 @@ namespace ComputeSharp.Shaders.Translation
///
private readonly Dictionary Decompilers = new Dictionary();
- ///
- /// The available instances for the loaded assemblies
- ///
- private readonly IReadOnlyList PEFiles;
-
- ///
- /// The mapping of and values for the discovered instances
- ///
- private readonly Dictionary TypeDefinitions = new Dictionary();
-
///
/// The incremental instance for the shader assembly
///
@@ -80,9 +70,6 @@ namespace ComputeSharp.Shaders.Translation
}).ToArray();
}
- // Load and store all the available PEFile instances
- PEFiles = assemblyPaths.Select(p => new PEFile(p)).ToArray();
-
// Ceate an incremental shader assembly with the available references
IEnumerable metadataReferences = assemblyPaths.Select(p => MetadataReference.CreateFromFile(p));
_Compilation = CSharpCompilation.Create("ShaderAssembly").WithReferences(metadataReferences);
@@ -211,10 +198,10 @@ namespace ComputeSharp.Shaders.Translation
List parsedFields = new List();
// Local function to recursively extract all the nested fields
- void ParseNestedFields(string source)
+ void ParseNestedFields(string typeSource)
{
// Find the field declarations
- Match match = NestedClosureFieldRegex.Match(source);
+ Match match = NestedClosureFieldRegex.Match(typeSource);
if (!match.Success) return;
// Load the nested closure type
diff --git a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs
index 6c7cfe14..e217ca18 100644
--- a/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs
+++ b/src/ComputeSharp.Shaders/Translation/ShaderCompiler.cs
@@ -1,12 +1,12 @@
using System;
using System.Diagnostics.Contracts;
-using DotNetDxc;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
+using Vortice.Dxc;
namespace ComputeSharp.Shaders.Translation
{
///
- /// A that uses the APIs to compile compute shaders
+ /// A that uses the APIs to compile compute shaders
///
internal sealed class ShaderCompiler
{
@@ -15,25 +15,10 @@ namespace ComputeSharp.Shaders.Translation
///
public static ShaderCompiler Instance { get; } = new ShaderCompiler();
- ///
- /// The instance to use to create new HLSL shaders
- ///
- private readonly IDxcCompiler Compiler;
-
///
/// The instance to use to create the bytecode for HLSL sources
///
- private readonly IDxcLibrary Library;
-
- ///
- /// Creates a new instance
- ///
- private ShaderCompiler()
- {
- HlslDxcLib.DxcCreateInstanceFn = DefaultDxcLib.GetDxcCreateInstanceFn();
- Compiler = HlslDxcLib.CreateDxcCompiler();
- Library = HlslDxcLib.CreateDxcLibrary();
- }
+ private readonly IDxcLibrary Library = Dxc.CreateDxcLibrary();
///
/// Compiles a new HLSL shader from the input source code
@@ -43,53 +28,20 @@ namespace ComputeSharp.Shaders.Translation
[Pure]
public ShaderBytecode CompileShader(string source)
{
- const uint CP_UTF16 = 1200;
-
- IDxcBlobEncoding sourceBlob = Library.CreateBlobWithEncodingOnHeapCopy(source, (uint)(source.Length * 2), CP_UTF16);
- IDxcOperationResult result = Compiler.Compile(sourceBlob, "", "CSMain", "cs_6_1", new[] { "-Zpr" }, 1, null, 0, Library.CreateIncludeHandler());
+ var result = DxcCompiler.Compile(DxcShaderStage.ComputeShader, source, "CSMain", string.Empty, new DxcCompilerOptions { ShaderModel = DxcShaderModel.Model6_1 });
// Get the compiled bytecode in case of success
if (result.GetStatus() == 0)
{
IDxcBlob blob = result.GetResult();
- byte[] bytecode = GetBytesFromBlob(blob);
+ byte[] bytecode = Dxc.GetBytesFromBlob(blob);
return bytecode;
}
// Compile error
- string resultText = GetStringFromBlob(Library, result.GetErrors());
+ string resultText = Dxc.GetStringFromBlob(Library, result.GetErrors());
throw new Exception(resultText);
}
-
- ///
- /// Reads the buffer content from an input instance
- ///
- /// The input instance to read data from
- /// The read bytes buffer, as an array
- [Pure]
- private static unsafe byte[] GetBytesFromBlob(IDxcBlob blob)
- {
- byte* pMem = (byte*)blob.GetBufferPointer();
- uint size = blob.GetBufferSize();
- byte[] result = new byte[size];
-
- new Span(pMem, (int)size).CopyTo(result.AsSpan());
-
- return result;
- }
-
- ///
- /// Reads a value from an input instance
- ///
- /// The source to use to load the data
- /// The input instance to read data from
- /// The resulting read from the input data buffer
- [Pure]
- private static unsafe string GetStringFromBlob(IDxcLibrary library, IDxcBlob blob)
- {
- blob = library.GetBlobAstUf16(blob);
- return new string(blob.GetBufferPointer(), 0, (int)(blob.GetBufferSize() / 2));
- }
}
}
diff --git a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
index 5e2f5e4d..d550d1dc 100644
--- a/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
+++ b/src/ComputeSharp.Shaders/Translation/ShaderLoader.cs
@@ -11,7 +11,7 @@ using ComputeSharp.Shaders.Renderer.Models.Fields.Abstract;
using ComputeSharp.Shaders.Translation.Models;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
-using SharpDX.Direct3D12;
+using Vortice.DirectX.Direct3D12;
#pragma warning disable CS8618 // Non-nullable field is uninitialized
@@ -58,16 +58,16 @@ namespace ComputeSharp.Shaders.Translation
public Type ShaderType { get; }
///
- /// The of items that are required to load the captured values
+ /// The of items that are required to load the captured values
///
- private readonly List DescriptorRanges = new List();
+ private readonly List DescriptorRanges = new List();
- private RootParameter[] _RootParameters;
+ private RootParameter1[] _RootParameters;
///
- /// Gets the array for the current shader
+ /// Gets the array for the current shader
///
- public RootParameter[] RootParameters => _RootParameters ??= DescriptorRanges.Select(range => new RootParameter(ShaderVisibility.All, range)).ToArray();
+ public RootParameter1[] RootParameters => _RootParameters ??= DescriptorRanges.Select(range => new RootParameter1(new RootDescriptorTable1(range), ShaderVisibility.All)).ToArray();
///
/// The of instances mapping the captured buffers in the current shader
@@ -162,7 +162,7 @@ namespace ComputeSharp.Shaders.Translation
if (shaderFields.Any(fieldInfo => fieldInfo.IsStatic)) throw new InvalidOperationException("Empty shader body");
// Descriptor for the buffer for captured scalar/vector variables
- DescriptorRanges.Add(new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, _ConstantBuffersCount++));
+ DescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, _ConstantBuffersCount++));
// Inspect the captured fields
foreach (FieldInfo fieldInfo in shaderFields)
@@ -185,7 +185,7 @@ namespace ComputeSharp.Shaders.Translation
// Constant buffer
if (HlslKnownTypes.IsConstantBufferType(fieldType))
{
- DescriptorRanges.Add(new DescriptorRange(DescriptorRangeType.ConstantBufferView, 1, _ConstantBuffersCount));
+ DescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.ConstantBufferView, 1, _ConstantBuffersCount));
// Track the buffer field
_BufferMembers.Add((memberInfo, parents));
@@ -196,7 +196,7 @@ namespace ComputeSharp.Shaders.Translation
else if (HlslKnownTypes.IsReadOnlyBufferType(fieldType))
{
// Root parameter for a readonly buffer
- DescriptorRanges.Add(new DescriptorRange(DescriptorRangeType.ShaderResourceView, 1, _ReadOnlyBuffersCount));
+ DescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.ShaderResourceView, 1, _ReadOnlyBuffersCount));
// Track the buffer field
_BufferMembers.Add((memberInfo, parents));
@@ -207,7 +207,7 @@ namespace ComputeSharp.Shaders.Translation
else if (HlslKnownTypes.IsReadWriteBufferType(fieldType))
{
// Root parameter for a read write buffer
- DescriptorRanges.Add(new DescriptorRange(DescriptorRangeType.UnorderedAccessView, 1, _ReadWriteBuffersCount));
+ DescriptorRanges.Add(new DescriptorRange1(DescriptorRangeType.UnorderedAccessView, 1, _ReadWriteBuffersCount));
// Track the buffer field
_BufferMembers.Add((memberInfo, parents));
diff --git a/src/ComputeSharp/ComputeSharp.nuspec b/src/ComputeSharp/ComputeSharp.nuspec
index caa9106b..3ea4cc89 100644
--- a/src/ComputeSharp/ComputeSharp.nuspec
+++ b/src/ComputeSharp/ComputeSharp.nuspec
@@ -17,12 +17,12 @@
-
-
+
+
diff --git a/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs b/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
index a5b5c1ab..1c4532ed 100644
--- a/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
+++ b/src/ComputeSharp/Extensions/Primitives/VectorExtensions.cs
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics.Contracts;
using System.Numerics;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace ComputeSharp
@@ -17,7 +16,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat2Span(this Vector2[] array) => array.AsSpan().As();
+ public static Span AsFloat2Span(this Vector2[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -25,7 +24,7 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat2Span(this Span span) => span.As();
+ public static Span AsFloat2Span(this Span span) => MemoryMarshal.Cast(span);
///
/// Converts a array into a with items of type
@@ -33,7 +32,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat3Span(this Vector3[] array) => array.AsSpan().As();
+ public static Span AsFloat3Span(this Vector3[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -41,7 +40,7 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat3Span(this Span span) => span.As();
+ public static Span AsFloat3Span(this Span span) => MemoryMarshal.Cast(span);
///
/// Converts a array into a with items of type
@@ -49,7 +48,7 @@ namespace ComputeSharp
/// The input array
/// A with items of type , mapping the original array
[Pure]
- public static Span AsFloat4Span(this Vector4[] array) => array.AsSpan().As();
+ public static Span AsFloat4Span(this Vector4[] array) => MemoryMarshal.Cast(array);
///
/// Converts a into a with items of type
@@ -57,25 +56,6 @@ namespace ComputeSharp
/// The input
/// A with items of type , mapping the original
[Pure]
- public static Span AsFloat4Span(this Span span) => span.As();
-
- ///
- /// Converts a value with items of type to one with items of type
- ///
- /// The type of the input items
- /// The type of items to convert to
- /// The input
- /// A with items of type
- [Pure]
- private static Span As(this Span span)
- where TFrom : unmanaged
- where TTo : unmanaged
- {
-
- if (span.Length == 0) return Span.Empty;
-
- ref TTo r0 = ref Unsafe.As(ref span.GetPinnableReference());
- return MemoryMarshal.CreateSpan(ref r0, span.Length);
- }
+ public static Span AsFloat4Span(this Span span) => MemoryMarshal.Cast(span);
}
}
diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs
index 0bfe9b60..ed09bbcf 100644
--- a/src/ComputeSharp/Gpu.cs
+++ b/src/ComputeSharp/Gpu.cs
@@ -4,8 +4,8 @@ using System.Diagnostics.Contracts;
using System.Linq;
using ComputeSharp.Graphics;
using ComputeSharp.Graphics.Helpers;
-using SharpDX.DXGI;
-using Device = SharpDX.Direct3D12.Device;
+using Vortice.DirectX.Direct3D12;
+using Vortice.DirectX.DXGI;
namespace ComputeSharp
{
@@ -42,6 +42,6 @@ namespace ComputeSharp
public static IEnumerable EnumerateDevices() => _Devices.Select(device => new GraphicsDevice(device.Device, device.Description));
// The loaded collection of supported devices
- private static IReadOnlyList<(Device Device, AdapterDescription Description)> _Devices;
+ private static IReadOnlyList<(ID3D12Device Device, AdapterDescription Description)> _Devices;
}
}
diff --git a/src/NuGet.config b/src/NuGet.config
new file mode 100644
index 00000000..f072f570
--- /dev/null
+++ b/src/NuGet.config
@@ -0,0 +1,3 @@
+
+
+