diff --git a/renderdoc/driver/gl/gl_hooks_linux_shared.cpp b/renderdoc/driver/gl/gl_hooks_linux_shared.cpp index 5fcf2175c..7351ed383 100644 --- a/renderdoc/driver/gl/gl_hooks_linux_shared.cpp +++ b/renderdoc/driver/gl/gl_hooks_linux_shared.cpp @@ -87,39 +87,60 @@ Threading::CriticalSection &GetGLLock() /* in bash: - function HookWrapper() + function WrapperMacro() { - N=$1; - echo -n "#define HookWrapper$N(ret, function"; + NAME=$1; + N=$2; + ALIAS=$3; + if [ $ALIAS -eq 1 ]; then + echo -n "#define $NAME$N(ret, function, realfunc"; + else + echo -n "#define $NAME$N(ret, function"; + fi for I in `seq 1 $N`; do echo -n ", t$I, p$I"; done; echo ") \\"; - echo -en "\ttypedef ret (*CONCAT(function, _hooktype)) ("; + echo -en " typedef ret (*CONCAT(function, _hooktype))("; for I in `seq 1 $N`; do echo -n "t$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; echo "); \\"; - echo -e "\textern \"C\" __attribute__ ((visibility (\"default\"))) \\"; - - echo -en "\tret function("; + echo -en " extern \"C\" __attribute__((visibility (\"default\"))) ret function("; for I in `seq 1 $N`; do echo -n "t$I p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; echo ") \\"; - echo -en "\t{ SCOPED_LOCK(glLock); return m_GLDriver->function("; + echo -e " { \\"; + echo -e " SCOPED_LOCK(glLock); \\"; + echo -e " gl_CurChunk = GLChunk::function; \\"; + if [ $ALIAS -eq 1 ]; then + echo -n " return glhooks.GL.realfunc("; + else + echo -n " return glhooks.GL.function("; + fi for I in `seq 1 $N`; do echo -n "p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; - echo "); } \\"; + echo -e "); \\"; + echo -e " } \\"; - echo -en "\tret CONCAT(function,_renderdoc_hooked)("; + echo -en " ret CONCAT(function,_renderdoc_hooked)("; for I in `seq 1 $N`; do echo -n "t$I p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; echo ") \\"; - echo -en "\t{ SCOPED_LOCK(glLock); return m_GLDriver->function("; + echo -e " { \\"; + echo -e " SCOPED_LOCK(glLock); \\"; + echo -e " gl_CurChunk = GLChunk::function; \\"; + if [ $ALIAS -eq 1 ]; then + echo -n " return m_GLDriver->realfunc("; + else + echo -n " return m_GLDriver->function("; + fi for I in `seq 1 $N`; do echo -n "p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; - echo -n "); }"; + echo -e "); \\"; + echo -e " }"; } - for I in `seq 0 15`; do HookWrapper $I; echo; done + for I in `seq 0 15`; do WrapperMacro HookWrapper $I 0; echo; done + for I in `seq 0 15`; do WrapperMacro HookAliasWrapper $I 1; echo; done */ @@ -143,112 +164,139 @@ Threading::CriticalSection &GetGLLock() extern "C" __attribute__((visibility("default"))) ret function() \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(); \ } \ ret CONCAT(function, _renderdoc_hooked)() \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(); \ } + #define HookWrapper1(ret, function, t1, p1) \ typedef ret (*CONCAT(function, _hooktype))(t1); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1); \ } + #define HookWrapper2(ret, function, t1, p1, t2, p2) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2); \ } + #define HookWrapper3(ret, function, t1, p1, t2, p2, t3, p3) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3); \ } + #define HookWrapper4(ret, function, t1, p1, t2, p2, t3, p3, t4, p4) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4); \ } + #define HookWrapper5(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5); \ } + #define HookWrapper6(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ t5 p5, t6 p6) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6); \ } + #define HookWrapper7(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ t5 p5, t6 p6, t7 p7) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7); \ } + #define HookWrapper8(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8); \ extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ t5 p5, t6 p6, t7 p7, t8 p8) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8); \ } + #define HookWrapper9(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9); \ @@ -256,14 +304,17 @@ Threading::CriticalSection &GetGLLock() t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ } + #define HookWrapper10(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); \ @@ -271,14 +322,17 @@ Threading::CriticalSection &GetGLLock() t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9, t10 p10) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ } + #define HookWrapper11(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11); \ @@ -286,14 +340,17 @@ Threading::CriticalSection &GetGLLock() t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9, t10 p10, t11 p11) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ } + #define HookWrapper12(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12); \ @@ -301,14 +358,17 @@ Threading::CriticalSection &GetGLLock() t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11, t12 p12) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9, t10 p10, t11 p11, t12 p12) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ } + #define HookWrapper13(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ @@ -318,14 +378,17 @@ Threading::CriticalSection &GetGLLock() t13 p13) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9, t10 p10, t11 p11, t12 p12, t13 p13) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ } + #define HookWrapper14(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, t14, p14) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ @@ -335,14 +398,17 @@ Threading::CriticalSection &GetGLLock() t13 p13, t14 p14) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ t9 p9, t10 p10, t11 p11, t12 p12, t13 p13, t14 p14) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ } + #define HookWrapper15(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, t14, p14, t15, p15) \ typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ @@ -352,6 +418,7 @@ Threading::CriticalSection &GetGLLock() t13 p13, t14 p14, t15 p15) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ } \ ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ @@ -359,36 +426,284 @@ Threading::CriticalSection &GetGLLock() t15 p15) \ { \ SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ return m_GLDriver->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ } -#define HookAliasWrapper0(ret, function, realfunc) -#define HookAliasWrapper1(ret, function, realfunc, t1, p1) -#define HookAliasWrapper2(ret, function, realfunc, t1, p1, t2, p2) -#define HookAliasWrapper3(ret, function, realfunc, t1, p1, t2, p2, t3, p3) -#define HookAliasWrapper4(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4) -#define HookAliasWrapper5(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) -#define HookAliasWrapper6(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) +#define HookAliasWrapper0(ret, function, realfunc) \ + typedef ret (*CONCAT(function, _hooktype))(); \ + extern "C" __attribute__((visibility("default"))) ret function() \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(); \ + } \ + ret CONCAT(function, _renderdoc_hooked)() \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(); \ + } + +#define HookAliasWrapper1(ret, function, realfunc, t1, p1) \ + typedef ret (*CONCAT(function, _hooktype))(t1); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1); \ + } + +#define HookAliasWrapper2(ret, function, realfunc, t1, p1, t2, p2) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2); \ + } + +#define HookAliasWrapper3(ret, function, realfunc, t1, p1, t2, p2, t3, p3) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3); \ + } + +#define HookAliasWrapper4(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4); \ + } + +#define HookAliasWrapper5(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5); \ + } + +#define HookAliasWrapper6(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ + t5 p5, t6 p6) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6); \ + } + #define HookAliasWrapper7(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7) + t7, p7) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ + t5 p5, t6 p6, t7 p7) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7); \ + } + #define HookAliasWrapper8(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7, t8, p8) + t7, p7, t8, p8) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8); \ + extern "C" __attribute__((visibility("default"))) ret function(t1 p1, t2 p2, t3 p3, t4 p4, \ + t5 p5, t6 p6, t7 p7, t8 p8) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8); \ + } + #define HookAliasWrapper9(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7, t8, p8, t9, p9) -#define HookAliasWrapper10(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10) -#define HookAliasWrapper11(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11) -#define HookAliasWrapper12(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12) -#define HookAliasWrapper13(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) -#define HookAliasWrapper14(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ - t14, p14) -#define HookAliasWrapper15(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ - t14, p14, t15, p15) + t7, p7, t8, p8, t9, p9) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + } + +#define HookAliasWrapper10(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + } + +#define HookAliasWrapper11(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10, t11 p11) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + } + +#define HookAliasWrapper12(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11, t12 p12) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10, t11 p11, t12 p12) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + } + +#define HookAliasWrapper13(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ + t13); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, \ + t13 p13) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10, t11 p11, t12 p12, t13 p13) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + } + +#define HookAliasWrapper14(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ + t14, p14) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ + t13, t14); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, \ + t13 p13, t14 p14) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10, t11 p11, t12 p12, t13 p13, t14 p14) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + } + +#define HookAliasWrapper15(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ + t14, p14, t15, p15) \ + typedef ret (*CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, \ + t13, t14, t15); \ + extern "C" __attribute__((visibility("default"))) ret function( \ + t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, \ + t13 p13, t14 p14, t15 p15) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ + } \ + ret CONCAT(function, _renderdoc_hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8, \ + t9 p9, t10 p10, t11 p11, t12 p12, t13 p13, t14 p14, \ + t15 p15) \ + { \ + SCOPED_LOCK(glLock); \ + gl_CurChunk = GLChunk::function; \ + return m_GLDriver->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ + } DefineDLLExportHooks(); DefineGLExtensionHooks(); diff --git a/renderdoc/driver/gl/gl_hooks_vrapi.cpp b/renderdoc/driver/gl/gl_hooks_vrapi.cpp index 2bf097b22..499469a04 100644 --- a/renderdoc/driver/gl/gl_hooks_vrapi.cpp +++ b/renderdoc/driver/gl/gl_hooks_vrapi.cpp @@ -189,6 +189,8 @@ __attribute__((visibility("default"))) ovrTextureSwapChain *vrapi_CreateTextureS vrapi_hooks.SetupHooks(); } + gl_CurChunk = GLChunk::vrapi_CreateTextureSwapChain2; + ovrTextureSwapChain *texture_swapchain = vrapi_hooks.vrapi_CreateTextureSwapChain2_real( type, format, width, height, levels, bufferCount); @@ -222,6 +224,8 @@ __attribute__((visibility("default"))) ovrTextureSwapChain *vrapi_CreateTextureS vrapi_hooks.SetupHooks(); } + gl_CurChunk = GLChunk::vrapi_CreateTextureSwapChain; + ovrTextureSwapChain *texture_swapchain = vrapi_hooks.vrapi_CreateTextureSwapChain_real(type, format, width, height, levels, buffered); diff --git a/renderdoc/driver/gl/gl_hooks_win32.cpp b/renderdoc/driver/gl/gl_hooks_win32.cpp index f00928238..663d3e5bc 100644 --- a/renderdoc/driver/gl/gl_hooks_win32.cpp +++ b/renderdoc/driver/gl/gl_hooks_win32.cpp @@ -77,35 +77,55 @@ /* in bash: - function HookWrapper() + function WrapperMacro() { - N=$1; - echo -n "#define HookWrapper$N(ret, function"; + NAME=$1; + N=$2; + ALIAS=$3; + if [ $ALIAS -eq 1 ]; then + echo -n "#define $NAME$N(ret, function, realfunc"; + else + echo -n "#define $NAME$N(ret, function"; + fi for I in `seq 1 $N`; do echo -n ", t$I, p$I"; done; echo ") \\"; - echo -en "\tHook CONCAT(function, _hook); \\"; - echo -en "\ttypedef ret (WINAPI *CONCAT(function, _hooktype)) ("; + echo -en " typedef ret(WINAPI *CONCAT(function, _hooktype)) ("; for I in `seq 1 $N`; do echo -n "t$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; echo "); \\"; - echo -en "\tstatic ret WINAPI CONCAT(function, _hooked)("; + echo -en " static ret WINAPI CONCAT(function, _hooked)("; for I in `seq 1 $N`; do echo -n "t$I p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; echo ") \\"; - echo -en "\t{ SCOPED_LOCK(glLock);"; - echo -en "if(!glhooks.m_HaveContextCreation) return glhooks.GL.function("; + echo -e " { \\"; + echo -e " SCOPED_LOCK(glLock); \\"; + echo -e ' if(!glhooks.m_HaveContextCreation) \\'; + if [ $ALIAS -eq 1 ]; then + echo -n " return glhooks.GL.realfunc("; + else + echo -n " return glhooks.GL.function("; + fi for I in `seq 1 $N`; do echo -n "p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; - echo -en "); return glhooks.GetDriver()->function("; + echo -e "); \\"; + echo -e " gl_CurChunk = GLChunk::function; \\"; + if [ $ALIAS -eq 1 ]; then + echo -n " return glhooks.GetDriver()->realfunc("; + else + echo -n " return glhooks.GetDriver()->function("; + fi for I in `seq 1 $N`; do echo -n "p$I"; if [ $I -ne $N ]; then echo -n ", "; fi; done; - echo -n "); }"; + echo -e "); \\"; + echo -e " }"; } - for I in `seq 0 15`; do HookWrapper $I; echo; done + for I in `seq 0 15`; do WrapperMacro HookWrapper $I 0; echo; done + for I in `seq 0 15`; do WrapperMacro HookAliasWrapper $I 1; echo; done */ @@ -117,7 +137,6 @@ #ifdef far #undef far #endif - #define HookWrapper0(ret, function) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(); \ @@ -126,8 +145,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(); \ } + #define HookWrapper1(ret, function, t1, p1) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1); \ @@ -136,8 +157,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1); \ } + #define HookWrapper2(ret, function, t1, p1, t2, p2) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2); \ @@ -146,8 +169,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2); \ } + #define HookWrapper3(ret, function, t1, p1, t2, p2, t3, p3) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3); \ @@ -156,8 +181,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3); \ } + #define HookWrapper4(ret, function, t1, p1, t2, p2, t3, p3, t4, p4) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4); \ @@ -166,8 +193,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4); \ } + #define HookWrapper5(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5); \ @@ -176,8 +205,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5); \ } + #define HookWrapper6(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6); \ @@ -186,8 +217,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6); \ } + #define HookWrapper7(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7); \ @@ -196,8 +229,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7); \ } + #define HookWrapper8(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, p8) \ Hook CONCAT(function, _hook); \ typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8); \ @@ -206,8 +241,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8); \ } + #define HookWrapper9(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9) \ Hook CONCAT(function, _hook); \ @@ -218,8 +255,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ } + #define HookWrapper10(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10) \ Hook CONCAT(function, _hook); \ @@ -230,8 +269,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ } + #define HookWrapper11(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11) \ Hook CONCAT(function, _hook); \ @@ -242,8 +283,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ } + #define HookWrapper12(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12) \ Hook CONCAT(function, _hook); \ @@ -255,8 +298,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ } + #define HookWrapper13(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) \ Hook CONCAT(function, \ @@ -269,8 +314,10 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ } + #define HookWrapper14(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, t14, p14) \ Hook CONCAT( \ @@ -284,9 +331,11 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, \ p14); \ } + #define HookWrapper15(ret, function, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, t7, p7, t8, \ p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, t14, p14, t15, p15) \ Hook CONCAT( \ @@ -300,37 +349,231 @@ SCOPED_LOCK(glLock); \ if(!glhooks.m_HaveContextCreation) \ return glhooks.GL.function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ + gl_CurChunk = GLChunk::function; \ return glhooks.GetDriver()->function(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, \ p14, p15); \ } -#define HookAliasWrapper0(ret, function, realfunc) -#define HookAliasWrapper1(ret, function, realfunc, t1, p1) -#define HookAliasWrapper2(ret, function, realfunc, t1, p1, t2, p2) -#define HookAliasWrapper3(ret, function, realfunc, t1, p1, t2, p2, t3, p3) -#define HookAliasWrapper4(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4) -#define HookAliasWrapper5(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) -#define HookAliasWrapper6(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) +#define HookAliasWrapper0(ret, function, realfunc) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(); \ + static ret WINAPI CONCAT(function, _hooked)() \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(); \ + } + +#define HookAliasWrapper1(ret, function, realfunc, t1, p1) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1); \ + } + +#define HookAliasWrapper2(ret, function, realfunc, t1, p1, t2, p2) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2); \ + } + +#define HookAliasWrapper3(ret, function, realfunc, t1, p1, t2, p2, t3, p3) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3); \ + } + +#define HookAliasWrapper4(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4); \ + } + +#define HookAliasWrapper5(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5); \ + } + +#define HookAliasWrapper6(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6); \ + } + #define HookAliasWrapper7(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7) -#define HookAliasWrapper8(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7, t8, p8) + t7, p7) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7); \ + } + +#define HookAliasWrapper8(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ + t7, p7, t8, p8) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, t8 p8) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8); \ + } + #define HookAliasWrapper9(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, p6, \ - t7, p7, t8, p8, t9, p9) + t7, p7, t8, p8, t9, p9) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9); \ + } + #define HookAliasWrapper10(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10) -#define HookAliasWrapper11(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11) -#define HookAliasWrapper12(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12) -#define HookAliasWrapper13(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) -#define HookAliasWrapper14(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ - t14, p14) -#define HookAliasWrapper15(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ - p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ - t14, p14, t15, p15) + p6, t7, p7, t8, p8, t9, p9, t10, p10) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); \ + } + +#define HookAliasWrapper11(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10, t11 p11) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11); \ + } + +#define HookAliasWrapper12(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12) \ + Hook CONCAT(function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, \ + t12); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10, t11 p11, t12 p12) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12); \ + } + +#define HookAliasWrapper13(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13) \ + Hook CONCAT(function, \ + _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, \ + t12, t13); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, t13 p13) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13); \ + } + +#define HookAliasWrapper14(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ + t14, p14) \ + Hook CONCAT( \ + function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, \ + t12, t13, t14); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, t13 p13, \ + t14 p14) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, \ + p14); \ + } + +#define HookAliasWrapper15(ret, function, realfunc, t1, p1, t2, p2, t3, p3, t4, p4, t5, p5, t6, \ + p6, t7, p7, t8, p8, t9, p9, t10, p10, t11, p11, t12, p12, t13, p13, \ + t14, p14, t15, p15) \ + Hook CONCAT( \ + function, _hook); \ + typedef ret(WINAPI *CONCAT(function, _hooktype))(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, \ + t12, t13, t14, t15); \ + static ret WINAPI CONCAT(function, _hooked)(t1 p1, t2 p2, t3 p3, t4 p4, t5 p5, t6 p6, t7 p7, \ + t8 p8, t9 p9, t10 p10, t11 p11, t12 p12, t13 p13, \ + t14 p14, t15 p15) \ + { \ + SCOPED_LOCK(glLock); \ + if(!glhooks.m_HaveContextCreation) \ + return glhooks.GL.realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15); \ + gl_CurChunk = GLChunk::function; \ + return glhooks.GetDriver()->realfunc(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, \ + p14, p15); \ + } Threading::CriticalSection glLock;