ComputeSharp.Graphics project switched to Vortice.Windows

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-26 19:57:43 +02:00
1 親 1f312787ac
コミット 07b3608fe0
13ファイル変更
+103 -108

検索条件に一致するファイルはありません

+3 -3
ファイルの表示
@@ -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; }
/// <summary>
/// Gets the <see cref="Resource"/> object currently mapped
/// Gets the <see cref="ID3D12Resource"/> object currently mapped
/// </summary>
protected internal Resource? NativeResource { get; set; }
protected internal ID3D12Resource? NativeResource { get; set; }
/// <summary>
/// Gets the <see cref="CpuDescriptorHandle"/> instance for the current resource
+1 -1
ファイルの表示
@@ -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
+5 -5
ファイルの表示
@@ -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);
+1 -1
ファイルの表示
@@ -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
+1 -1
ファイルの表示
@@ -1,5 +1,5 @@
using System;
using SharpDX.Direct3D12;
using Vortice.DirectX.Direct3D12;
namespace ComputeSharp.Graphics.Commands.Abstract
{
+12 -12
ファイルの表示
@@ -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
{
/// <summary>
/// A <see langword="class"/> that acts as a pool to get new <see cref="CommandAllocator"/> instances wheen needed
/// A <see langword="class"/> that acts as a pool to get new <see cref="ID3D12CommandAllocator"/> instances wheen needed
/// </summary>
internal sealed class CommandAllocatorPool : CommandController
{
/// <summary>
/// The queue of currently pooled <see cref="CommandAllocator"/> instances
/// The queue of currently pooled <see cref="ID3D12CommandAllocator"/> instances
/// </summary>
private readonly Queue<(CommandAllocator CommandAllocator, long FenceValue)> CommandAllocatorQueue = new Queue<(CommandAllocator, long)>();
private readonly Queue<(ID3D12CommandAllocator CommandAllocator, long FenceValue)> CommandAllocatorQueue = new Queue<(ID3D12CommandAllocator, long)>();
/// <inheritdoc/>
public CommandAllocatorPool(GraphicsDevice device, CommandListType commandListType) : base(device, commandListType) { }
/// <summary>
/// Adds a new <see cref="CommandAllocator"/> item to the internal pool queue
/// Adds a new <see cref="ID3D12CommandAllocator"/> item to the internal pool queue
/// </summary>
/// <param name="commandAllocator">The input <see cref="CommandAllocator"/> to enqueue</param>
/// <param name="fenceValue">The fence value for the input <see cref="CommandAllocator"/></param>
public void Enqueue(CommandAllocator commandAllocator, long fenceValue)
/// <param name="commandAllocator">The input <see cref="ID3D12CommandAllocator"/> to enqueue</param>
/// <param name="fenceValue">The fence value for the input <see cref="ID3D12CommandAllocator"/></param>
public void Enqueue(ID3D12CommandAllocator commandAllocator, long fenceValue)
{
lock (CommandAllocatorQueue)
{
@@ -33,16 +33,16 @@ namespace ComputeSharp.Graphics.Commands
}
/// <summary>
/// Gets a new or reused <see cref="CommandAllocator"/> item to use to issue GPU commands
/// Gets a new or reused <see cref="ID3D12CommandAllocator"/> item to use to issue GPU commands
/// </summary>
[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();
}
+8 -8
ファイルの表示
@@ -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 });
}
}
/// <summary>
/// Gets the <see cref="SharpDX.Direct3D12.CommandAllocator"/> object in use by the current instance
/// Gets the <see cref="ID3D12CommandAllocator"/> object in use by the current instance
/// </summary>
public CommandAllocator CommandAllocator { get; }
public ID3D12CommandAllocator CommandAllocator { get; }
/// <summary>
/// Gets the <see cref="GraphicsCommandList"/> object in use by the current instance
/// Gets the <see cref="ID3D12GraphicsCommandList"/> object in use by the current instance
/// </summary>
public GraphicsCommandList NativeCommandList { get; }
public ID3D12GraphicsCommandList NativeCommandList { get; }
/// <summary>
/// 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);
}
/// <summary>
+6 -12
ファイルの表示
@@ -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 <see cref="PipelineState"/> instance with the specified parameters
/// </summary>
/// <param name="device">The <see cref="GraphicsDevice"/> to use</param>
/// <param name="rootSignature">The <see cref="SharpDX.Direct3D12.RootSignature"/> value for the current shader</param>
/// <param name="rootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader</param>
/// <param name="computeShader">The bytecode for the compute shader to run</param>
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);
}
/// <summary>
/// Gets the <see cref="SharpDX.Direct3D12.RootSignature"/> value for the current shader
/// Gets the <see cref="ID3D12PipelineState"/> instance for the current <see cref="PipelineState"/> object
/// </summary>
public RootSignature RootSignature { get; }
/// <summary>
/// Gets the <see cref="SharpDX.Direct3D12.PipelineState"/> instance for the current <see cref="PipelineState"/> object
/// </summary>
public SharpDX.Direct3D12.PipelineState NativePipelineState { get; }
public ID3D12PipelineState NativePipelineState { get; }
}
}
+1 -1
ファイルの表示
@@ -8,8 +8,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpDX.Direct3D12" Version="4.2.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.6.0-preview8.19405.3" />
<PackageReference Include="Vortice.DirectX.Direct3D12" Version="1.0.0-ge816fae51e" />
</ItemGroup>
<ItemGroup>
+7 -7
ファイルの表示
@@ -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();
}
/// <summary>
/// Gets the <see cref="SharpDX.Direct3D12.DescriptorHeap"/> object in use for the current <see cref="DescriptorAllocator"/> instance
/// Gets the <see cref="ID3D12DescriptorHeap"/> object in use for the current <see cref="DescriptorAllocator"/> instance
/// </summary>
public DescriptorHeap DescriptorHeap { get; }
public ID3D12DescriptorHeap DescriptorHeap { get; }
/// <summary>
/// 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;
+33 -34
ファイルの表示
@@ -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
{
/// <summary>
/// Gets the <see cref="SharpDX.Direct3D.FeatureLevel"/> value that needs to be supported by GPUs mapped to a <see cref="GraphicsDevice"/> instance
/// Gets the <see cref="FeatureLevel"/> value that needs to be supported by GPUs mapped to a <see cref="GraphicsDevice"/> instance
/// </summary>
public const FeatureLevel FeatureLevel = SharpDX.Direct3D.FeatureLevel.Level_12_1;
public const FeatureLevel FeatureLevel = Vortice.DirectX.Direct3D.FeatureLevel.Level_12_1;
/// <summary>
/// The <see cref="System.Threading.AutoResetEvent"/> instance used to wait for completion when executing commands
@@ -25,26 +24,26 @@ namespace ComputeSharp.Graphics
private readonly AutoResetEvent AutoResetEvent = new AutoResetEvent(false);
/// <summary>
/// The <see cref="CommandQueue"/> instance to use for compute operations
/// The <see cref="ID3D12CommandQueue"/> instance to use for compute operations
/// </summary>
private readonly CommandQueue NativeComputeCommandQueue;
private readonly ID3D12CommandQueue NativeComputeCommandQueue;
/// <summary>
/// The <see cref="CommandQueue"/> instance to use for copy operations
/// The <see cref="ID3D12CommandQueue"/> instance to use for copy operations
/// </summary>
private readonly CommandQueue NativeCopyCommandQueue;
private readonly ID3D12CommandQueue NativeCopyCommandQueue;
/// <summary>
/// The <see cref="CommandQueue"/> instance to use for direct operations
/// The <see cref="ID3D12CommandQueue"/> instance to use for direct operations
/// </summary>
private readonly CommandQueue NativeDirectCommandQueue;
private readonly ID3D12CommandQueue NativeDirectCommandQueue;
/// <summary>
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="Device"/>
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="ID3D12Device"/>
/// </summary>
/// <param name="device">The <see cref="Device"/> to use for the new <see cref="GraphicsDevice"/> instance</param>
/// <param name="device">The <see cref="ID3D12Device"/> to use for the new <see cref="GraphicsDevice"/> instance</param>
/// <param name="description">The available info for the new <see cref="GraphicsDevice"/> instance</param>
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; }
/// <summary>
/// Gets the <see cref="Device"/> object wrapped by the current instance
/// Gets the <see cref="ID3D12Device"/> object wrapped by the current instance
/// </summary>
internal Device NativeDevice { get; }
internal ID3D12Device NativeDevice { get; }
/// <summary>
/// Gets the <see cref="DescriptorAllocator"/> object for the current instance, used when allocating new buffers
@@ -101,19 +100,19 @@ namespace ComputeSharp.Graphics
internal CommandAllocatorPool DirectAllocatorPool { get; }
/// <summary>
/// Gets the <see cref="Fence"/> instance used for compute operations
/// Gets the <see cref="ID3D12Fence"/> instance used for compute operations
/// </summary>
internal Fence NativeComputeFence { get; }
internal ID3D12Fence NativeComputeFence { get; }
/// <summary>
/// Gets the <see cref="Fence"/> instance used for copy operations
/// Gets the <see cref="ID3D12Fence"/> instance used for copy operations
/// </summary>
internal Fence NativeCopyFence { get; }
internal ID3D12Fence NativeCopyFence { get; }
/// <summary>
/// Gets the <see cref="Fence"/> instance used for direct operations
/// Gets the <see cref="ID3D12Fence"/> instance used for direct operations
/// </summary>
internal Fence NativeDirectFence { get; }
internal ID3D12Fence NativeDirectFence { get; }
/// <summary>
/// Gets the next fence value for compute operations
@@ -131,13 +130,13 @@ namespace ComputeSharp.Graphics
internal long NextDirectFenceValue { get; private set; } = 1;
/// <summary>
/// Creates a <see cref="RootSignature"/> instance from a description
/// Creates a <see cref="ID3D12RootSignature"/> instance from a description
/// </summary>
/// <param name="rootSignatureDescription">A <see cref="RootSignatureDescription"/> instance with the info for the new <see cref="RootSignature"/> object to create</param>
/// <returns>A new <see cref="RootSignature"/> instance to use in a compute shader</returns>
internal RootSignature CreateRootSignature(RootSignatureDescription rootSignatureDescription)
/// <param name="rootSignatureDescription">A <see cref="VersionedRootSignatureDescription"/> instance with the info for the new <see cref="ID3D12RootSignature"/> object to create</param>
/// <returns>A new <see cref="ID3D12RootSignature"/> instance to use in a compute shader</returns>
internal ID3D12RootSignature CreateRootSignature(VersionedRootSignatureDescription rootSignatureDescription)
{
return NativeDevice.CreateRootSignature(rootSignatureDescription.Serialize());
return NativeDevice.CreateRootSignature(rootSignatureDescription);
}
/// <summary>
@@ -146,7 +145,7 @@ namespace ComputeSharp.Graphics
/// <param name="commandList">The input <see cref="CommandList"/> to execute</param>
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)
+22 -20
ファイルの表示
@@ -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
/// <summary>
/// Gets a collection of all the supported devices on the current machine
/// </summary>
/// <returns>The collection of <see cref="Device"/> objects with support for DX12.1</returns>
/// <returns>The collection of <see cref="ID3D12Device"/> objects with support for DX12.1</returns>
[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();
}
}
}
}
+3 -3
ファイルの表示
@@ -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<GraphicsDevice> 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;
}
}