]> git.cworth.org Git - apitrace/blobdiff - glretrace_main.cpp
Move tracers to wrappers subdirectory.
[apitrace] / glretrace_main.cpp
index f9d77413eef276c8513aa294c19af90238745934..313a563459216f4508edfa2ae836af2a0c6c3a84 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <string.h>
 
+#include "os_binary.hpp"
 #include "os_string.hpp"
 #include "os_time.hpp"
 #include "image.hpp"
@@ -40,7 +41,6 @@ namespace glretrace {
 
 bool double_buffer = true;
 bool insideGlBeginEnd = false;
-trace::Parser parser;
 glws::Profile defaultProfile = glws::PROFILE_COMPAT;
 glws::Visual *visual[glws::PROFILE_MAX];
 glws::Drawable *drawable = NULL;
@@ -213,7 +213,7 @@ static void display(void) {
     startTime = os::getTime();
     trace::Call *call;
 
-    while ((call = parser.parse_call())) {
+    while ((call = retrace::parser.parse_call())) {
         bool swapRenderTarget = call->flags & trace::CALL_FLAG_SWAP_RENDERTARGET;
         bool doSnapshot =
             snapshot_frequency.contains(*call) ||
@@ -256,7 +256,7 @@ static void display(void) {
     long long endTime = os::getTime();
     float timeInterval = (endTime - startTime) * (1.0 / os::timeFrequency);
 
-    if (retrace::verbosity >= -1) { 
+    if ((retrace::verbosity >= -1) || (retrace::profiling)) {
         std::cout << 
             "Rendered " << frame << " frames"
             " in " <<  timeInterval << " secs,"
@@ -277,6 +277,7 @@ static void usage(void) {
         "Replay TRACE.\n"
         "\n"
         "  -b           benchmark mode (no error checking or warning messages)\n"
+        "  -p           profiling mode (run whole trace, dump profiling info)\n"
         "  -c PREFIX    compare against snapshots\n"
         "  -C CALLSET   calls to compare (default is every frame)\n"
         "  -core        use core profile\n"
@@ -309,6 +310,10 @@ int main(int argc, char **argv)
             benchmark = true;
             retrace::verbosity = -1;
             glws::debug = false;
+        } else if (!strcmp(arg, "-p")) {
+            retrace::profiling = true;
+            retrace::verbosity = -1;
+            glws::debug = false;
         } else if (!strcmp(arg, "-c")) {
             compare_prefix = argv[++i];
             if (compare_frequency.empty()) {
@@ -337,6 +342,7 @@ int main(int argc, char **argv)
                 snapshot_frequency = trace::CallSet(trace::FREQUENCY_FRAME);
             }
             if (snapshot_prefix[0] == '-' && snapshot_prefix[1] == 0) {
+                os::setBinaryMode(stdout);
                 retrace::verbosity = -2;
             }
         } else if (!strcmp(arg, "-S")) {
@@ -362,14 +368,14 @@ int main(int argc, char **argv)
     visual[glws::PROFILE_ES2] = glws::createVisual(double_buffer, glws::PROFILE_ES2);
 
     for ( ; i < argc; ++i) {
-        if (!parser.open(argv[i])) {
+        if (!retrace::parser.open(argv[i])) {
             std::cerr << "error: failed to open " << argv[i] << "\n";
             return 1;
         }
 
         display();
 
-        parser.close();
+        retrace::parser.close();
     }
 
     for (int n = 0; n < glws::PROFILE_MAX; n++) {