Fix EGL order-of-operations on windows

* On windows we can load libEGL which then loads opengl32.dll, so we ensure that
  opengl32.dll is loaded first at startup rather than have it appear last-minute
  in a recursive call.
* Likewise, when using EGL we forcibly forget all GL function pointers and fetch
  them through eglGetProcAddress, rather than having a mix-and-match dispatch
  table.
This commit is contained in:
baldurk
2018-07-12 15:33:52 +01:00
parent ec81a0329a
commit 7670c125c0
2 changed files with 11 additions and 0 deletions
+6
View File
@@ -535,6 +535,12 @@ static void EGLHooked(void *handle)
EGL_NONHOOKED_SYMBOLS(EGL_FETCH)
#undef EGL_FETCH
#if ENABLED(RDOC_WIN32)
// On windows we completely erase all GL function pointers. These might point into opengl32.dll
// which is not what we want to call when we're using a libEGL emulator
RDCEraseEl(GL);
#endif
// Now that libEGL is loaded, we can immediately fill out any missing functions that weren't
// library hooked by calling eglGetProcAddress.
GL.PopulateWithCallback([](const char *funcName) {
+5
View File
@@ -534,6 +534,11 @@ void WGLHook::RegisterHooks()
{
RDCLOG("Registering WGL hooks");
// we load GL here to ensure that it is loaded by the time that we end hook registration and apply
// any callbacks. That ensures that it doesn't get loaded later e.g. while we're in the middle of
// loading libEGL, and break due to recursive calls.
LoadLibraryA("opengl32.dll");
LibraryHooks::RegisterLibraryHook("opengl32.dll", &WGLHooked);
LibraryHooks::RegisterLibraryHook("gdi32.dll", NULL);
LibraryHooks::RegisterLibraryHook("user32.dll", NULL);