Refactor hook populating out to separate from context checking

* On EGL we want to populate our hooks immediately so we have them ready
  before anything is used, and it's valid because eglGetProcAddress is
  spec'd to return function pointers that can be used with any context.
* Then later when we have a context we can check extensions and emulate.
This commit is contained in:
baldurk
2018-01-31 22:08:16 +00:00
parent 29f5d7e53d
commit 5cda6a8d65
4 changed files with 19 additions and 5 deletions
+8 -3
View File
@@ -327,7 +327,7 @@ __attribute__((visibility("default"))) EGLBoolean eglMakeCurrent(EGLDisplay disp
{
eglhooks.m_Contexts.insert(ctx);
eglhooks.PopulateHooks();
SharedCheckContext();
}
GLWindowingData data;
@@ -435,7 +435,7 @@ bool EGLHook::CreateHooks(const char *libName)
return true;
}
bool success = SetupHooks();
bool success = PopulateHooks();
if(!success)
return false;
@@ -449,6 +449,9 @@ bool EGLHook::PopulateHooks()
{
SetupHooks();
if(m_PopulatedHooks)
return true;
// dlsym can return GL symbols during a GLES context
bool dlsymFirst = false;
@@ -457,12 +460,14 @@ bool EGLHook::PopulateHooks()
dlsymFirst = true;
#endif
return SharedPopulateHooks(dlsymFirst, [](const char *funcName) {
m_PopulatedHooks = SharedPopulateHooks(dlsymFirst, [](const char *funcName) {
// on some android devices we need to hook dlsym, but eglGetProcAddress might call dlsym so we
// need to ensure we return the 'real' pointers
PosixScopedSuppressHooking suppress;
return (void *)eglGetProcAddress(funcName);
});
return m_PopulatedHooks;
}
const GLHookSet &GetRealGLFunctionsEGL()
+4
View File
@@ -647,6 +647,8 @@ __attribute__((visibility("default"))) Bool glXMakeCurrent(Display *dpy, GLXDraw
glhooks.m_Contexts.insert(ctx);
glhooks.PopulateHooks();
SharedCheckContext();
}
GLWindowingData data;
@@ -674,6 +676,8 @@ __attribute__((visibility("default"))) Bool glXMakeContextCurrent(Display *dpy,
glhooks.m_Contexts.insert(ctx);
glhooks.PopulateHooks();
SharedCheckContext();
}
GLWindowingData data;
@@ -1252,14 +1252,18 @@ bool SharedPopulateHooks(bool dlsymFirst, void *(*lookupFunc)(const char *))
DLLExportHooks();
HookCheckGLExtensions();
return true;
}
void SharedCheckContext()
{
CheckExtensions(GL);
// see gl_emulated.cpp
glEmulate::EmulateUnsupportedFunctions(&GL);
glEmulate::EmulateRequiredExtensions(&GL);
return true;
}
void PosixHookFunctions()
@@ -32,6 +32,7 @@ void CloneDisplay(Display *dpy);
void *SharedLookupFuncPtr(const char *func, void *realFunc);
bool SharedPopulateHooks(bool dlsymFirst, void *(*lookupFunc)(const char *));
void SharedCheckContext();
void PosixHookFunctions();
extern GLHookSet GL;