From c80a55816249fd6b1cfdaed481f7064051483e5f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Tue, 9 Mar 2021 19:05:19 +0100 Subject: [PATCH] Removed Gpu.IsSupported property --- src/ComputeSharp/Gpu.cs | 13 +++++-------- src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs | 14 +------------- tests/ComputeSharp.Tests/InitializationTests.cs | 2 +- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs index affd1d93..a075a6e3 100644 --- a/src/ComputeSharp/Gpu.cs +++ b/src/ComputeSharp/Gpu.cs @@ -15,19 +15,16 @@ namespace ComputeSharp /// private static readonly Lazy DefaultFactory = new(DeviceHelper.GetDefaultDevice); - /// - /// Gets whether or not the APIs can be used on the - /// current machine (ie. if there is at least a supported GPU device). - /// - public static bool IsSupported => DeviceHelper.IsDefaultDeviceAvailable(); - /// /// Gets the default instance for the current machine. /// 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. /// - /// Thrown when a default device is not available. - /// Make sure to check before accessing this property. + /// + /// This device will always be available, even when there isn't a compatible physical GPU + /// or integrated GPU in the system in use. In that case, the WARP device will be used. + /// For more info, see . + /// public static GraphicsDevice Default => DefaultFactory.Value; /// diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs index def2b0c0..b06bf427 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.cs @@ -24,18 +24,6 @@ namespace ComputeSharp.Graphics.Helpers /// private const uint WarpDeviceId = 0x8C; - /// - /// Gets whether or not there is a default device available, without creating it. - /// - /// Whether or not there is a device supporting at least DX12.0. - [Pure] - public static unsafe bool IsDefaultDeviceAvailable() - { - DXGI_ADAPTER_DESC1 dxgiDescription1; - - return TryGetDefaultDevice(null, null, &dxgiDescription1) || TryGetWarpDevice(null, null, &dxgiDescription1); - } - /// /// Gets the of the default device. /// @@ -69,7 +57,7 @@ namespace ComputeSharp.Graphics.Helpers return GetOrCreateDevice(d3D12Device.Get(), dxgiAdapter.Get(), &dxgiDescription1); } - return ThrowHelper.ThrowNotSupportedException("There isn't a supported GPU device on the current machine"); + return ThrowHelper.ThrowNotSupportedException("Failed to retrieve the default device."); } /// diff --git a/tests/ComputeSharp.Tests/InitializationTests.cs b/tests/ComputeSharp.Tests/InitializationTests.cs index 4149d0af..af7e8448 100644 --- a/tests/ComputeSharp.Tests/InitializationTests.cs +++ b/tests/ComputeSharp.Tests/InitializationTests.cs @@ -13,7 +13,7 @@ namespace ComputeSharp.Tests [TestMethod] public void IsSupported() { - Assert.IsTrue(Gpu.IsSupported); + Assert.IsTrue(Gpu.Default is not null); } [CombinatorialTestMethod]