]> git.cworth.org Git - apitrace/blobdiff - retrace/retrace_main.cpp
glstate: Don't dump garbage when glReadPixels fail.
[apitrace] / retrace / retrace_main.cpp
index 2d3311fedb9cb68131c0b5fba4dd3598dc3e36fc..5e31c020490ab86beccb3635914fa82d9e83d479 100644 (file)
@@ -46,6 +46,11 @@ static bool loopOnFinish = false;
 
 static const char *comparePrefix = NULL;
 static const char *snapshotPrefix = NULL;
+static enum {
+    PNM_FMT,
+    RAW_RGB
+} snapshotFormat = PNM_FMT;
+
 static trace::CallSet snapshotFrequency;
 static trace::CallSet compareFrequency;
 static trace::ParseBookmark lastFrameStart;
@@ -128,7 +133,10 @@ takeSnapshot(unsigned call_no) {
             char comment[21];
             snprintf(comment, sizeof comment, "%u",
                      useCallNos ? call_no : snapshot_no);
-            src->writePNM(std::cout, comment);
+            if (snapshotFormat == RAW_RGB)
+                src->writeRAW(std::cout);
+            else
+                src->writePNM(std::cout, comment);
         } else {
             os::String filename = os::String::format("%s%010u.png",
                                                      snapshotPrefix,
@@ -276,6 +284,12 @@ public:
         }
     }
 
+    ~RelayRunner() {
+        if (thread.joinable()) {
+            thread.join();
+        }
+    }
+
     /**
      * Thread main loop.
      */
@@ -567,6 +581,7 @@ usage(const char *argv0) {
         "      --driver=DRIVER     force driver type (`hw`, `sw`, `ref`, `null`, or driver module name)\n"
         "      --sb                use a single buffer visual\n"
         "  -s, --snapshot-prefix=PREFIX    take snapshots; `-` for PNM stdout output\n"
+        "      --snapshot-format=FMT       use (PNM or RGB; default is PNM) when writing to stdout output\n"
         "  -S, --snapshot=CALLSET  calls to snapshot (default is every frame)\n"
         "  -v, --verbose           increase output verbosity\n"
         "  -D, --dump-state=CALL   dump state at specific call no\n"
@@ -585,6 +600,7 @@ enum {
     PPD_OPT,
     PMEM_OPT,
     SB_OPT,
+    SNAPSHOT_FORMAT_OPT,
     LOOP_OPT,
     SINGLETHREAD_OPT
 };
@@ -609,6 +625,7 @@ longOptions[] = {
     {"pmem", no_argument, 0, PMEM_OPT},
     {"sb", no_argument, 0, SB_OPT},
     {"snapshot-prefix", required_argument, 0, 's'},
+    {"snapshot-format", required_argument, 0, SNAPSHOT_FORMAT_OPT},
     {"snapshot", required_argument, 0, 'S'},
     {"verbose", no_argument, 0, 'v'},
     {"wait", no_argument, 0, 'w'},
@@ -699,6 +716,12 @@ int main(int argc, char **argv)
                 retrace::verbosity = -2;
             }
             break;
+       case SNAPSHOT_FORMAT_OPT:
+            if (strcmp(optarg, "RGB") == 0)
+                snapshotFormat = RAW_RGB;
+            else
+                snapshotFormat = PNM_FMT;
+            break;
         case 'S':
             snapshotFrequency = trace::CallSet(optarg);
             if (snapshotPrefix == NULL) {