]> git.cworth.org Git - apitrace/commitdiff
Use call number instead of frame number for snapshot filenames.
authorMichel Dänzer <daenzer@vmware.com>
Thu, 24 Feb 2011 17:20:52 +0000 (09:20 -0800)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 14 Apr 2011 10:57:34 +0000 (11:57 +0100)
This will allow changing the granularity of taking snapshots while preserving
the comparability of snapshots from different runs.

glretrace_main.cpp
scripts/snapdiff.py

index 52619dd211c1ed4b7376fb1cee29933a046fa64b..d0fb5789ca314b0a22495e81bc4d2139e92e2d6c 100644 (file)
@@ -111,14 +111,14 @@ static void snapshot(Image::Image &image) {
 }
 
 
-static void frame_complete(void) {
+static void frame_complete(unsigned call_no) {
     ++frame;
     
     if (snapshot_prefix || compare_prefix) {
         Image::Image *ref = NULL;
         if (compare_prefix) {
             char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%04u.png", compare_prefix, frame);
+            snprintf(filename, sizeof filename, "%s%010u.png", compare_prefix, call_no);
             ref = Image::readPNG(filename);
             if (!ref) {
                 return;
@@ -132,19 +132,18 @@ static void frame_complete(void) {
 
         if (snapshot_prefix) {
             char filename[PATH_MAX];
-            snprintf(filename, sizeof filename, "%s%04u.png", snapshot_prefix, frame);
+            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 << "Frame " << frame << " average precision of " << src.compare(*ref) << " bits\n";
+            std::cout << "Snapshot " << call_no << " average precision of " << src.compare(*ref) << " bits\n";
             delete ref;
         }
     }
-    
-    ws->processEvents();
+
 }
 
 
@@ -163,7 +162,7 @@ static void display(void) {
                     std::cout << *call;
                     std::cout.flush();
                 };
-                frame_complete();
+                frame_complete(call->no);
                 if (double_buffer)
                     drawable->swapBuffers();
                 else
@@ -172,7 +171,7 @@ static void display(void) {
                        name == "wglMakeCurrent") {
                 glFlush();
                 if (!double_buffer) {
-                    frame_complete();
+                    frame_complete(call->no);
                 }
             } else {
                 continue;
@@ -182,7 +181,7 @@ static void display(void) {
         if (name == "glFlush") {
             glFlush();
             if (!double_buffer) {
-                frame_complete();
+                frame_complete(call->no);
             }
         }
         
index 129adedf6ec868dcd0b42f5932dda795797f5534..d99a4acf81b0aaeb7791d2027ec368dd6d0c9578 100755 (executable)
@@ -67,11 +67,11 @@ def main():
         help="output filename [stdout]")
     optparser.add_option(
         '--start', metavar='FRAME',
-        type="int", dest="start", default=1,
+        type="int", dest="start", default=0,
         help="start frame [default: %default]")
     optparser.add_option(
         '--stop', metavar='FRAME',
-        type="int", dest="stop", default=9999,
+        type="int", dest="stop", default=0xffffffff,
         help="stop frame [default: %default]")
     optparser.add_option(
         '-f', '--fuzz',
@@ -94,10 +94,11 @@ def main():
     html.write('  <body>\n')
     html.write('    <table border="1">\n')
     html.write('      <tr><th>ref</th><th>src</th><th>&Delta;</th></tr>\n')
-    for frame_no in range(options.start, options.stop + 1):
-        ref_image = "%s%04u.png" % (ref_prefix, frame_no)
-        src_image = "%s%04u.png" % (src_prefix, frame_no)
-        delta_image = "%s%04u_diff.png" % (src_prefix, frame_no)
+    frame_no = options.start
+    while frame_no <= options.stop:
+        ref_image = "%s%010u.png" % (ref_prefix, frame_no)
+        src_image = "%s%010u.png" % (src_prefix, frame_no)
+        delta_image = "%s%010u_diff.png" % (src_prefix, frame_no)
         if os.path.exists(ref_image) and os.path.exists(src_image):
             html.write('      <tr>\n')
             subprocess.call(["compare", '-metric', 'AE', '-fuzz', options.fuzz, ref_image, src_image, delta_image])
@@ -106,6 +107,7 @@ def main():
             surface(html, delta_image)
             html.write('      </tr>\n')
             html.flush()
+        frame_no += 1
     html.write('    </table>\n')
     html.write('  </body>\n')
     html.write('</html>\n')