Unified fallback device initialization
このコミットが含まれているのは:
1 親
f0e1a6ded7
コミット
606faa70c9
3ファイル変更
+4
-88
検索条件に一致するファイルはありません
@@ -23,7 +23,7 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 dxgiDescription1;
|
||||
|
||||
return TryGetDefaultDevice(null, &dxgiDescription1);
|
||||
return TryGetDefaultDevice(null, &dxgiDescription1) || TryGetWarpDevice(null, &dxgiDescription1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +36,7 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
{
|
||||
DXGI_ADAPTER_DESC1 dxgiDescription1;
|
||||
|
||||
_ = TryGetDefaultDevice(null, &dxgiDescription1);
|
||||
_ = TryGetDefaultDevice(null, &dxgiDescription1) || TryGetWarpDevice(null, &dxgiDescription1);
|
||||
|
||||
return Luid.FromLUID(dxgiDescription1.AdapterLuid);
|
||||
}
|
||||
@@ -52,7 +52,8 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
|
||||
DXGI_ADAPTER_DESC1 dxgiDescription1;
|
||||
|
||||
if (TryGetDefaultDevice(d3D12Device.GetAddressOf(), &dxgiDescription1))
|
||||
if (TryGetDefaultDevice(d3D12Device.GetAddressOf(), &dxgiDescription1) ||
|
||||
TryGetWarpDevice(d3D12Device.GetAddressOf(), &dxgiDescription1))
|
||||
{
|
||||
return GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1);
|
||||
}
|
||||
@@ -60,25 +61,6 @@ namespace ComputeSharp.Graphics.Helpers
|
||||
return ThrowHelper.ThrowNotSupportedException<GraphicsDevice>("There isn't a supported GPU device on the current machine");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the warp <see cref="GraphicsDevice"/> instance.
|
||||
/// </summary>
|
||||
/// <returns>The default <see cref="GraphicsDevice"/> instance supporting at least DX12.0.</returns>
|
||||
/// <exception cref="NotSupportedException">Thrown when a default device is not available.</exception>
|
||||
public static unsafe GraphicsDevice GetWarpDevice()
|
||||
{
|
||||
using ComPtr<ID3D12Device> d3D12Device = default;
|
||||
|
||||
DXGI_ADAPTER_DESC1 dxgiDescription1;
|
||||
|
||||
if (TryGetWarpDevice(d3D12Device.GetAddressOf(), &dxgiDescription1))
|
||||
{
|
||||
return GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1);
|
||||
}
|
||||
|
||||
return ThrowHelper.ThrowNotSupportedException<GraphicsDevice>("There isn't a supported device on the current machine");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tries to check or create a default <see cref="ID3D12Device"/> object.
|
||||
/// </summary>
|
||||
|
||||
@@ -16,11 +16,6 @@ namespace ComputeSharp
|
||||
/// </summary>
|
||||
private static readonly Lazy<GraphicsDevice> DefaultFactory = new(DeviceHelper.GetDefaultDevice);
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Lazy{T}"/> instance used to produce the warp device for <see cref="Fallback"/>.
|
||||
/// </summary>
|
||||
private static readonly Lazy<GraphicsDevice> WarpFactory = new(DeviceHelper.GetWarpDevice);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether or not the <see cref="Gpu"/> APIs can be used on the
|
||||
/// current machine (ie. if there is at least a supported GPU device).
|
||||
@@ -36,15 +31,6 @@ namespace ComputeSharp
|
||||
/// <remarks>Make sure to check <see cref="IsSupported"/> before accessing this property.</remarks>
|
||||
public static GraphicsDevice Default => DefaultFactory.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fallback <see cref="GraphicsDevice"/> instance for the current machine.
|
||||
/// This is a software version of a device that can be used when no supported GPU is available.
|
||||
/// This instance cannot be manually disposed - attempting to do so is safe and it will
|
||||
/// not cause an exception, but it will simply do nothing and not dispose the device.
|
||||
/// </summary>
|
||||
/// <exception cref="NotSupportedException">Thrown when a fallback device is not available.</exception>
|
||||
public static GraphicsDevice Fallback => WarpFactory.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Enumerates all the currently available DX12.0 devices. Note that creating a device is a relatively
|
||||
/// expensive operation, so consider using <see cref="QueryDevices"/> to be able to filter the available
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする