diff --git a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs index 242f51bd..41dbd338 100644 --- a/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs +++ b/src/ComputeSharp/Graphics/GraphicsDevice.GetDevice.cs @@ -20,6 +20,42 @@ partial class GraphicsDevice /// public static GraphicsDevice Default => DeviceHelper.DefaultFactory.Value; + /// + /// Gets or creates the default instance for the current machine. + /// + /// The default define is the first device supporting the required feature level that could + /// be created when enumerating the available adapters in performance order. That is, it is + /// conceptually equivalent to the first successfully created device from . + /// + /// + /// The default instance for the current machine. + /// + /// The returned is cached across multiple invocations. In order to + /// support device lost scenarios (see ) and due to how the DirectX 12 + /// runtime handles caching of device instances, this method has the following behavior: + /// + /// If no device has been created, create the default one, cache it, and return it. + /// If a cached device is available, return that. + /// If the returned device is disposed, the cache is reset. + /// + /// If is called again after that, the returned device might map to a different adapter. + /// This would be the case if the first device was lost due to the adapter being removed from the system. + /// + /// + /// There is one additional caveat to the list above: if is called, then that device is lost, then + /// the returned instance is disposed incorrectly (eg. with some existing resources not being + /// disposed, which would keep the underlying device object alive), calling again will result in + /// an exception instead of a different device being returned. That is, if enumerating adapters and trying to create a device + /// fails due to device lost (as opposed to other valid failures when trying to normally create a device), an exception will be + /// thrown instead of just skipping that adapter, because that would mean a device had been created but incorrectly disposed. + /// + /// Thrown if the target device was lost and incorrectly disposed (see remarks). + /// Thrown if no adapter could be created (this should never be the case). + public static GraphicsDevice GetDefault() + { + throw new NotImplementedException(); + } + /// /// Enumerates all the currently available devices supporting the minimum necessary feature level. /// Physical devices and integrated GPUs will be enumerated first, and the WARP device will always be last.