Allow EGL functions to be missing on replay if we don't need them

This commit is contained in:
baldurk
2019-09-10 13:41:08 +01:00
parent 764f294d75
commit b7d78d8e07
6 changed files with 37 additions and 66 deletions
+27 -27
View File
@@ -65,33 +65,33 @@ typedef PFNEGLPOSTSUBBUFFERNVPROC PFN_eglPostSubBufferNV;
typedef PFNEGLSWAPBUFFERSWITHDAMAGEEXTPROC PFN_eglSwapBuffersWithDamageEXT;
typedef PFNEGLSWAPBUFFERSWITHDAMAGEKHRPROC PFN_eglSwapBuffersWithDamageKHR;
#define EGL_HOOKED_SYMBOLS(FUNC) \
FUNC(BindAPI, false); \
FUNC(GetProcAddress, false); \
FUNC(GetDisplay, false); \
FUNC(GetPlatformDisplay, false); \
FUNC(CreateContext, false); \
FUNC(DestroyContext, false); \
FUNC(CreateWindowSurface, false); \
FUNC(CreatePlatformWindowSurface, false); \
FUNC(MakeCurrent, false); \
FUNC(SwapBuffers, false); \
FUNC(PostSubBufferNV, true); \
FUNC(SwapBuffersWithDamageEXT, true); \
FUNC(SwapBuffersWithDamageKHR, true);
#define EGL_HOOKED_SYMBOLS(FUNC) \
FUNC(BindAPI, false, true); \
FUNC(GetProcAddress, false, true); \
FUNC(GetDisplay, false, true); \
FUNC(GetPlatformDisplay, false, false); \
FUNC(CreateContext, false, true); \
FUNC(DestroyContext, false, true); \
FUNC(CreateWindowSurface, false, true); \
FUNC(CreatePlatformWindowSurface, false, false); \
FUNC(MakeCurrent, false, true); \
FUNC(SwapBuffers, false, true); \
FUNC(PostSubBufferNV, true, false); \
FUNC(SwapBuffersWithDamageEXT, true, false); \
FUNC(SwapBuffersWithDamageKHR, true, false);
#define EGL_NONHOOKED_SYMBOLS(FUNC) \
FUNC(ChooseConfig, false); \
FUNC(CreatePbufferSurface, false); \
FUNC(DestroySurface, false); \
FUNC(GetConfigAttrib, false); \
FUNC(GetCurrentContext, false); \
FUNC(GetCurrentDisplay, false); \
FUNC(GetCurrentSurface, false); \
FUNC(GetError, false); \
FUNC(Initialize, false); \
FUNC(QueryString, false); \
FUNC(QuerySurface, false);
#define EGL_NONHOOKED_SYMBOLS(FUNC) \
FUNC(ChooseConfig, false, true); \
FUNC(CreatePbufferSurface, false, true); \
FUNC(DestroySurface, false, true); \
FUNC(GetConfigAttrib, false, false); \
FUNC(GetCurrentContext, false, true); \
FUNC(GetCurrentDisplay, false, true); \
FUNC(GetCurrentSurface, false, true); \
FUNC(GetError, false, true); \
FUNC(Initialize, false, true); \
FUNC(QueryString, false, true); \
FUNC(QuerySurface, false, true);
struct EGLDispatchTable
{
@@ -109,7 +109,7 @@ struct EGLDispatchTable
// Generate the EGL function pointers. We need to consider hooked and non-hooked symbols separately
// - non-hooked symbols don't have a function hook to register, or if they do it's a dummy
// pass-through hook that will risk calling itself via trampoline.
#define EGL_PTR_GEN(func, isext) CONCAT(PFN_egl, func) func;
#define EGL_PTR_GEN(func, isext, replayrequired) CONCAT(PFN_egl, func) func;
EGL_HOOKED_SYMBOLS(EGL_PTR_GEN)
EGL_NONHOOKED_SYMBOLS(EGL_PTR_GEN)
#undef EGL_PTR_GEN
+7 -7
View File
@@ -637,8 +637,8 @@ eglGetProcAddress_renderdoc_hooked(const char *func)
return realFunc;
// return our egl hooks
#define GPA_FUNCTION(name, isext) \
if(!strcmp(func, "egl" STRINGIZE(name))) \
#define GPA_FUNCTION(name, isext, replayrequired) \
if(!strcmp(func, "egl" STRINGIZE(name))) \
return (__eglMustCastToProperFunctionPointerType)&CONCAT(egl, CONCAT(name, _renderdoc_hooked));
EGL_HOOKED_SYMBOLS(GPA_FUNCTION)
#undef GPA_FUNCTION
@@ -876,7 +876,7 @@ static void EGLHooked(void *handle)
RDCASSERT(!RenderDoc::Inst().IsReplayApp());
// fetch non-hooked functions into our dispatch table
#define EGL_FETCH(func, isext) \
#define EGL_FETCH(func, isext, replayrequired) \
EGL.func = (CONCAT(PFN_egl, func))Process::GetFunctionAddress(handle, "egl" STRINGIZE(func)); \
if(!EGL.func && CheckConstParam(isext)) \
EGL.func = (CONCAT(PFN_egl, func))EGL.GetProcAddress("egl" STRINGIZE(func));
@@ -985,7 +985,7 @@ void EGLHook::RegisterHooks()
#endif
// register EGL hooks
#define EGL_REGISTER(func, isext) \
#define EGL_REGISTER(func, isext, replayrequired) \
LibraryHooks::RegisterFunctionHook( \
"libEGL" LIBSUFFIX, FunctionHook("egl" STRINGIZE(func), (void **)&EGL.func, \
(void *)&CONCAT(egl, CONCAT(func, _renderdoc_hooked))));
@@ -1009,7 +1009,7 @@ HOOK_EXPORT void AndroidGLESLayer_Initialize(void *layer_id,
// populate EGL dispatch table with the next layer's function pointers. Fetch all 'hooked' and
// non-hooked functions
#define EGL_FETCH(func, isext) \
#define EGL_FETCH(func, isext, replayrequired) \
EGL.func = (CONCAT(PFN_egl, func))next_gpa(layer_id, "egl" STRINGIZE(func)); \
if(!EGL.func) \
RDCWARN("Couldn't fetch function pointer for egl" STRINGIZE(func));
@@ -1026,8 +1026,8 @@ HOOK_EXPORT void *AndroidGLESLayer_GetProcAddress(const char *funcName,
__eglMustCastToProperFunctionPointerType next)
{
// return our egl hooks
#define GPA_FUNCTION(name, isext) \
if(!strcmp(funcName, "egl" STRINGIZE(name))) \
#define GPA_FUNCTION(name, isext, replayrequired) \
if(!strcmp(funcName, "egl" STRINGIZE(name))) \
return (void *)&CONCAT(egl, CONCAT(name, _renderdoc_hooked));
EGL_HOOKED_SYMBOLS(GPA_FUNCTION)
#undef GPA_FUNCTION
-26
View File
@@ -1,26 +0,0 @@
/******************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2019 Baldur Karlsson
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
******************************************************************************/
#include "driver/gl/egl_dispatch_table.h"
#include "driver/gl/gl_driver.h"
+3 -2
View File
@@ -435,7 +435,7 @@ bool EGLDispatchTable::PopulateForReplay()
bool symbols_ok = true;
#define LOAD_FUNC(func, isext) \
#define LOAD_FUNC(func, isext, replayrequired) \
if(!this->func) \
this->func = (CONCAT(PFN_egl, func))Process::GetFunctionAddress(handle, "egl" STRINGIZE(func)); \
if(!this->func && CheckConstParam(isext)) \
@@ -443,7 +443,8 @@ bool EGLDispatchTable::PopulateForReplay()
\
if(!this->func && !CheckConstParam(isext)) \
{ \
symbols_ok = false; \
if(CheckConstParam(replayrequired)) \
symbols_ok = false; \
RDCWARN("Unable to load '%s'", STRINGIZE(func)); \
}
-1
View File
@@ -135,7 +135,6 @@
<ClCompile Include="cgl_hooks.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="egl_layer_android.cpp" />
<ClCompile Include="glx_fake_vk_hooks.cpp">
<ExcludedFromBuild>true</ExcludedFromBuild>
</ClCompile>
@@ -260,9 +260,6 @@
<ClCompile Include="glx_fake_vk_hooks.cpp">
<Filter>Platform Interfaces\Linux</Filter>
</ClCompile>
<ClCompile Include="egl_layer_android.cpp">
<Filter>EGL</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="cgl_platform.mm">