#include "retrace.hpp"
-static bool wait = false;
+static bool waitOnFinish = false;
static const char *comparePrefix = NULL;
static const char *snapshotPrefix = NULL;
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;
+unsigned callNo = 0;
void
addCallbacks(retracer);
long long startTime = 0;
+ frameNo = 0;
startTime = os::getTime();
trace::Call *call;
}
}
+ callNo = call->no;
retracer.retrace(*call);
if (doSnapshot && !swapRenderTarget) {
" average of " << (frameNo/timeInterval) << " fps\n";
}
- if (wait) {
+ if (waitOnFinish) {
waitForInput();
} else {
- exit(0);
+ return;
}
}
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"
- " -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"
" -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());
} 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()) {
}
} else if (!strcmp(arg, "-D")) {
dumpStateCallNo = atoi(argv[++i]);
+ dumpingState = true;
retrace::verbosity = -2;
} else if (!strcmp(arg, "-core")) {
retrace::coreProfile = true;
} else if (!strcmp(arg, "-v")) {
++retrace::verbosity;
} else if (!strcmp(arg, "-w")) {
- wait = true;
+ 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]);
}
retrace::setUp();
+ if (retrace::profiling) {
+ retrace::profiler.setup(retrace::profilingCpuTimes, retrace::profilingGpuTimes, retrace::profilingPixelsDrawn);
+ }
for ( ; i < argc; ++i) {
if (!retrace::parser.open(argv[i])) {
retrace::parser.close();
}
- retrace::cleanUp();
+ // XXX: X often hangs on XCloseDisplay
+ //retrace::cleanUp();
return 0;
}