diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownKeywords.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownKeywords.cs
index 32f85dad..4e7dd21e 100644
--- a/src/ComputeSharp.Shaders/Mappings/HlslKnownKeywords.cs
+++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownKeywords.cs
@@ -24,7 +24,7 @@ namespace ComputeSharp.Shaders.Mappings
"unsigned", "vector", "vertexfragment", "zero"
};
- private static Regex _KeywordsRegex;
+ private static Regex? _KeywordsRegex;
///
/// The to use to match variable names
diff --git a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs
index 4c0cc9b5..930c9caa 100644
--- a/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs
+++ b/src/ComputeSharp.Shaders/Mappings/HlslKnownMethods.cs
@@ -13,7 +13,7 @@ namespace ComputeSharp.Shaders.Mappings
///
internal static class HlslKnownMethods
{
- private static IReadOnlyDictionary _KnownMethods;
+ private static IReadOnlyDictionary? _KnownMethods;
///
/// The mapping of supported known methods to HLSL methods
diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs
index f6971963..79520bcf 100644
--- a/src/ComputeSharp/Gpu.cs
+++ b/src/ComputeSharp/Gpu.cs
@@ -14,12 +14,17 @@ namespace ComputeSharp
///
public static class Gpu
{
+ ///
+ /// The loaded collection of supported devices and descriptions
+ ///
+ private static 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; } = (_Devices = DeviceHelper.QueryAllSupportedDevices()).Any();
- private static GraphicsDevice _Default;
+ private static GraphicsDevice? _Default;
///
/// Gets the default instance for the current machine
@@ -30,7 +35,7 @@ namespace ComputeSharp
{
if (!IsSupported) throw new NotSupportedException("There isn't a supported GPU device on the current machine");
- return _Default ??= new GraphicsDevice(_Devices[0].Device, _Devices[0].Description);
+ return _Default ??= new GraphicsDevice(_Devices![0].Device, _Devices[0].Description);
}
}
@@ -40,8 +45,5 @@ namespace ComputeSharp
/// A sequence of supported objects that can be used to run compute shaders
[Pure]
public static IEnumerable EnumerateDevices() => _Devices.Select(device => new GraphicsDevice(device.Device, device.Description));
-
- // The loaded collection of supported devices
- private static IReadOnlyList<(ID3D12Device Device, AdapterDescription Description)> _Devices;
}
}