Browse Source

add directx debug switch

Kolja Strohm 2 years ago
parent
commit
6737a6cd05
4 changed files with 19 additions and 5 deletions
  1. 2 1
      DX11GraphicsApi.cpp
  2. 8 4
      DX12GraphicsApi.cpp
  3. 6 0
      Global.cpp
  4. 3 0
      Globals.h

+ 2 - 1
DX11GraphicsApi.cpp

@@ -183,7 +183,8 @@ void DirectX11::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
     // create a device, device context and swap chain using the information in the scd struct
     UINT flag = 0;
 #ifdef _DEBUG
-    flag |= D3D11_CREATE_DEVICE_DEBUG;
+    if( debugDX )
+        flag |= D3D11_CREATE_DEVICE_DEBUG;
 #endif
     HRESULT result = createDeviceAndSwapChain( NULL,
                                                D3D_DRIVER_TYPE_HARDWARE,

+ 8 - 4
DX12GraphicsApi.cpp

@@ -165,14 +165,18 @@ void DirectX12::initialize( WFenster *fenster, Vec2<int> backBufferSize, bool fu
     D3D12SerializeVersionedRootSignatureFunction d3d12svrsf = (D3D12SerializeVersionedRootSignatureFunction)GetProcAddress( d3d12DLL, "D3D12SerializeVersionedRootSignature" );
     D3D12SerializeRootSignatureFunction d3d12srsf = (D3D12SerializeRootSignatureFunction)GetProcAddress( d3d12DLL, "D3D12SerializeRootSignature" );
 #ifdef _DEBUG
-    D3D12GetDebugInterfaceFunction getDebugInterface = (D3D12GetDebugInterfaceFunction)GetProcAddress( d3d12DLL, "D3D12GetDebugInterface" );
-    getDebugInterface( __uuidof( ID3D12Debug ), (void **)&debug );
-    debug->EnableDebugLayer();
+    if( debugDX )
+    {
+        D3D12GetDebugInterfaceFunction getDebugInterface = (D3D12GetDebugInterfaceFunction)GetProcAddress( d3d12DLL, "D3D12GetDebugInterface" );
+        getDebugInterface( __uuidof(ID3D12Debug), (void**)&debug );
+        debug->EnableDebugLayer();
+    }
 #endif
     IDXGIFactory4 *factory;
     UINT createFactoryFlags = 0;
 #if defined(_DEBUG)
-    createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
+    if( debugDX )
+        createFactoryFlags = DXGI_CREATE_FACTORY_DEBUG;
 #endif
     HRESULT res = createFactory( createFactoryFlags, __uuidof( IDXGIFactory4 ), (void **)&factory );
     if( FAILED( res ) )

+ 6 - 0
Global.cpp

@@ -140,6 +140,12 @@ Framework::DLLRegister *Framework::getDLLRegister()
     return Framework::dlls;
 }
 
+//! Versetzt DirectX in den Debug modus
+void Framework::setDebugDX( bool debug )
+{
+    debugDX = debug;
+}
+
 #ifdef WIN32
 // gibt eine Referenz auf die Maus zurück
 Framework::Maus &Framework::getMaus()

+ 3 - 0
Globals.h

@@ -39,6 +39,7 @@ namespace Framework
     Global Critical logC;
     Global HINSTANCE__ *_hinst;
     Global DLLRegister *dlls;
+    Global bool debugDX;
 
 #ifdef WIN32
     //! Gibt die Koordinaten der Maus auf dem Bildschirm zurück
@@ -78,6 +79,8 @@ namespace Framework
     DLLEXPORT void logLine( char *txt );
     //! Gibt das DLL Register zurück, in dem alle zurzeit dynamisch geladenen DLL Dateien hinterlegt sind
     DLLEXPORT DLLRegister *getDLLRegister();
+    //! Versetzt DirectX in den Debug modus
+    DLLEXPORT void setDebugDX(bool debug);
 #ifdef WIN32
     //! gibt eine Referenz auf die Maus zurück
     DLLEXPORT Maus &getMaus();