Added device description to the GraphicsDevice class
このコミットが含まれているのは:
1 親
46e8fd6b15
コミット
f6f73b9e3f
3ファイル変更
+12
-26
検索条件に一致するファイルはありません
@@ -15,12 +15,14 @@ namespace ComputeSharp.Graphics
|
||||
/// 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>
|
||||
public GraphicsDevice(Device device)
|
||||
/// <param name="description">The available info for the new <see cref="GraphicsDevice"/> instance</param>
|
||||
public GraphicsDevice(Device device, AdapterDescription description)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugInterface.Get().EnableDebugLayer();
|
||||
#endif
|
||||
NativeDevice = device;
|
||||
Description = description;
|
||||
WavefrontSize = NativeDevice.D3D12Options1.WaveLaneCountMin;
|
||||
|
||||
NativeComputeCommandQueue = NativeDevice.CreateCommandQueue(new CommandQueueDescription(SharpDX.Direct3D12.CommandListType.Compute));
|
||||
@@ -48,26 +50,9 @@ namespace ComputeSharp.Graphics
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to create a new <see cref="GraphicsDevice"/> instance from the input <see cref="Adapter"/> object
|
||||
/// Gets the available info for the current <see cref="GraphicsDevice"/> instance
|
||||
/// </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;
|
||||
}
|
||||
}
|
||||
public AdapterDescription Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of lanes in a SIMD wave on the current device (also known as "wavefront size" or "warp width")
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
/// </summary>
|
||||
/// <returns>The collection of <see cref="Device"/> objects with support for DX12.1</returns>
|
||||
[Pure]
|
||||
public static IReadOnlyList<Device> QueryAllSupportedDevices()
|
||||
public static IReadOnlyList<(Device, AdapterDescription)> QueryAllSupportedDevices()
|
||||
{
|
||||
using Factory factory = new Factory1();
|
||||
List<Device> devices = new List<Device>();
|
||||
List<(Device, AdapterDescription)> devices = new List<(Device, AdapterDescription)>();
|
||||
|
||||
foreach (Adapter adapter in factory.Adapters)
|
||||
{
|
||||
@@ -26,7 +26,7 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
try
|
||||
{
|
||||
Device device = new Device(adapter, GraphicsDevice.FeatureLevel);
|
||||
devices.Add(device);
|
||||
devices.Add((device, adapter.Description));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Diagnostics.Contracts;
|
||||
using System.Linq;
|
||||
using ComputeSharp.Graphics;
|
||||
using ComputeSharp.Graphics.Helpers;
|
||||
using SharpDX.DXGI;
|
||||
using Device = SharpDX.Direct3D12.Device;
|
||||
|
||||
namespace ComputeSharp
|
||||
@@ -29,7 +30,7 @@ namespace ComputeSharp
|
||||
{
|
||||
if (!IsSupported) throw new NotSupportedException("There isn't a supported GPU device on the current machine");
|
||||
|
||||
return _Default ??= new GraphicsDevice(_Devices.First());
|
||||
return _Default ??= new GraphicsDevice(_Devices[0].Device, _Devices[0].Description);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,9 +39,9 @@ namespace ComputeSharp
|
||||
/// </summary>
|
||||
/// <returns>A sequence of supported <see cref="GraphicsDevice"/> objects that can be used to run compute shaders</returns>
|
||||
[Pure]
|
||||
public static IEnumerable<GraphicsDevice> EnumerateDevices() => _Devices.Select(device => new GraphicsDevice(device));
|
||||
public static IEnumerable<GraphicsDevice> EnumerateDevices() => _Devices.Select(device => new GraphicsDevice(device.Device, device.Description));
|
||||
|
||||
// The loaded collection of supported devices
|
||||
private static IReadOnlyList<Device> _Devices;
|
||||
private static IReadOnlyList<(Device Device, AdapterDescription Description)> _Devices;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする