From d705fbc9bde4c7f23843a12ec8d079c0d2cc2e41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 27 Sep 2014 20:40:47 -0700 Subject: [PATCH] Fixed RenderDoc crash when IntelGPA is present. --- scripts/genie.lua | 1 + src/renderer_d3d11.cpp | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/scripts/genie.lua b/scripts/genie.lua index 07cd1d0c..01ca6342 100644 --- a/scripts/genie.lua +++ b/scripts/genie.lua @@ -77,6 +77,7 @@ function exampleProject(_name) } links { -- this is needed only for testing with GLES2/3 on Windows with VS2008 "DelayImp", + "psapi", } configuration { "vs201*" } diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index fec89a51..2261848c 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -7,6 +7,7 @@ #if BGFX_CONFIG_RENDERER_DIRECT3D11 # include "renderer_d3d11.h" +# include # include namespace bgfx @@ -423,8 +424,54 @@ RENDERDOC_IMPORT pRENDERDOC_GetAPIVersion RENDERDOC_GetAPIVersion; + bool findModule(const char* _name) + { + HANDLE process = GetCurrentProcess(); + DWORD size; + BOOL result = EnumProcessModules(process + , NULL + , 0 + , &size + ); + if (0 != result) + { + HMODULE* modules = (HMODULE*)alloca(size); + result = EnumProcessModules(process + , modules + , size + , &size + ); + + if (0 != result) + { + char moduleName[MAX_PATH]; + for (uint32_t ii = 0, num = uint32_t(size/sizeof(HMODULE) ); ii < num; ++ii) + { + result = GetModuleBaseNameA(process + , modules[ii] + , moduleName + , BX_COUNTOF(moduleName) + ); + if (0 != result + && 0 == bx::stricmp(_name, moduleName) ) + { + return true; + } + } + } + } + + return false; + } + void* loadRenderDoc() { + // Skip loading RenderDoc when IntelGPA is present to avoid RenderDoc crash. + if (findModule(BX_ARCH_32BIT ? "shimloader32.dll" : "shimloader64.dll") ) + { + return NULL; + } + void* renderdocdll = bx::dlopen("renderdoc.dll"); if (NULL != renderdocdll)