]> git.cworth.org Git - apitrace/blobdiff - retrace/glretrace.py
Don't show pbuffers in windows.
[apitrace] / retrace / glretrace.py
index 69a6dce6f7e20bc3ed606505d3b6b14892bcce0c..f2cc37232032387af218e300cf6b318eb43e1e3c 100644 (file)
@@ -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,7 +289,35 @@ class GlRetracer(Retracer):
             print r'    if (pipeline) {'
             print r'        _pipelineHasBeenBound = true;'
             print r'    }'
-        
+
+        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 function.name != 'glEnd':
+            print r'    if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {'
+            if profileDraw:
+                print r'        glretrace::beginProfile(call, true);'
+            else:
+                print r'        glretrace::beginProfile(call, false);'
+            print r'    }'
+
         if function.name == 'glCreateShaderProgramv':
             # When dumping state, break down glCreateShaderProgramv so that the
             # shader source can be recovered.
@@ -316,10 +349,18 @@ class GlRetracer(Retracer):
         else:
             Retracer.invokeFunction(self, function)
 
-        # Error checking
         if function.name == "glBegin":
             print '    glretrace::insideGlBeginEnd = true;'
-        elif function.name.startswith('gl'):
+
+        print r'    if (!glretrace::insideList && !glretrace::insideGlBeginEnd && retrace::profiling) {'
+        if profileDraw:
+            print r'        glretrace::endProfile(call, true);'
+        else:
+            print r'        glretrace::endProfile(call, false);'
+        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);'
@@ -436,14 +477,19 @@ class GlRetracer(Retracer):
            and 'program' not in function.argNames():
             # Determine the active program for uniforms swizzling
             print '    GLint program = -1;'
-            print '    GLint pipeline = 0;'
-            print '    if (_pipelineHasBeenBound) {'
-            print '        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);'
-            print '    }'
-            print '    if (pipeline) {'
-            print '        glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);'
+            print '    if (glretrace::insideList) {'
+            print '        // glUseProgram & glUseProgramObjectARB are display-list-able'
+            print '        program = _program_map[glretrace::currentContext->activeProgram];'
             print '    } else {'
-            print '        glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
+            print '        GLint pipeline = 0;'
+            print '        if (_pipelineHasBeenBound) {'
+            print '            glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);'
+            print '        }'
+            print '        if (pipeline) {'
+            print '            glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);'
+            print '        } else {'
+            print '            glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
+            print '        }'
             print '    }'
             print