]> git.cworth.org Git - apitrace/commitdiff
Take snapshot but don't count glReadPixels as frames.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 10 May 2011 19:36:11 +0000 (20:36 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Tue, 10 May 2011 19:36:11 +0000 (20:36 +0100)
Based on a change by Michel Danzer.

glretrace.hpp
glretrace.py
glretrace_main.cpp

index 5a55edb5faa77db06348f228835fba2bcd9c2a50..2593040c6ae096abbf872e35ff34c711bb8923ec 100644 (file)
@@ -59,6 +59,7 @@ checkGlError(Trace::Call &call);
 void retrace_call_glx(Trace::Call &call);
 void retrace_call_wgl(Trace::Call &call);
 
+void snapshot(unsigned call_no);
 void frame_complete(unsigned call_no);
 
 void state_dump(std::ostream &os);
index 706dbb44d78f3d9da5be6c41f99105e501404e44..ec9957da0e32b0d01e4810967057df646f9ac08c 100644 (file)
@@ -132,7 +132,7 @@ class GlRetracer(Retracer):
 
         if function.name == 'glReadPixels':
             print '    glFinish();'
-            print '    glretrace::frame_complete(call.no);'
+            print '    glretrace::snapshot(call.no);'
 
     def call_function(self, function):
         if function.name == "glViewport":
index abed8ed577d8fd9fad9fb883bc14cb9bf8eb73fa..a9ef1579b14d5fbec9288b971e494bca13f1dc92 100644 (file)
@@ -106,7 +106,7 @@ checkGlError(Trace::Call &call) {
 }
 
 
-static void snapshot(Image::Image &image) {
+static void color_snapshot(Image::Image &image) {
     GLint drawbuffer = double_buffer ? GL_BACK : GL_FRONT;
     GLint readbuffer = double_buffer ? GL_BACK : GL_FRONT;
     glGetIntegerv(GL_DRAW_BUFFER, &drawbuffer);
@@ -131,40 +131,48 @@ static void snapshot(Image::Image &image) {
 }
 
 
-void frame_complete(unsigned call_no) {
-    ++frame;
-    
-    if (drawable &&
-        (snapshot_prefix || compare_prefix)) {
-        Image::Image *ref = NULL;
-        if (compare_prefix) {
-            char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%010u.png", compare_prefix, call_no);
-            ref = Image::readPNG(filename);
-            if (!ref) {
-                return;
-            }
-            if (retrace::verbosity >= 0)
-                std::cout << "Read " << filename << "\n";
+void snapshot(unsigned call_no) {
+    if (!drawable ||
+        (!snapshot_prefix && !compare_prefix)) {
+        return;
+    }
+
+    Image::Image *ref = NULL;
+
+    if (compare_prefix) {
+        char filename[PATH_MAX];
+        snprintf(filename, sizeof filename, "%s%010u.png", compare_prefix, call_no);
+        ref = Image::readPNG(filename);
+        if (!ref) {
+            return;
         }
-        
-        Image::Image src(drawable->width, drawable->height, true);
-        snapshot(src);
-
-        if (snapshot_prefix) {
-            char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
-            if (src.writePNG(filename) && retrace::verbosity >= 0) {
-                std::cout << "Wrote " << filename << "\n";
-            }
+        if (retrace::verbosity >= 0) {
+            std::cout << "Read " << filename << "\n";
         }
+    }
 
-        if (ref) {
-            std::cout << "Snapshot " << call_no << " average precision of " << src.compare(*ref) << " bits\n";
-            delete ref;
+    Image::Image src(drawable->width, drawable->height, true);
+    color_snapshot(src);
+
+    if (snapshot_prefix) {
+        char filename[PATH_MAX];
+        snprintf(filename, sizeof filename, "%s%010u.png", snapshot_prefix, call_no);
+        if (src.writePNG(filename) && retrace::verbosity >= 0) {
+            std::cout << "Wrote " << filename << "\n";
         }
     }
 
+    if (ref) {
+        std::cout << "Snapshot " << call_no << " average precision of " << src.compare(*ref) << " bits\n";
+        delete ref;
+    }
+}
+
+
+void frame_complete(unsigned call_no) {
+    ++frame;
+
+    snapshot(call_no);
 }