diff --git a/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.cs b/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.cs
index 8265c55b..9c3710ae 100644
--- a/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.cs
+++ b/src/ComputeSharp.UI/Controls/AnimatedComputeShaderPanel.cs
@@ -34,9 +34,18 @@ public sealed partial class AnimatedComputeShaderPanel : SwapChainPanel, IDispos
///
/// Creates a new instance.
///
- public unsafe AnimatedComputeShaderPanel()
+ public AnimatedComputeShaderPanel()
+ : this(GraphicsDevice.GetDefault())
{
- this.swapChainManager = new SwapChainManager(this);
+ }
+
+ ///
+ /// Creates a new instance.
+ ///
+ /// The instance to use to render frames.
+ public AnimatedComputeShaderPanel(GraphicsDevice device)
+ {
+ this.swapChainManager = new SwapChainManager(this, device);
this.Loaded += AnimatedComputeShaderPanel_Loaded;
this.Unloaded += AnimatedComputeShaderPanel_Unloaded;
diff --git a/src/ComputeSharp.UI/Controls/ComputeShaderPanel.cs b/src/ComputeSharp.UI/Controls/ComputeShaderPanel.cs
index af51a4bd..fae6d793 100644
--- a/src/ComputeSharp.UI/Controls/ComputeShaderPanel.cs
+++ b/src/ComputeSharp.UI/Controls/ComputeShaderPanel.cs
@@ -34,9 +34,18 @@ public sealed partial class ComputeShaderPanel : SwapChainPanel, IDisposable
///
/// Creates a new instance.
///
- public unsafe ComputeShaderPanel()
+ public ComputeShaderPanel()
+ : this(GraphicsDevice.GetDefault())
{
- this.swapChainManager = new SwapChainManager(this);
+ }
+
+ ///
+ /// Creates a new instance.
+ ///
+ /// The instance to use to render frames.
+ public ComputeShaderPanel(GraphicsDevice device)
+ {
+ this.swapChainManager = new SwapChainManager(this, device);
this.Loaded += ComputeShaderPanel_Loaded;
this.Unloaded += ComputeShaderPanel_Unloaded;
diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
index 0e82cbc5..279df0c2 100644
--- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
+++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs
@@ -231,10 +231,11 @@ internal sealed unsafe partial class SwapChainManager : NativeObject
/// Initializes a new instance of the type.
///
/// The input swap chain instance being used.
- public SwapChainManager(TOwner owner)
+ /// The instance to use to render frames.
+ public SwapChainManager(TOwner owner, GraphicsDevice device)
{
this.owner = owner;
- this.device = GraphicsDevice.GetDefault();
+ this.device = device;
// Extract the ISwapChainPanelNative reference from the current panel, then query the
// IDXGISwapChain reference just created and set that as the swap chain panel to use.