From 874ff3c15564b2c78f473aa28d4206e8ab981074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 29 Jul 2015 14:49:24 -0700 Subject: [PATCH] DX11: DXGI debug layers. --- src/renderer_d3d.h | 2 ++ src/renderer_d3d11.cpp | 46 +++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/renderer_d3d.h b/src/renderer_d3d.h index 596dd667..88e79e9a 100644 --- a/src/renderer_d3d.h +++ b/src/renderer_d3d.h @@ -73,6 +73,8 @@ namespace bgfx typedef void (WINAPI* PFN_D3DPERF_SET_OPTIONS)(DWORD _options); typedef DWORD (WINAPI* PFN_D3DPERF_GET_STATUS)(); typedef HRESULT (WINAPI* PFN_CREATE_DXGI_FACTORY)(REFIID _riid, void** _factory); + typedef HRESULT (WINAPI* PFN_GET_DEBUG_INTERFACE)(REFIID _riid, void** _debug); + typedef HRESULT (WINAPI* PFN_GET_DEBUG_INTERFACE1)(UINT _flags, REFIID _riid, void** _debug); #define _PIX_SETMARKER(_col, _name) D3DPERF_SetMarker(_col, _name) #define _PIX_BEGINEVENT(_col, _name) D3DPERF_BeginEvent(_col, _name) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index 89e5085a..bbb575a6 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -436,11 +436,13 @@ namespace bgfx { namespace d3d11 }; #if USE_D3D11_DYNAMIC_LIB - static PFN_D3D11_CREATE_DEVICE D3D11CreateDevice; - static PFN_CREATE_DXGI_FACTORY CreateDXGIFactory; - static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker; - static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent; - static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent; + static PFN_D3D11_CREATE_DEVICE D3D11CreateDevice; + static PFN_CREATE_DXGI_FACTORY CreateDXGIFactory; + static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker; + static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent; + static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent; + static PFN_GET_DEBUG_INTERFACE DXGIGetDebugInterface; + static PFN_GET_DEBUG_INTERFACE1 DXGIGetDebugInterface1; #endif // USE_D3D11_DYNAMIC_LIB struct RendererContextD3D11 : public RendererContextI @@ -449,6 +451,7 @@ namespace bgfx { namespace d3d11 : m_d3d9dll(NULL) , m_d3d11dll(NULL) , m_dxgidll(NULL) + , m_dxgidebugdll(NULL) , m_renderdocdll(NULL) , m_driverType(D3D_DRIVER_TYPE_NULL) , m_featureLevel(D3D_FEATURE_LEVEL(0) ) @@ -531,6 +534,23 @@ namespace bgfx { namespace d3d11 CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)bx::dlsym(m_dxgidll, "CreateDXGIFactory"); BGFX_FATAL(NULL != CreateDXGIFactory, Fatal::UnableToInitialize, "Function CreateDXGIFactory not found."); + + m_dxgidebugdll = bx::dlopen("dxgidebug.dll"); + if (NULL != m_dxgidebugdll) + { + DXGIGetDebugInterface = (PFN_GET_DEBUG_INTERFACE )bx::dlsym(m_dxgidebugdll, "DXGIGetDebugInterface"); + DXGIGetDebugInterface1 = (PFN_GET_DEBUG_INTERFACE1)bx::dlsym(m_dxgidebugdll, "DXGIGetDebugInterface1"); + if (NULL == DXGIGetDebugInterface + && NULL == DXGIGetDebugInterface1) + { + bx::dlclose(m_dxgidebugdll); + m_dxgidebugdll = NULL; + } + else + { + // Figure out how to access IDXGIInfoQueue on pre Win8... + } + } #endif // USE_D3D11_DYNAMIC_LIB HRESULT hr; @@ -721,7 +741,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (SUCCEEDED(hr) ) { setGraphicsDebuggerPresent(true); -// DX_RELEASE(renderdoc, 0); + DX_RELEASE(renderdoc, 2); } else { @@ -814,7 +834,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); if (SUCCEEDED(hr) ) { m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); - m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, false); + m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_ERROR, true); m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, false); D3D11_INFO_QUEUE_FILTER filter; @@ -1108,9 +1128,20 @@ BX_PRAGMA_DIAGNOSTIC_POP(); unloadRenderDoc(m_renderdocdll); #if USE_D3D11_DYNAMIC_LIB + if (NULL != m_dxgidebugdll) + { + bx::dlclose(m_dxgidebugdll); + m_dxgidebugdll = NULL; + } + bx::dlclose(m_dxgidll); + m_dxgidll = NULL; + bx::dlclose(m_d3d9dll); + m_d3d9dll = NULL; + bx::dlclose(m_d3d11dll); + m_d3d11dll = NULL; #endif // USE_D3D11_DYNAMIC_LIB } @@ -2615,6 +2646,7 @@ BX_PRAGMA_DIAGNOSTIC_POP(); void* m_d3d9dll; void* m_d3d11dll; void* m_dxgidll; + void* m_dxgidebugdll; void* m_renderdocdll;