Преглед изворни кода

Detect RenderDoc presence when it's injected.

Branimir Karadžić пре 10 година
родитељ
комит
1aea6fc415
2 измењених фајлова са 17 додато и 2 уклоњено
  1. 13 2
      src/renderer_d3d11.cpp
  2. 4 0
      src/renderer_gl.cpp

+ 13 - 2
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.");

+ 4 - 0
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;