From: José Fonseca Date: Thu, 2 Aug 2012 19:00:28 +0000 (+0100) Subject: Recognize for context creation/destruction/binding functions (issue #90). X-Git-Url: https://git.cworth.org/git?p=apitrace;a=commitdiff_plain;h=a67ed0a94ba8f02c0e64a6e0a530b33152747240 Recognize for context creation/destruction/binding functions (issue #90). Thanks to gregory38 for spotting this. --- diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py index 1805846..4330581 100644 --- a/wrappers/egltrace.py +++ b/wrappers/egltrace.py @@ -81,6 +81,7 @@ class EglTracer(GlTracer): print ' gltrace::releaseContext((uintptr_t)ctx);' print ' }' + if __name__ == '__main__': print '#include ' print '#include ' diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py index ff3eb4c..21bf98c 100644 --- a/wrappers/glxtrace.py +++ b/wrappers/glxtrace.py @@ -45,17 +45,34 @@ class GlxTracer(GlTracer): "glXGetProcAddressARB", ] + createContextFunctionNames = [ + 'glXCreateContext', + 'glXCreateContextAttribsARB', + 'glXCreateContextWithConfigSGIX' + 'glXCreateNewContext', + ] + + destroyContextFunctionNames = [ + 'glXDestroyContext', + ] + + makeCurrentFunctionNames = [ + 'glXMakeCurrent', + 'glXMakeContextCurrent', + 'glXMakeCurrentReadSGI', + ] + def traceFunctionImplBody(self, function): - if function.name == 'glXDestroyContext': + if function.name in self.destroyContextFunctionNames: print ' gltrace::releaseContext((uintptr_t)ctx);' GlTracer.traceFunctionImplBody(self, function) - if function.name == 'glXCreateContext': + if function.name in self.createContextFunctionNames: print ' if (_result != NULL)' print ' gltrace::createContext((uintptr_t)_result);' - if function.name == 'glXMakeCurrent': + if function.name in self.makeCurrentFunctionNames: print ' if (_result) {' print ' if (ctx != NULL)' print ' gltrace::setContext((uintptr_t)ctx);' diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index 1b00357..317c542 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -39,8 +39,24 @@ class WglTracer(GlTracer): "wglGetProcAddress", ] + createContextFunctionNames = [ + 'wglCreateContext', + 'wglCreateContextAttribsARB', + 'wglCreateLayerContext', + ] + + destroyContextFunctionNames = [ + 'wglDeleteContext', + ] + + makeCurrentFunctionNames = [ + 'wglMakeCurrent', + 'wglMakeContextCurrentARB', + 'wglMakeContextCurrentEXT', + ] + def traceFunctionImplBody(self, function): - if function.name == 'wglDeleteContext': + if function.name in self.destroyContextFunctionNames: # Unlike other GL APIs like EGL or GLX, WGL will make the context # inactive if it's currently the active context. print ' if (_wglGetCurrentContext() == hglrc) {' @@ -50,11 +66,11 @@ class WglTracer(GlTracer): GlTracer.traceFunctionImplBody(self, function) - if function.name == 'wglCreateContext': + if function.name in self.createContextFunctionNames: print ' if (_result)' print ' gltrace::createContext((uintptr_t)_result);' - if function.name == 'wglMakeCurrent': + if function.name in self.makeCurrentFunctionNames: print ' if (_result) {' print ' if (hglrc != NULL)' print ' gltrace::setContext((uintptr_t)hglrc);'