Procházet zdrojové kódy

Fixed RenderDoc crash when IntelGPA is present.

Branimir Karadžić před 11 roky
rodič
revize
d705fbc9bd
2 změnil soubory, kde provedl 48 přidání a 0 odebrání
  1. 1 0
      scripts/genie.lua
  2. 47 0
      src/renderer_d3d11.cpp

+ 1 - 0
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*" }

+ 47 - 0
src/renderer_d3d11.cpp

@@ -7,6 +7,7 @@
 
 #if BGFX_CONFIG_RENDERER_DIRECT3D11
 #	include "renderer_d3d11.h"
+#	include <psapi.h>
 #	include <renderdoc/renderdoc_app.h>
 
 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)