From ba4ccca62fc64d6254348f877b12146c9aa06844 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 9 Sep 2019 10:59:51 +0100 Subject: [PATCH] Don't load libEGL.dll from a global path on windows * EGL emulators are not sufficiently stable to run RenderDoc, so we want to be able to fall back to EXT_create_context_es2_profile unless the libEGL.dll is explicitly placed in our plugin path. --- renderdoc/driver/gl/egl_platform.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/renderdoc/driver/gl/egl_platform.cpp b/renderdoc/driver/gl/egl_platform.cpp index 81eca4779..d8c17ed8a 100644 --- a/renderdoc/driver/gl/egl_platform.cpp +++ b/renderdoc/driver/gl/egl_platform.cpp @@ -25,11 +25,26 @@ #include "core/plugins.h" #include "driver/gl/egl_dispatch_table.h" #include "driver/gl/gl_common.h" +#include "strings/string_utils.h" static void *GetEGLHandle() { #if ENABLED(RDOC_WIN32) - return Process::LoadModule(LocatePluginFile("gles", "libEGL.dll").c_str()); + std::string libEGL = LocatePluginFile("gles", "libEGL.dll"); + + // refuse to load libEGL.dll globally, as this is too likely to pick up ANGLE from some program + // with poor PATH control. Instead try to explicitly load it from next to the DLL in case someone + // has put it there. + if(libEGL == "libEGL.dll") + { + std::string libpath; + FileIO::GetLibraryFilename(libpath); + libpath = get_dirname(libpath); + + libEGL = libpath + "/libEGL.dll"; + } + + return Process::LoadModule(libEGL.c_str()); #else void *handle = Process::LoadModule("libEGL.so");