Don't rely on linux GL library exporting all symbols. Closes #1048

This commit is contained in:
baldurk
2018-07-24 11:20:40 +01:00
parent 8410cfd5ab
commit 5e911bb7c8
4 changed files with 21 additions and 4 deletions
+2
View File
@@ -520,6 +520,8 @@ EGL_PASSTHRU_0(EGLContext, eglGetCurrentContext)
static void EGLHooked(void *handle)
{
RDCDEBUG("EGL library hooked");
// store the handle for any pass-through implementations that need to look up their onward
// pointers
eglhook.handle = handle;
+17 -3
View File
@@ -618,8 +618,10 @@ GLX_PASSTHRU_3(GLXPbuffer, glXCreatePbuffer, Display *, dpy, GLXFBConfig, config
attrib_list);
GLX_PASSTHRU_2(void, glXDestroyPbuffer, Display *, dpy, GLXPbuffer, pbuf);
static void GLHooked(void *handle)
static void GLXHooked(void *handle)
{
RDCDEBUG("GLX library hooked");
// store the handle for any pass-through implementations that need to look up their onward
// pointers
glxhook.handle = handle;
@@ -633,6 +635,18 @@ static void GLHooked(void *handle)
GLX_NONHOOKED_SYMBOLS(GLX_FETCH)
#undef GLX_FETCH
// fetch any functions that weren't directly exported
#define GPA_FUNC(func) \
if(!GLX.func && GLX.glXGetProcAddressARB) \
GLX.func = (CONCAT(PFN_, func))GLX.glXGetProcAddressARB((const GLubyte *)STRINGIZE(func)); \
\
if(!GLX.func && GLX.glXGetProcAddress) \
GLX.func = (CONCAT(PFN_, func))GLX.glXGetProcAddress((const GLubyte *)STRINGIZE(func));
GLX_HOOKED_SYMBOLS(GPA_FUNC)
GLX_NONHOOKED_SYMBOLS(GPA_FUNC)
#undef GPA_FUNC
// Now that libGL is loaded, we can immediately fill out any missing functions that weren't
// library hooked by calling eglGetProcAddress.
GL.PopulateWithCallback([](const char *funcName) -> void * {
@@ -657,8 +671,8 @@ void GLXHook::RegisterHooks()
RDCLOG("Registering GLX hooks");
// register library hooks
LibraryHooks::RegisterLibraryHook("libGL.so", &GLHooked);
LibraryHooks::RegisterLibraryHook("libGL.so.1", &GLHooked);
LibraryHooks::RegisterLibraryHook("libGL.so", &GLXHooked);
LibraryHooks::RegisterLibraryHook("libGL.so.1", &GLXHooked);
// register EGL hooks
#define GLX_REGISTER(func) \
-1
View File
@@ -435,7 +435,6 @@ GLPlatform &GetGLPlatform()
bool GLXDispatchTable::PopulateForReplay()
{
RDCASSERT(RenderDoc::Inst().IsReplayApp());
GetGLHandle();
void *handle = GetGLHandle();
+2
View File
@@ -518,6 +518,8 @@ static PROC WINAPI wglGetProcAddress_hooked(const char *func)
static void WGLHooked(void *handle)
{
RDCDEBUG("WGL library hooked");
// as a hook callback this is only called while capturing
RDCASSERT(!RenderDoc::Inst().IsReplayApp());