using System.Collections.Generic;
using System.Diagnostics.Contracts;
using SharpDX.DXGI;
using Device = SharpDX.Direct3D12.Device;
namespace ComputeSharp.Graphics.Helpers
{
///
/// A with methods to inspect the available devices on the current machine
///
public static class DeviceHelper
{
///
/// Gets a collection of all the supported devices on the current machine
///
/// The collection of objects with support for DX12.1
[Pure]
public static IReadOnlyList QueryAllSupportedDevices()
{
using Factory factory = new Factory1();
List devices = new List();
foreach (Adapter adapter in factory.Adapters)
{
if (adapter.Description.DedicatedVideoMemory == 0) continue;
try
{
Device device = new Device(adapter, GraphicsDevice.FeatureLevel);
devices.Add(device);
}
catch
{
// Unsupported device
}
}
return devices;
}
}
}