summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/src/debug_renderdoc.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/src/debug_renderdoc.cpp')
-rw-r--r--3rdparty/bgfx/src/debug_renderdoc.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/3rdparty/bgfx/src/debug_renderdoc.cpp b/3rdparty/bgfx/src/debug_renderdoc.cpp
index 35fc2ab05ce..053df044375 100644
--- a/3rdparty/bgfx/src/debug_renderdoc.cpp
+++ b/3rdparty/bgfx/src/debug_renderdoc.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright 2011-2019 Branimir Karadzic. All rights reserved.
+ * Copyright 2011-2021 Branimir Karadzic. All rights reserved.
* License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause
*/
@@ -13,9 +13,11 @@
namespace bgfx
{
- bool findModule(const char* _name)
+ void* findModule(const char* _name)
{
#if BX_PLATFORM_WINDOWS
+ // NOTE: there was some reason to do it this way instead of simply calling GetModuleHandleA,
+ // but not sure what it was.
HANDLE process = GetCurrentProcess();
DWORD size;
BOOL result = EnumProcessModules(process
@@ -45,14 +47,16 @@ namespace bgfx
if (0 != result
&& 0 == bx::strCmpI(_name, moduleName) )
{
- return true;
+ return (void*)modules[ii];
}
}
}
}
-#endif // BX_PLATFORM_WINDOWS
+#else
BX_UNUSED(_name);
- return false;
+#endif // BX_PLATFORM_WINDOWS
+
+ return NULL;
}
pRENDERDOC_GetAPI RENDERDOC_GetAPI;
@@ -72,13 +76,19 @@ namespace bgfx
return NULL;
}
- void* renderDocDll = bx::dlopen(
+ // If RenderDoc is already injected in the process then use the already present DLL
+ void* renderDocDll = findModule("renderdoc.dll");
+ if (NULL == renderDocDll)
+ {
+ // TODO: try common installation paths before looking in current directory
+ renderDocDll = bx::dlopen(
#if BX_PLATFORM_WINDOWS
- "renderdoc.dll"
+ "renderdoc.dll"
#else
- "./librenderdoc.so"
+ "./librenderdoc.so"
#endif // BX_PLATFORM_WINDOWS
- );
+ );
+ }
if (NULL != renderDocDll)
{
@@ -89,7 +99,7 @@ namespace bgfx
{
s_renderDoc->SetCaptureFilePathTemplate(BGFX_CONFIG_RENDERDOC_LOG_FILEPATH);
- s_renderDoc->SetFocusToggleKeys(NULL, 0);
+ s_renderDoc->SetFocusToggleKeys(NULL, 0);
RENDERDOC_InputButton captureKeys[] = BGFX_CONFIG_RENDERDOC_CAPTURE_KEYS;
s_renderDoc->SetCaptureKeys(captureKeys, BX_COUNTOF(captureKeys) );