]> git.cworth.org Git - apitrace/blobdiff - glretrace.py
apitrace diff-images: Print one line for each file being compared.
[apitrace] / glretrace.py
index e650c54a7fdb4c4ad939f9324cc12463c5cc0424..97a6ecc1c8f07063c0ea24bf68168bbc2d09ccc4 100644 (file)
@@ -111,6 +111,8 @@ class GlRetracer(Retracer):
     ])
 
     misc_draw_function_names = set([
+        "glCallList",
+        "glCallLists",
         "glClear",
         "glEnd",
         "glDrawPixels",
@@ -120,8 +122,8 @@ class GlRetracer(Retracer):
 
     bind_framebuffer_function_names = set([
         "glBindFramebuffer",
-        "glBindFramebufferARB",
         "glBindFramebufferEXT",
+        "glBindFramebufferOES",
     ])
 
     # Names of the functions that can pack into the current pixel buffer
@@ -157,7 +159,8 @@ class GlRetracer(Retracer):
         'glMapBufferOES',
         'glMapBufferRange',
         'glMapNamedBufferEXT',
-        'glMapNamedBufferRangeEXT'
+        'glMapNamedBufferRangeEXT',
+        'glMapObjectBufferATI',
     ])
 
     unmap_function_names = set([
@@ -165,6 +168,7 @@ class GlRetracer(Retracer):
         'glUnmapBufferARB',
         'glUnmapBufferOES',
         'glUnmapNamedBufferEXT',
+        'glUnmapObjectBufferATI',
     ])
 
     def retraceFunctionBody(self, function):
@@ -197,20 +201,12 @@ class GlRetracer(Retracer):
             print '    GLint __pack_buffer = 0;'
             print '    glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &__pack_buffer);'
             print '    if (!__pack_buffer) {'
-            if function.name == 'glReadPixels':
-                print '    glFinish();'
-                print '    if (glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAME ||'
-                print '        glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAMEBUFFER) {'
-                print '        glretrace::snapshot(call.no);'
-                print '    }'
             print '        return;'
             print '    }'
 
         # Pre-snapshots
         if function.name in self.bind_framebuffer_function_names:
-            print '    if (glretrace::snapshot_frequency == glretrace::FREQUENCY_FRAMEBUFFER) {'
-            print '        glretrace::snapshot(call.no - 1);'
-            print '    }'
+            print '    assert(call.flags & trace::CALL_FLAG_SWAP_RENDERTARGET);'
         if function.name == 'glFrameTerminatorGREMEDY':
             print '    glretrace::frame_complete(call);'
             return
@@ -223,15 +219,28 @@ class GlRetracer(Retracer):
             print '        glretrace::frame_complete(call);'
             print '    }'
         if is_draw_array or is_draw_elements or is_misc_draw:
-            print '    if (glretrace::snapshot_frequency == glretrace::FREQUENCY_DRAW) {'
-            print '        glretrace::snapshot(call.no);'
-            print '    }'
+            print '    assert(call.flags & trace::CALL_FLAG_RENDER);'
 
 
     def invokeFunction(self, function):
         # Infer the drawable size from GL calls
         if function.name == "glViewport":
             print '    glretrace::updateDrawable(x + width, y + height);'
+        if function.name == "glViewportArray":
+            # We are concerned about drawables so only care for the first viewport
+            print '    if (first == 0 && count > 0) {'
+            print '        GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
+        if function.name == "glViewportIndexedf":
+            print '    if (index == 0) {'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
+        if function.name == "glViewportIndexedfv":
+            print '    if (index == 0) {'
+            print '        GLfloat x = v[0], y = v[1], w = v[2], h = v[3];'
+            print '        glretrace::updateDrawable(x + w, y + h);'
+            print '    }'
         if function.name in ('glBlitFramebuffer', 'glBlitFramebufferEXT'):
             # Some applications do all their rendering in a framebuffer, and
             # then just blit to the drawable without ever calling glViewport.
@@ -240,8 +249,35 @@ class GlRetracer(Retracer):
         if function.name == "glEnd":
             print '    glretrace::insideGlBeginEnd = false;'
 
+        if function.name.startswith('gl') and not function.name.startswith('glX'):
+            print r'    if (!glretrace::context && !glretrace::benchmark && !retrace::profiling) {'
+            print r'        retrace::warning(call) << "no current context\n";'
+            print r'    }'
+
         if function.name == 'memcpy':
             print '    if (!dest || !src || !n) return;'
+
+        # Destroy the buffer mapping
+        if function.name in self.unmap_function_names:
+            print r'        GLvoid *ptr = NULL;'
+            if function.name == 'glUnmapBuffer':
+                print r'            glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);'
+            elif function.name == 'glUnmapBufferARB':
+                print r'            glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);'
+            elif function.name == 'glUnmapBufferOES':
+                print r'            glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);'
+            elif function.name == 'glUnmapNamedBufferEXT':
+                print r'            glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);'
+            elif function.name == 'glUnmapObjectBufferATI':
+                # TODO
+                pass
+            else:
+                assert False
+            print r'        if (ptr) {'
+            print r'            retrace::delRegionByPointer(ptr);'
+            print r'        } else {'
+            print r'            retrace::warning(call) << "no current context\n";'
+            print r'        }'
         
         Retracer.invokeFunction(self, function)
 
@@ -250,7 +286,7 @@ class GlRetracer(Retracer):
             print '    glretrace::insideGlBeginEnd = true;'
         elif function.name.startswith('gl'):
             # glGetError is not allowed inside glBegin/glEnd
-            print '    if (!glretrace::benchmark && !glretrace::insideGlBeginEnd) {'
+            print '    if (!glretrace::benchmark && !retrace::profiling && !glretrace::insideGlBeginEnd) {'
             print '        glretrace::checkGlError(call);'
             if function.name in ('glProgramStringARB', 'glProgramStringNV'):
                 print r'        GLint error_position = -1;'
@@ -307,6 +343,10 @@ class GlRetracer(Retracer):
                 print r'        if (!__result) {'
                 print r'             retrace::warning(call) << "failed to map buffer\n";'
                 print r'        }'
+            if function.name in self.unmap_function_names and function.type is not stdapi.Void:
+                print r'        if (!__result) {'
+                print r'             retrace::warning(call) << "failed to unmap buffer\n";'
+                print r'        }'
             if function.name in ('glGetAttribLocation', 'glGetAttribLocationARB'):
                 print r'    GLint __orig_result = call.ret->toSInt();'
                 print r'    if (__result != __orig_result) {'
@@ -320,37 +360,23 @@ class GlRetracer(Retracer):
                 print r'    }'
             print '    }'
 
-            # Query the buffer length for whole buffer mappings
-            if function.name in self.map_function_names:
-                if 'length' in function.argNames():
-                    assert 'BufferRange' in function.name
-                else:
-                    assert 'BufferRange' not in function.name
-                    print r'    GLint length = 0;'
-                    if function.name in ('glMapBuffer', 'glMapBufferOES'):
-                        print r'    glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);'
-                    elif function.name == 'glMapBufferARB':
-                        print r'    glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);'
-                    elif function.name == 'glMapNamedBufferEXT':
-                        print r'    glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);'
-                    else:
-                        assert False
-            # Destroy the buffer mapping
-            if function.name in self.unmap_function_names:
-                print r'        GLvoid *ptr = NULL;'
-                if function.name == 'glUnmapBuffer':
-                    print r'            glGetBufferPointerv(target, GL_BUFFER_MAP_POINTER, &ptr);'
-                elif function.name == 'glUnmapBufferARB':
-                    print r'            glGetBufferPointervARB(target, GL_BUFFER_MAP_POINTER_ARB, &ptr);'
-                elif function.name == 'glUnmapBufferOES':
-                    print r'            glGetBufferPointervOES(target, GL_BUFFER_MAP_POINTER_OES, &ptr);'
-                elif function.name == 'glUnmapNamedBufferEXT':
-                    print r'            glGetNamedBufferPointervEXT(buffer, GL_BUFFER_MAP_POINTER, &ptr);'
+        # Query the buffer length for whole buffer mappings
+        if function.name in self.map_function_names:
+            if 'length' in function.argNames():
+                assert 'BufferRange' in function.name
+            else:
+                assert 'BufferRange' not in function.name
+                print r'    GLint length = 0;'
+                if function.name in ('glMapBuffer', 'glMapBufferOES'):
+                    print r'    glGetBufferParameteriv(target, GL_BUFFER_SIZE, &length);'
+                elif function.name == 'glMapBufferARB':
+                    print r'    glGetBufferParameterivARB(target, GL_BUFFER_SIZE_ARB, &length);'
+                elif function.name == 'glMapNamedBufferEXT':
+                    print r'    glGetNamedBufferParameterivEXT(buffer, GL_BUFFER_SIZE, &length);'
+                elif function.name == 'glMapObjectBufferATI':
+                    print r'    glGetObjectBufferivATI(buffer, GL_OBJECT_BUFFER_SIZE_ATI, &length);'
                 else:
                     assert False
-                print r'        if (ptr) {'
-                print r'            retrace::delRegionByPointer(ptr);'
-                print r'        }'
 
     def extractArg(self, function, arg, arg_type, lvalue, rvalue):
         if function.name in self.array_pointer_function_names and arg.name == 'pointer':