Change RENDERDOC_HOOK_EGL to a runtime option on an env var

* Environment variables are not user-friendly, but I don't want to promote this
  to a capture option since it's so niche.
* In future perhaps  it will be feasible to support selecting an arbitrary API
  to capture, or even capturing multiple APIs simultaneously - though with GLES-
  on-GL that will be quite difficult.
This commit is contained in:
baldurk
2018-07-12 14:05:52 +01:00
parent 7670c125c0
commit fd5612e30a
3 changed files with 31 additions and 15 deletions
+20 -7
View File
@@ -551,9 +551,28 @@ static void EGLHooked(void *handle)
});
}
#if ENABLED(RDOC_WIN32)
bool ShouldHookEGL()
{
const char *toggle = Process::GetEnvVariable("RENDERDOC_HOOK_EGL");
// if the var is set to 0, then don't hook EGL
if(toggle && toggle[0] == '0')
return false;
return true;
}
#endif
void EGLHook::RegisterHooks()
{
#if ENABLED(RENDERDOC_HOOK_EGL)
#if ENABLED(RDOC_WIN32)
if(!ShouldHookEGL())
{
RDCLOG("EGL hooks disabled - if GLES emulator is in use, underlying API will be captured");
return;
}
#endif
RDCLOG("Registering EGL hooks");
@@ -591,10 +610,4 @@ void EGLHook::RegisterHooks()
FunctionHook("egl" STRINGIZE(func), (void **)&EGL.func, (void *)&CONCAT(egl, func)));
EGL_HOOKED_SYMBOLS(EGL_REGISTER)
#undef EGL_REGISTER
#else
RDCLOG("EGL hooks disabled - if GLES emulator is in use, underlying API will be captured");
#endif
}
+3 -3
View File
@@ -49,9 +49,9 @@ DECLARE_REFLECTION_ENUM(RDCGLenum);
#define RENDERDOC_SUPPORT_GL
#define RENDERDOC_SUPPORT_GLES
// disable this option to disallow hooking EGL on windows. This means that the underlying GL or D3D
// calls will be captured instead.
#define RENDERDOC_HOOK_EGL OPTION_ON
// checks a runtime opt-out option to disallow hooking EGL on windows. This means that the
// underlying GL or D3D calls will be captured instead.
bool ShouldHookEGL();
#else
+8 -5
View File
@@ -185,11 +185,14 @@ void GLHook::RegisterHooks()
ForEachSupported(RegisterFunc);
#if ENABLED(RDOC_WIN32) && defined(RENDERDOC_SUPPORT_GLES)
// on windows where hooking is per-library, we also need to register these hooks for any GLES2/3
// wrapper library, when GLES support is enabled.
libraryName = "libGLESv2.dll";
#if ENABLED(RDOC_WIN32)
if(ShouldHookEGL())
{
// on windows where hooking is per-library, we also need to register these hooks for any GLES2/3
// wrapper library, when GLES support is enabled.
libraryName = "libGLESv2.dll";
ForEachSupported(RegisterFunc);
ForEachSupported(RegisterFunc);
}
#endif
}