DX11: DXGI debug layers.

This commit is contained in:
Branimir Karadžić 2015-07-29 14:49:24 -07:00
parent a56ded38ed
commit 874ff3c155
2 changed files with 41 additions and 7 deletions

View file

@ -73,6 +73,8 @@ namespace bgfx
typedef void (WINAPI* PFN_D3DPERF_SET_OPTIONS)(DWORD _options); typedef void (WINAPI* PFN_D3DPERF_SET_OPTIONS)(DWORD _options);
typedef DWORD (WINAPI* PFN_D3DPERF_GET_STATUS)(); typedef DWORD (WINAPI* PFN_D3DPERF_GET_STATUS)();
typedef HRESULT (WINAPI* PFN_CREATE_DXGI_FACTORY)(REFIID _riid, void** _factory); 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_SETMARKER(_col, _name) D3DPERF_SetMarker(_col, _name)
#define _PIX_BEGINEVENT(_col, _name) D3DPERF_BeginEvent(_col, _name) #define _PIX_BEGINEVENT(_col, _name) D3DPERF_BeginEvent(_col, _name)

View file

@ -436,11 +436,13 @@ namespace bgfx { namespace d3d11
}; };
#if USE_D3D11_DYNAMIC_LIB #if USE_D3D11_DYNAMIC_LIB
static PFN_D3D11_CREATE_DEVICE D3D11CreateDevice; static PFN_D3D11_CREATE_DEVICE D3D11CreateDevice;
static PFN_CREATE_DXGI_FACTORY CreateDXGIFactory; static PFN_CREATE_DXGI_FACTORY CreateDXGIFactory;
static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker; static PFN_D3DPERF_SET_MARKER D3DPERF_SetMarker;
static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent; static PFN_D3DPERF_BEGIN_EVENT D3DPERF_BeginEvent;
static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent; static PFN_D3DPERF_END_EVENT D3DPERF_EndEvent;
static PFN_GET_DEBUG_INTERFACE DXGIGetDebugInterface;
static PFN_GET_DEBUG_INTERFACE1 DXGIGetDebugInterface1;
#endif // USE_D3D11_DYNAMIC_LIB #endif // USE_D3D11_DYNAMIC_LIB
struct RendererContextD3D11 : public RendererContextI struct RendererContextD3D11 : public RendererContextI
@ -449,6 +451,7 @@ namespace bgfx { namespace d3d11
: m_d3d9dll(NULL) : m_d3d9dll(NULL)
, m_d3d11dll(NULL) , m_d3d11dll(NULL)
, m_dxgidll(NULL) , m_dxgidll(NULL)
, m_dxgidebugdll(NULL)
, m_renderdocdll(NULL) , m_renderdocdll(NULL)
, m_driverType(D3D_DRIVER_TYPE_NULL) , m_driverType(D3D_DRIVER_TYPE_NULL)
, m_featureLevel(D3D_FEATURE_LEVEL(0) ) , m_featureLevel(D3D_FEATURE_LEVEL(0) )
@ -531,6 +534,23 @@ namespace bgfx { namespace d3d11
CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)bx::dlsym(m_dxgidll, "CreateDXGIFactory"); CreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY)bx::dlsym(m_dxgidll, "CreateDXGIFactory");
BGFX_FATAL(NULL != CreateDXGIFactory, Fatal::UnableToInitialize, "Function CreateDXGIFactory not found."); 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 #endif // USE_D3D11_DYNAMIC_LIB
HRESULT hr; HRESULT hr;
@ -721,7 +741,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (SUCCEEDED(hr) ) if (SUCCEEDED(hr) )
{ {
setGraphicsDebuggerPresent(true); setGraphicsDebuggerPresent(true);
// DX_RELEASE(renderdoc, 0); DX_RELEASE(renderdoc, 2);
} }
else else
{ {
@ -814,7 +834,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
if (SUCCEEDED(hr) ) if (SUCCEEDED(hr) )
{ {
m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_CORRUPTION, true); 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); m_infoQueue->SetBreakOnSeverity(D3D11_MESSAGE_SEVERITY_WARNING, false);
D3D11_INFO_QUEUE_FILTER filter; D3D11_INFO_QUEUE_FILTER filter;
@ -1108,9 +1128,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
unloadRenderDoc(m_renderdocdll); unloadRenderDoc(m_renderdocdll);
#if USE_D3D11_DYNAMIC_LIB #if USE_D3D11_DYNAMIC_LIB
if (NULL != m_dxgidebugdll)
{
bx::dlclose(m_dxgidebugdll);
m_dxgidebugdll = NULL;
}
bx::dlclose(m_dxgidll); bx::dlclose(m_dxgidll);
m_dxgidll = NULL;
bx::dlclose(m_d3d9dll); bx::dlclose(m_d3d9dll);
m_d3d9dll = NULL;
bx::dlclose(m_d3d11dll); bx::dlclose(m_d3d11dll);
m_d3d11dll = NULL;
#endif // USE_D3D11_DYNAMIC_LIB #endif // USE_D3D11_DYNAMIC_LIB
} }
@ -2615,6 +2646,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
void* m_d3d9dll; void* m_d3d9dll;
void* m_d3d11dll; void* m_d3d11dll;
void* m_dxgidll; void* m_dxgidll;
void* m_dxgidebugdll;
void* m_renderdocdll; void* m_renderdocdll;