Added Gpu.QueryAll method to list all available GPUs

このコミットが含まれているのは:
Sergio Pedri committed 2019-08-13 12:13:59 +02:00
1 親 a93bcc807c
コミット 17ea1a0f71
2ファイル変更
+58 -5

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

+36 -3
ファイルの表示
@@ -2,6 +2,8 @@
using System.Threading;
using SharpDX.Direct3D;
using SharpDX.Direct3D12;
using SharpDX.DXGI;
using Device = SharpDX.Direct3D12.Device;
namespace ComputeSharp.Graphics
{
@@ -9,12 +11,21 @@ namespace ComputeSharp.Graphics
{
private readonly AutoResetEvent fenceEvent = new AutoResetEvent(false);
public GraphicsDevice(bool enableDebugLayer = false)
/// <summary>
/// Creates a new <see cref="GraphicsDevice"/> instance for the default GPU on the current machine
/// </summary>
public GraphicsDevice() : this(new Device(null, FeatureLevel)) { }
/// <summary>
/// Creates a new <see cref="GraphicsDevice"/> instance for the input <see cref="Device"/>
/// </summary>
/// <param name="device">The <see cref="Device"/> to use for the new <see cref="GraphicsDevice"/> instance</param>
private GraphicsDevice(Device device)
{
#if DEBUG
if (enableDebugLayer) DebugInterface.Get().EnableDebugLayer();
DebugInterface.Get().EnableDebugLayer();
#endif
NativeDevice = new Device(null, FeatureLevel);
NativeDevice = device;
WavefrontSize = NativeDevice.D3D12Options1.WaveLaneCountMin;
NativeComputeCommandQueue = NativeDevice.CreateCommandQueue(new CommandQueueDescription(SharpDX.Direct3D12.CommandListType.Compute));
@@ -41,6 +52,28 @@ namespace ComputeSharp.Graphics
CopyCommandList.Close();
}
/// <summary>
/// Tries to create a new <see cref="GraphicsDevice"/> instance from the input <see cref="Adapter"/> object
/// </summary>
/// <param name="adapter">The input <see cref="Adapter"/> for the current GPU being targeted</param>
/// <param name="result">The resulting <see cref="GraphicsDevice"/> value, in case of success</param>
/// <returns>A <see langword="bool"/> value indicating whether or not the resulting device was created correctly</returns>
public static bool TryGetFromAdapter(Adapter adapter, out GraphicsDevice? result)
{
try
{
Device device = new Device(adapter, FeatureLevel);
result = new GraphicsDevice(device);
return true;
}
catch
{
result = null;
return false;
}
}
/// <summary>
/// Gets the number of lanes in a SIMD wave on the current device (also known as "wavefront size" or "warp width")
/// </summary>