From 4b9253dc762c841cb2f64f7f167e498700ec7f6f Mon Sep 17 00:00:00 2001 From: reuk Date: Wed, 27 Nov 2024 16:54:41 +0000 Subject: [PATCH] DirectX: Make it easier to enable debug logging output --- modules/juce_graphics/native/juce_DirectX_windows.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/juce_graphics/native/juce_DirectX_windows.h b/modules/juce_graphics/native/juce_DirectX_windows.h index 2e911b9c59..516d20248e 100644 --- a/modules/juce_graphics/native/juce_DirectX_windows.h +++ b/modules/juce_graphics/native/juce_DirectX_windows.h @@ -35,6 +35,8 @@ namespace juce { +constexpr auto enableDirectXDebugLayer = false; + struct DxgiAdapter : public ReferenceCountedObject { using Ptr = ReferenceCountedObjectPtr; @@ -60,7 +62,8 @@ struct DxgiAdapter : public ReferenceCountedObject // This flag adds support for surfaces with a different color channel ordering // than the API default. It is required for compatibility with Direct2D. - const auto creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT; + const auto creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT + | (enableDirectXDebugLayer ? D3D11_CREATE_DEVICE_DEBUG : 0); if (const auto hr = D3D11CreateDevice (result->dxgiAdapter, D3D_DRIVER_TYPE_UNKNOWN, @@ -266,7 +269,7 @@ private: ComSmartPtr d2dSharedFactory = [&] { D2D1_FACTORY_OPTIONS options; - options.debugLevel = D2D1_DEBUG_LEVEL_NONE; + options.debugLevel = enableDirectXDebugLayer ? D2D1_DEBUG_LEVEL_INFORMATION : D2D1_DEBUG_LEVEL_NONE; JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE ("-Wlanguage-extension-token") ComSmartPtr result; auto hr = D2D1CreateFactory (D2D1_FACTORY_TYPE_MULTI_THREADED,