Don't assign function ptrs in gl*GetProcAddress if we have one already

* In theory, gl*GetProcAddress can return different function pointers
  at different times, but in practice this does not happen. Also we have
  many more problems if there was an implementation that did this.
* In reality what can happen if we don't preserve existing function
  pointers is that any call to gl*GetProcAddress will overwrite
  required emulated functions for e.g. EXT_dsa if the implementation
  doesn't support the extension but does return valid pointers for the
  query.
This commit is contained in:
baldurk
2017-05-17 15:15:36 +01:00
parent f8d10850f8
commit c867784647
2 changed files with 11 additions and 8 deletions
@@ -43,17 +43,19 @@ Threading::CriticalSection &GetGLLock()
return glLock;
}
#define HookInit(function) \
if(!strcmp(func, STRINGIZE(function))) \
{ \
GL.function = (CONCAT(function, _hooktype))realFunc; \
return (void *)&CONCAT(function, _renderdoc_hooked); \
#define HookInit(function) \
if(!strcmp(func, STRINGIZE(function))) \
{ \
if(GL.function == NULL) \
GL.function = (CONCAT(function, _hooktype))realFunc; \
return (void *)&CONCAT(function, _renderdoc_hooked); \
}
#define HookExtension(funcPtrType, function) \
if(!strcmp(func, STRINGIZE(function))) \
{ \
GL.function = (funcPtrType)realFunc; \
if(GL.function == NULL) \
GL.function = (funcPtrType)realFunc; \
return (void *)&CONCAT(function, _renderdoc_hooked); \
}
+3 -2
View File
@@ -44,14 +44,15 @@
#define HookExtension(funcPtrType, function) \
if(!strcmp(func, STRINGIZE(function))) \
{ \
glhooks.GL.function = (funcPtrType)realFunc; \
if(glhooks.GL.function == NULL) \
glhooks.GL.function = (funcPtrType)realFunc; \
return (PROC)&glhooks.CONCAT(function, _hooked); \
}
#define HookExtensionAlias(funcPtrType, function, alias) \
if(!strcmp(func, STRINGIZE(alias))) \
{ \
if(OpenGLHook::glhooks.GL.function == NULL) \
if(glhooks.GL.function == NULL) \
glhooks.GL.function = (funcPtrType)realFunc; \
return (PROC)&glhooks.CONCAT(function, _hooked); \
}