From 1aea6fc4154d40a1ab8158b4e6c8ca23959abbab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Fri, 8 May 2015 11:49:18 -0700 Subject: [PATCH] Detect RenderDoc presence when it's injected. --- src/renderer_d3d11.cpp | 15 +++++++++++++-- src/renderer_gl.cpp | 4 ++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index b1f924dc..cc71e475 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -348,6 +348,7 @@ namespace bgfx { namespace d3d11 static const GUID IID_IDXGIDevice3 = { 0x6007896c, 0x3244, 0x4afd, { 0xbf, 0x18, 0xa6, 0xd3, 0xbe, 0xda, 0x50, 0x23 } }; static const GUID IID_IDXGIAdapter = { 0x2411e7e1, 0x12ac, 0x4ccf, { 0xbd, 0x14, 0x97, 0x98, 0xe8, 0x53, 0x4d, 0xc0 } }; static const GUID IID_ID3D11InfoQueue = { 0x6543dbb6, 0x1b48, 0x42f5, { 0xab, 0x82, 0xe9, 0x7e, 0xc7, 0x43, 0x26, 0xf6 } }; + static const GUID IID_IDXGIDeviceRenderDoc = { 0xa7aa6116, 0x9c8d, 0x4bba, { 0x90, 0x83, 0xb4, 0xd8, 0x16, 0xb7, 0x1b, 0x78 } }; enum D3D11_FORMAT_SUPPORT2 { @@ -707,8 +708,18 @@ BX_PRAGMA_DIAGNOSTIC_POP(); // // This causes assert in debug. When debugger is present refcount // checks are off. - setGraphicsDebuggerPresent(2 != getRefCount(device) ); - DX_RELEASE(device, 2); + IDXGIDevice* renderdoc; + hr = m_device->QueryInterface(IID_IDXGIDeviceRenderDoc, (void**)&renderdoc); + if (SUCCEEDED(hr) ) + { + setGraphicsDebuggerPresent(true); + DX_RELEASE(renderdoc, 0); + } + else + { + setGraphicsDebuggerPresent(2 != getRefCount(device) ); + DX_RELEASE(device, 2); + } hr = adapter->GetDesc(&m_adapterDesc); BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 device."); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 41560c6d..62014059 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -429,6 +429,7 @@ namespace bgfx { namespace gl EXT_compressed_ETC1_RGB8_sub_texture, EXT_debug_label, EXT_debug_marker, + EXT_debug_tool, EXT_discard_framebuffer, EXT_disjoint_timer_query, EXT_draw_buffers, @@ -621,6 +622,7 @@ namespace bgfx { namespace gl { "EXT_compressed_ETC1_RGB8_sub_texture", false, true }, // GLES2 extension. { "EXT_debug_label", false, true }, { "EXT_debug_marker", false, true }, + { "EXT_debug_tool", false, true }, // RenderDoc extension. { "EXT_discard_framebuffer", false, true }, // GLES2 extension. { "EXT_disjoint_timer_query", false, true }, // GLES2 extension. { "EXT_draw_buffers", false, true }, // GLES2 extension. @@ -1621,6 +1623,8 @@ namespace bgfx { namespace gl ; } + setGraphicsDebuggerPresent(s_extension[Extension::EXT_debug_tool].m_supported); + if (NULL == glObjectLabel) { glObjectLabel = stubObjectLabel;