diff options
Diffstat (limited to 'wrappers')
-rw-r--r-- | wrappers/gltrace.hpp | 6 | ||||
-rw-r--r-- | wrappers/gltrace.py | 93 | ||||
-rw-r--r-- | wrappers/gltrace_state.cpp | 4 | ||||
-rw-r--r-- | wrappers/wgltrace.py | 14 |
4 files changed, 54 insertions, 63 deletions
diff --git a/wrappers/gltrace.hpp b/wrappers/gltrace.hpp index 148bbc0c..5cc90bcf 100644 --- a/wrappers/gltrace.hpp +++ b/wrappers/gltrace.hpp @@ -31,6 +31,10 @@ #include "glfeatures.hpp" +void APIENTRY _fake_glScissor(GLint x, GLint y, GLsizei width, GLsizei height); +void APIENTRY _fake_glViewport(GLint x, GLint y, GLsizei width, GLsizei height); + + namespace gltrace { @@ -86,5 +90,3 @@ _glGetStringi_override(GLenum name, GLuint index); } /* namespace gltrace */ - - diff --git a/wrappers/gltrace.py b/wrappers/gltrace.py index 60c75a52..52ec1077 100644 --- a/wrappers/gltrace.py +++ b/wrappers/gltrace.py @@ -173,11 +173,14 @@ class GlTracer(Tracer): print r'static void _trace_user_arrays(gltrace::Context *_ctx, GLuint count);' print - print r'static void _fakeStringMarker(GLsizei len, const GLvoid * string);' + # Declare helper functions to emit fake function calls into the trace + for function in api.getAllFunctions(): + if function.name in self.fake_function_names: + print function.prototype('_fake_' + function.name) + ';' print print r'static inline void' print r'_fakeStringMarker(const std::string &s) {' - print r' _fakeStringMarker(s.length(), s.data());' + print r' _fake_glStringMarkerGREMEDY(s.length(), s.data());' print r'}' print @@ -389,15 +392,10 @@ class GlTracer(Tracer): enable_name = 'GL_%s_ARRAY' % uppercase_name # Emit a fake function - print ' {' - print ' static const trace::FunctionSig &_sig = %s ? _glEnableClientState_sig : _glDisableClientState_sig;' % flag_name - print ' unsigned _call = trace::localWriter.beginEnter(&_sig, true);' - print ' trace::localWriter.beginArg(0);' - self.serializeValue(glapi.GLenum, enable_name) - print ' trace::localWriter.endArg();' - print ' trace::localWriter.endEnter();' - print ' trace::localWriter.beginLeave(_call);' - print ' trace::localWriter.endLeave();' + print ' if (%s) {' % flag_name + print ' _fake_glEnableClientState(%s);' % enable_name + print ' } else {' + print ' _fake_glDisableClientState(%s);' % enable_name print ' }' # Warn about buggy glGet(GL_*ARRAY_SIZE) not returning GL_BGRA @@ -666,8 +664,7 @@ class GlTracer(Tracer): print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" print ' GLint location = _glGetAttribLocation(program, name);' print ' if (location >= 0) {' - bind_function = glapi.glapi.getFunctionByName('glBindAttribLocation') - self.fake_call(bind_function, ['program', 'location', 'name']) + print ' _fake_glBindAttribLocation(program, location, name);' print ' }' print ' }' print ' }' @@ -684,8 +681,7 @@ class GlTracer(Tracer): print " if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {" print ' GLint location = _glGetAttribLocationARB(programObj, name);' print ' if (location >= 0) {' - bind_function = glapi.glapi.getFunctionByName('glBindAttribLocationARB') - self.fake_call(bind_function, ['programObj', 'location', 'name']) + print ' _fake_glBindAttribLocationARB(programObj, location, name);' print ' }' print ' }' print ' }' @@ -910,9 +906,34 @@ class GlTracer(Tracer): Tracer.serializeArgValue(self, function, arg) + fake_function_names = [ + 'glBindAttribLocation', + 'glBindAttribLocationARB', + 'glBindBuffer', + 'glBitmap', + 'glClientActiveTexture', + 'glDisableClientState', + 'glEnableClientState', + 'glEndList', + 'glNewList', + 'glScissor', + 'glStringMarkerGREMEDY', + 'glTexImage2D', + 'glViewport', + ] + def footer(self, api): Tracer.footer(self, api) + # Generate helper functions to emit fake function calls into the trace + for function in api.getAllFunctions(): + if function.name in self.fake_function_names: + print function.prototype('_fake_' + function.name) + print r'{' + self.fake_call(function, function.argNames()) + print r'}' + print + # A simple state tracker to track the pointer values # update the state print 'static void _trace_user_arrays(gltrace::Context *_ctx, GLuint count)' @@ -929,7 +950,7 @@ class GlTracer(Tracer): # Temporarily unbind the array buffer print ' GLint _array_buffer = _glGetInteger(GL_ARRAY_BUFFER_BINDING);' print ' if (_array_buffer) {' - self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '0') + print ' _fake_glBindBuffer(GL_ARRAY_BUFFER, 0);' print ' }' print @@ -1043,19 +1064,13 @@ class GlTracer(Tracer): # Restore the original array_buffer print ' if (_array_buffer) {' - self.fake_glBindBuffer(api, 'GL_ARRAY_BUFFER', '_array_buffer') + print ' _fake_glBindBuffer(GL_ARRAY_BUFFER, _array_buffer);' print ' }' print print '}' print - # Fake glStringMarkerGREMEDY - print r'static void _fakeStringMarker(GLsizei len, const GLvoid * string) {' - glStringMarkerGREMEDY = api.getFunctionByName('glStringMarkerGREMEDY') - self.fake_call(glStringMarkerGREMEDY, ['len', 'string']) - print r'}' - # # Hooks for glTexCoordPointer, which is identical to the other array # pointers except the fact that it is indexed by glClientActiveTexture. @@ -1098,41 +1113,15 @@ class GlTracer(Tracer): if uppercase_name == 'TEXTURE_COORD': print ' if (texture != client_active_texture || client_active_texture_dirty) {' print ' client_active_texture_dirty = true;' - self.fake_glClientActiveTexture_call(api, "texture"); + print ' _fake_glClientActiveTexture(texture);' print ' }' def array_trace_epilog(self, api, uppercase_name): if uppercase_name == 'TEXTURE_COORD': print ' if (client_active_texture_dirty) {' - self.fake_glClientActiveTexture_call(api, "client_active_texture"); + print ' _fake_glClientActiveTexture(client_active_texture);' print ' }' - def fake_glBindBuffer(self, api, target, buffer): - function = api.getFunctionByName('glBindBuffer') - self.fake_call(function, [target, buffer]) - - def fake_glClientActiveTexture_call(self, api, texture): - function = api.getFunctionByName('glClientActiveTexture') - self.fake_call(function, [texture]) - def emitFakeTexture2D(self): - function = glapi.glapi.getFunctionByName('glTexImage2D') - instances = function.argNames() - print ' unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig, true);' % (function.name,) - for arg in function.args: - assert not arg.output - self.serializeArg(function, arg) - print ' trace::localWriter.endEnter();' - print ' trace::localWriter.beginLeave(_fake_call);' - print ' trace::localWriter.endLeave();' - - - - - - - - - - + print r' _fake_glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);' diff --git a/wrappers/gltrace_state.cpp b/wrappers/gltrace_state.cpp index 20d80ba9..8848d21c 100644 --- a/wrappers/gltrace_state.cpp +++ b/wrappers/gltrace_state.cpp @@ -170,8 +170,8 @@ void setContext(uintptr_t context_id) * we might be called before both are set, so ignore empty boxes. */ if (viewport[2] && viewport[3] && scissor[2] && scissor[3]) { - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); - glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); + _fake_glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + _fake_glScissor(scissor[0], scissor[1], scissor[2], scissor[3]); ctx->boundDrawable = true; } } diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index 29081bde..d4830a17 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -155,10 +155,10 @@ class WglTracer(GlTracer): print r' bmi->bmiColors[1].rgbReserved = 0;' print print r' for (DWORD i = 0; i < count; ++i) {' - self.fake_call(glNewList, ['listBase + i', 'GL_COMPILE']) - + print r' _fake_glNewList(listBase + i, GL_COMPILE);' + print print r' char cChar = first + i;' - + print print r' // TODO: Use GetCharABSWidths' print r' // http://www.codeproject.com/Articles/14915/Width-of-text-in-italic-font' print r' // https://support.microsoft.com/en-us/kb/94646' @@ -212,12 +212,12 @@ class WglTracer(GlTracer): # FIXME: glPixelStorei(GL_UNPACK_ROW_LENGTH, width); # FIXME: glPixelStorei(GL_UNPACK_ALIGNMENT, 4); - - self.fake_call(glBitmap, ['width', 'height', 'xorig', 'yorig', 'xmove', 'ymove', 'bitmap']) - + print + print r' _fake_glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap);' + print print r' free(lpvBits);' print r' }' - self.fake_call(glEndList, []) + print r' _fake_glEndList();' print r' }' print print r' DeleteDC(memDC);' |