Added opportunistic optimized path for default LUID retrieval

このコミットが含まれているのは:
Sergio Pedri committed 2021-03-11 15:36:35 +01:00
1 親 f6e950f42e
コミット 5d87fa910b
2ファイル変更
+12 -7

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

+1 -6
ファイルの表示
@@ -10,11 +10,6 @@ namespace ComputeSharp
/// </summary>
public static class Gpu
{
/// <summary>
/// The <see cref="Lazy{T}"/> instance used to produce the default device for <see cref="Default"/>.
/// </summary>
private static readonly Lazy<GraphicsDevice> DefaultFactory = new(DeviceHelper.GetDefaultDevice);
/// <summary>
/// Gets the default <see cref="GraphicsDevice"/> instance for the current machine.
/// This instance cannot be manually disposed - attempting to do so is safe and it will
@@ -25,7 +20,7 @@ namespace ComputeSharp
/// or integrated GPU in the system in use. In that case, the WARP device will be used.
/// For more info, see <see href="https://docs.microsoft.com/windows/win32/direct3darticles/directx-warp"/>.
/// </remarks>
public static GraphicsDevice Default => DefaultFactory.Value;
public static GraphicsDevice Default => DeviceHelper.DefaultFactory.Value;
/// <summary>
/// Enumerates all the currently available devices supporting the minimum necessary feature level.
+11 -1
ファイルの表示
@@ -27,6 +27,11 @@ namespace ComputeSharp.Graphics.Helpers
/// </summary>
private const uint WarpDeviceId = 0x8C;
/// <summary>
/// The <see cref="Lazy{T}"/> instance used to produce the default <see cref="GraphicsDevice"/> instance.
/// </summary>
public static readonly Lazy<GraphicsDevice> DefaultFactory = new(GetDefaultDevice);
/// <summary>
/// Gets the <see cref="Luid"/> of the default device.
/// </summary>
@@ -35,6 +40,11 @@ namespace ComputeSharp.Graphics.Helpers
[Pure]
public static unsafe Luid GetDefaultDeviceLuid()
{
if (DefaultFactory.IsValueCreated)
{
return DefaultFactory.Value.Luid;
}
DXGI_ADAPTER_DESC1 dxgiDescription1;
_ = TryGetDefaultDevice(null, null, &dxgiDescription1) || TryGetWarpDevice(null, null, &dxgiDescription1);
@@ -47,7 +57,7 @@ namespace ComputeSharp.Graphics.Helpers
/// </summary>
/// <returns>The default <see cref="GraphicsDevice"/> instance supporting <see cref="D3D_FEATURE_LEVEL_11_0"/> and <see cref="D3D_SHADER_MODEL_6_0"/>.</returns>
/// <exception cref="NotSupportedException">Thrown when a default device is not available.</exception>
public static unsafe GraphicsDevice GetDefaultDevice()
private static unsafe GraphicsDevice GetDefaultDevice()
{
using ComPtr<ID3D12Device> d3D12Device = default;
using ComPtr<IDXGIAdapter> dxgiAdapter = default;