X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fglretrace.py;h=987798fe6a0c5cab01eb015a93ef62f708a50aea;hb=d9a73568b0a26c57d0fac8ee97550d0989b9c321;hp=857c1b5fa551493a9d258520b4935ce8cf0713dc;hpb=b79e26a00692e8d420727ae29f3e8f823e518632;p=apitrace diff --git a/retrace/glretrace.py b/retrace/glretrace.py index 857c1b5..987798f 100644 --- a/retrace/glretrace.py +++ b/retrace/glretrace.py @@ -257,6 +257,11 @@ class GlRetracer(Retracer): if function.name == 'memcpy': print ' if (!dest || !src || !n) return;' + # Skip glEnable/Disable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) as we don't + # faithfully set the CONTEXT_DEBUG_BIT_ARB flags on context creation. + if function.name in ('glEnable', 'glDisable'): + print ' if (cap == GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB) return;' + # Destroy the buffer mapping if function.name in self.unmap_function_names: print r' GLvoid *ptr = NULL;' @@ -284,13 +289,73 @@ class GlRetracer(Retracer): print r' if (pipeline) {' print r' _pipelineHasBeenBound = true;' print r' }' - - Retracer.invokeFunction(self, function) - # Error checking + profileDraw = ( + function.name in self.draw_array_function_names or + function.name in self.draw_elements_function_names or + function.name in self.draw_indirect_function_names or + function.name in self.misc_draw_function_names or + function.name == 'glBegin' + ) + + if function.name in ('glUseProgram', 'glUseProgramObjectARB'): + print r' if (glretrace::currentContext) {' + print r' glretrace::currentContext->activeProgram = call.arg(0).toUInt();' + print r' }' + + # Only profile if not inside a list as the queries get inserted into list + if function.name == 'glNewList': + print r' glretrace::insideList = true;' + + if function.name == 'glEndList': + print r' glretrace::insideList = false;' + + if profileDraw and function.name != 'glEnd': + print r' if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {' + print r' glretrace::beginProfile(call);' + print r' }' + + if function.name == 'glCreateShaderProgramv': + # When dumping state, break down glCreateShaderProgramv so that the + # shader source can be recovered. + print r' if (retrace::dumpingState) {' + print r' GLuint _shader = glCreateShader(type);' + print r' if (_shader) {' + print r' glShaderSource(_shader, count, strings, NULL);' + print r' glCompileShader(_shader);' + print r' const GLuint _program = glCreateProgram();' + print r' if (_program) {' + print r' GLint compiled = GL_FALSE;' + print r' glGetShaderiv(_shader, GL_COMPILE_STATUS, &compiled);' + print r' glProgramParameteri(_program, GL_PROGRAM_SEPARABLE, GL_TRUE);' + print r' if (compiled) {' + print r' glAttachShader(_program, _shader);' + print r' glLinkProgram(_program);' + print r' //glDetachShader(_program, _shader);' + print r' }' + print r' //append-shader-info-log-to-program-info-log' + print r' }' + print r' //glDeleteShader(_shader);' + print r' _result = _program;' + print r' } else {' + print r' _result = 0;' + print r' }' + print r' } else {' + Retracer.invokeFunction(self, function) + print r' }' + else: + Retracer.invokeFunction(self, function) + if function.name == "glBegin": print ' glretrace::insideGlBeginEnd = true;' - elif function.name.startswith('gl'): + + if profileDraw or function.name == 'glEnd': + print r' if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {' + print r' glretrace::endProfile(call);' + print r' }' + + # Error checking + if function.name.startswith('gl'): # glGetError is not allowed inside glBegin/glEnd print ' if (retrace::debug && !glretrace::insideGlBeginEnd) {' print ' glretrace::checkGlError(call);'