diff --git a/src/ComputeSharp.WinUI/Controls/ComputeShaderPanel.Rendering.cs b/src/ComputeSharp.WinUI/Controls/ComputeShaderPanel.Rendering.cs index 6f24ae3e..6b25e0a5 100644 --- a/src/ComputeSharp.WinUI/Controls/ComputeShaderPanel.Rendering.cs +++ b/src/ComputeSharp.WinUI/Controls/ComputeShaderPanel.Rendering.cs @@ -2,6 +2,7 @@ using System.Diagnostics; using System.Threading; using ComputeSharp.Core.Extensions; +using ComputeSharp.Graphics.Helpers; using ComputeSharp.Interop; using ComputeSharp.WinUI.Helpers; using TerraFX.Interop.DirectX; @@ -186,9 +187,9 @@ public sealed partial class ComputeShaderPanel } // Create the swap chain to display frames - using (ComPtr dxgiFactory2 = default) + using (ComPtr dxgiFactory6 = default) { - DirectX.CreateDXGIFactory2(DXGI.DXGI_CREATE_FACTORY_DEBUG, Win32.__uuidof(), (void**)dxgiFactory2.GetAddressOf()).Assert(); + DeviceHelper.CreateDXGIFactory6(dxgiFactory6.GetAddressOf()); DXGI_SWAP_CHAIN_DESC1 dxgiSwapChainDesc1 = default; dxgiSwapChainDesc1.AlphaMode = DXGI_ALPHA_MODE.DXGI_ALPHA_MODE_IGNORE; @@ -205,7 +206,7 @@ public sealed partial class ComputeShaderPanel using ComPtr dxgiSwapChain1 = default; - dxgiFactory2.Get()->CreateSwapChainForComposition( + dxgiFactory6.Get()->CreateSwapChainForComposition( (IUnknown*)this.d3D12CommandQueue.Get(), &dxgiSwapChainDesc1, null, diff --git a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs index 6f7314e1..c5ab0b64 100644 --- a/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs +++ b/src/ComputeSharp/Graphics/Helpers/DeviceHelper.IDXGIFactory6.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Runtime.InteropServices; using ComputeSharp.Core.Extensions; using TerraFX.Interop.DirectX; @@ -31,11 +30,13 @@ internal static partial class DeviceHelper /// Creates a new instance to be used to enumerate devices. /// /// The resulting instance. - private static unsafe void CreateDXGIFactory6(IDXGIFactory6** dxgiFactory6) + internal static unsafe void CreateDXGIFactory6(IDXGIFactory6** dxgiFactory6) { using ComPtr dxgiFactory4 = default; +#if DEBUG EnableDebugMode(); +#endif DirectX.CreateDXGIFactory2(IDXGIFactoryCreationFlags, Windows.__uuidof(), dxgiFactory4.GetVoidAddressOf()).Assert(); @@ -58,10 +59,10 @@ internal static partial class DeviceHelper return; } +#if DEBUG /// /// Enables the debug layer for DirectX APIs. /// - [Conditional("DEBUG")] private static unsafe void EnableDebugMode() { using ComPtr d3D12Debug = default; @@ -77,6 +78,7 @@ internal static partial class DeviceHelper d3D12Debug1.Get()->SetEnableSynchronizedCommandQueueValidation(Windows.TRUE); } } +#endif /// /// A custom fallback implementation to use on systems with no support for it.