From 27a5410a729636fec19550fe58200704e0ee9d75 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 25 Jul 2022 00:14:54 +0200 Subject: [PATCH] Ensure same graphics device is used --- src/ComputeSharp.UI/Helpers/SwapChainManager.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs index c0a9e85b..54ef9d84 100644 --- a/src/ComputeSharp.UI/Helpers/SwapChainManager.cs +++ b/src/ComputeSharp.UI/Helpers/SwapChainManager.cs @@ -49,6 +49,11 @@ internal sealed unsafe partial class SwapChainManager : NativeObject /// private readonly TOwner owner; + /// + /// The instance in use. + /// + private readonly GraphicsDevice device; + /// /// The captured for the current instance. /// @@ -216,6 +221,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject public SwapChainManager(TOwner owner) { this.owner = owner; + this.device = GraphicsDevice.GetDefault(); // 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. @@ -239,7 +245,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject // Get the underlying ID3D12Device in use fixed (ID3D12Device** d3D12Device = this.d3D12Device) { - GraphicsDevice.GetDefault().D3D12Device->QueryInterface(Win32.__uuidof(), (void**)d3D12Device).Assert(); + this.device.D3D12Device->QueryInterface(Win32.__uuidof(), (void**)d3D12Device).Assert(); } // Create the direct command queue to use @@ -394,7 +400,7 @@ internal sealed unsafe partial class SwapChainManager : NativeObject // Dispose the previous texture, if present, and create the new 2D texture to use to generate frames to display this.texture?.Dispose(); - this.texture = GraphicsDevice.GetDefault().AllocateReadWriteTexture2D((int)resizedWidth, (int)resizeHeight); + this.texture = this.device.AllocateReadWriteTexture2D((int)resizedWidth, (int)resizeHeight); } }