]> git.cworth.org Git - apitrace/blobdiff - retrace/retrace_main.cpp
Add support for basic GPU profiling of draw calls to retrace.
[apitrace] / retrace / retrace_main.cpp
index f91928beb2ee7244e5fa7c3447748dd41e8ef55e..164a596d4861830b775f73593e3f62b9b883a494 100644 (file)
@@ -35,7 +35,7 @@
 #include "retrace.hpp"
 
 
-static bool wait = false;
+static bool waitOnFinish = false;
 
 static const char *comparePrefix = NULL;
 static const char *snapshotPrefix = NULL;
@@ -49,18 +49,21 @@ namespace retrace {
 
 
 trace::Parser parser;
+trace::Profiler profiler;
 
 
 int verbosity = 0;
 bool debug = true;
 bool profiling = false;
+bool profileGPU = false;
+bool dumpingState = false;
 
 
 bool doubleBuffer = true;
 bool coreProfile = false;
 
 
-static unsigned frameNo = 0;
+unsigned frameNo = 0;
 
 
 void
@@ -122,6 +125,7 @@ mainLoop() {
     addCallbacks(retracer);
 
     long long startTime = 0; 
+    frameNo = 0;
 
     startTime = os::getTime();
     trace::Call *call;
@@ -174,10 +178,10 @@ mainLoop() {
             " average of " << (frameNo/timeInterval) << " fps\n";
     }
 
-    if (wait) {
+    if (waitOnFinish) {
         waitForInput();
     } else {
-        exit(0);
+        return;
     }
 }
 
@@ -188,7 +192,7 @@ mainLoop() {
 static void
 usage(const char *argv0) {
     std::cout << 
-        "Usage: " << argv0 << " [OPTION] TRACE\n"
+        "Usage: " << argv0 << " [OPTION] TRACE [...]\n"
         "Replay TRACE.\n"
         "\n"
         "  -b           benchmark mode (no error checking or warning messages)\n"
@@ -202,13 +206,15 @@ usage(const char *argv0) {
         "  -S CALLSET   calls to snapshot (default is every frame)\n"
         "  -v           increase output verbosity\n"
         "  -D CALLNO    dump state at specific call no\n"
-        "  -w           wait on final frame\n";
+        "  -w           waitOnFinish on final frame\n";
 }
 
 
 extern "C"
 int main(int argc, char **argv)
 {
+    using namespace retrace;
+
     assert(compareFrequency.empty());
     assert(snapshotFrequency.empty());
 
@@ -229,6 +235,8 @@ int main(int argc, char **argv)
             retrace::debug = false;
             retrace::profiling = true;
             retrace::verbosity = -1;
+        } else if (!strcmp(arg, "-pgpu")) {
+            retrace::profileGPU = true;
         } else if (!strcmp(arg, "-c")) {
             comparePrefix = argv[++i];
             if (compareFrequency.empty()) {
@@ -241,6 +249,7 @@ int main(int argc, char **argv)
             }
         } else if (!strcmp(arg, "-D")) {
             dumpStateCallNo = atoi(argv[++i]);
+            dumpingState = true;
             retrace::verbosity = -2;
         } else if (!strcmp(arg, "-core")) {
             retrace::coreProfile = true;
@@ -268,7 +277,7 @@ int main(int argc, char **argv)
         } else if (!strcmp(arg, "-v")) {
             ++retrace::verbosity;
         } else if (!strcmp(arg, "-w")) {
-            wait = true;
+            waitOnFinish = true;
         } else {
             std::cerr << "error: unknown option " << arg << "\n";
             usage(argv[0]);
@@ -289,7 +298,8 @@ int main(int argc, char **argv)
         retrace::parser.close();
     }
 
-    retrace::cleanUp();
+    // XXX: X often hangs on XCloseDisplay
+    //retrace::cleanUp();
 
     return 0;
 }