diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs
index 75507597..26ae6399 100644
--- a/src/ComputeSharp/Gpu.cs
+++ b/src/ComputeSharp/Gpu.cs
@@ -21,6 +21,11 @@ namespace ComputeSharp
{
Devices = DeviceHelper.QueryAllSupportedDevices();
IsSupported = Devices.Any();
+
+ if (IsSupported)
+ {
+ _Default = new GraphicsDevice(Devices[0].Device, Devices[0].Description);
+ }
}
///
@@ -28,25 +33,17 @@ namespace ComputeSharp
///
private static readonly IReadOnlyList<(ID3D12Device Device, AdapterDescription Description)> Devices;
- ///
- /// 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 { get; }
-
- private static GraphicsDevice? _Default;
+ private static readonly GraphicsDevice? _Default;
///
/// Gets the default instance for the current machine
///
- public static GraphicsDevice Default
- {
- get
- {
- if (!IsSupported) throw new NotSupportedException("There isn't a supported GPU device on the current machine");
+ public static GraphicsDevice Default => _Default ?? throw new NotSupportedException("There isn't a supported GPU device on the current machine");
- return _Default ??= new GraphicsDevice(Devices[0].Device, Devices[0].Description);
- }
- }
+ ///
+ /// 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 { get; }
///
/// Enumerates all the available objects on the current machine