X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=retrace%2Fretrace_main.cpp;h=5f5e095a9cbe875b5bc96fa4ae97dbe06e863d71;hb=6d92327e88d2bb4c03a1b84663e50497f99fc24f;hp=349b5a1366b1a82cf36a00ec38ea3b4872ca1378;hpb=83b46c2a02200b41f6177b6da2ba421b4fc482f7;p=apitrace diff --git a/retrace/retrace_main.cpp b/retrace/retrace_main.cpp index 349b5a1..5f5e095 100644 --- a/retrace/retrace_main.cpp +++ b/retrace/retrace_main.cpp @@ -49,18 +49,22 @@ namespace retrace { trace::Parser parser; +trace::Profiler profiler; int verbosity = 0; bool debug = true; -bool profiling = false; - +bool dumpingState = false; bool doubleBuffer = true; bool coreProfile = false; +bool profiling = false; +bool profilingGpuTimes = false; +bool profilingCpuTimes = false; +bool profilingPixelsDrawn = false; -static unsigned frameNo = 0; +unsigned frameNo = 0; void @@ -193,7 +197,9 @@ usage(const char *argv0) { "Replay TRACE.\n" "\n" " -b benchmark mode (no error checking or warning messages)\n" - " -p profiling mode (run whole trace, dump profiling info)\n" + " -pcpu cpu profiling (cpu times per call)\n" + " -pgpu gpu profiling (gpu times per draw call)\n" + " -ppd pixels drawn profiling (pixels drawn per draw call)\n" " -c PREFIX compare against snapshots\n" " -C CALLSET calls to compare (default is every frame)\n" " -core use core profile\n" @@ -210,6 +216,8 @@ usage(const char *argv0) { extern "C" int main(int argc, char **argv) { + using namespace retrace; + assert(compareFrequency.empty()); assert(snapshotFrequency.empty()); @@ -226,10 +234,6 @@ int main(int argc, char **argv) } else if (!strcmp(arg, "-b")) { retrace::debug = false; retrace::verbosity = -1; - } else if (!strcmp(arg, "-p")) { - retrace::debug = false; - retrace::profiling = true; - retrace::verbosity = -1; } else if (!strcmp(arg, "-c")) { comparePrefix = argv[++i]; if (compareFrequency.empty()) { @@ -242,6 +246,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; @@ -270,6 +275,18 @@ int main(int argc, char **argv) ++retrace::verbosity; } else if (!strcmp(arg, "-w")) { waitOnFinish = true; + } else if (arg[1] == 'p') { + retrace::debug = false; + retrace::profiling = true; + retrace::verbosity = -1; + + if (!strcmp(arg, "-pcpu")) { + retrace::profilingCpuTimes = true; + } else if (!strcmp(arg, "-pgpu")) { + retrace::profilingGpuTimes = true; + } else if (!strcmp(arg, "-ppd")) { + retrace::profilingPixelsDrawn = true; + } } else { std::cerr << "error: unknown option " << arg << "\n"; usage(argv[0]); @@ -278,6 +295,9 @@ int main(int argc, char **argv) } retrace::setUp(); + if (retrace::profiling) { + retrace::profiler.setup(retrace::profilingCpuTimes, retrace::profilingGpuTimes, retrace::profilingPixelsDrawn); + } for ( ; i < argc; ++i) { if (!retrace::parser.open(argv[i])) { @@ -290,7 +310,8 @@ int main(int argc, char **argv) retrace::parser.close(); } - retrace::cleanUp(); + // XXX: X often hangs on XCloseDisplay + //retrace::cleanUp(); return 0; }