]> 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 c15af29fe3daf2edf9696957aa5b8b321d670fd3..164a596d4861830b775f73593e3f62b9b883a494 100644 (file)
@@ -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;
@@ -177,7 +181,7 @@ mainLoop() {
     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"
@@ -209,6 +213,8 @@ usage(const char *argv0) {
 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;
@@ -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;
 }