This will note the time that each traced call required, and will dump
this information during the replay, giving a basic idea of where CPU
time was spent in the GL.
Signed-off-by: José Fonseca <jose.r.fonseca@gmail.com>
void visit(Call *call) {
CallFlags callFlags = call->flags;
void visit(Call *call) {
CallFlags callFlags = call->flags;
+
+ if (!(dumpFlags & DUMP_FLAG_NO_CALL_NO)) {
+ os << call->no << " ";
+ }
if (callFlags & CALL_FLAG_NON_REPRODUCIBLE) {
os << strike;
if (callFlags & CALL_FLAG_NON_REPRODUCIBLE) {
os << strike;
void dump(Call &call, std::ostream &os, DumpFlags flags) {
Dumper d(os, flags);
void dump(Call &call, std::ostream &os, DumpFlags flags) {
Dumper d(os, flags);
enum {
DUMP_FLAG_NO_COLOR = (1 << 0),
DUMP_FLAG_NO_ARG_NAMES = (1 << 1),
enum {
DUMP_FLAG_NO_COLOR = (1 << 0),
DUMP_FLAG_NO_ARG_NAMES = (1 << 1),
+ DUMP_FLAG_NO_CALL_NO = (1 << 2),
print ' glretrace::insideGlBeginEnd = true;'
elif function.name.startswith('gl'):
# glGetError is not allowed inside glBegin/glEnd
print ' glretrace::insideGlBeginEnd = true;'
elif function.name.startswith('gl'):
# glGetError is not allowed inside glBegin/glEnd
- print ' if (!glretrace::benchmark && !glretrace::insideGlBeginEnd) {'
+ print ' if (!glretrace::benchmark && !retrace::profiling && !glretrace::insideGlBeginEnd) {'
print ' glretrace::checkGlError(call);'
if function.name in ('glProgramStringARB', 'glProgramStringNV'):
print r' GLint error_position = -1;'
print ' glretrace::checkGlError(call);'
if function.name in ('glProgramStringARB', 'glProgramStringNV'):
print r' GLint error_position = -1;'
long long endTime = os::getTime();
float timeInterval = (endTime - startTime) * (1.0 / os::timeFrequency);
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,"
std::cout <<
"Rendered " << frame << " frames"
" in " << timeInterval << " secs,"
"Replay TRACE.\n"
"\n"
" -b benchmark mode (no error checking or warning messages)\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"
" -c PREFIX compare against snapshots\n"
" -C CALLSET calls to compare (default is every frame)\n"
" -core use core profile\n"
" -c PREFIX compare against snapshots\n"
" -C CALLSET calls to compare (default is every frame)\n"
" -core use core profile\n"
benchmark = true;
retrace::verbosity = -1;
glws::debug = false;
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()) {
} else if (!strcmp(arg, "-c")) {
compare_prefix = argv[++i];
if (compare_frequency.empty()) {
#include <string.h>
#include <iostream>
#include <string.h>
#include <iostream>
#include "trace_dump.hpp"
#include "retrace.hpp"
#include "trace_dump.hpp"
#include "retrace.hpp"
static bool call_dumped = false;
static bool call_dumped = false;
assert(callback);
assert(callbacks[id] == callback);
assert(callback);
assert(callbacks[id] == callback);
+ if (retrace::profiling) {
+ long long startTime = os::getTime();
+ callback(call);
+ long long stopTime = os::getTime();
+ float timeInterval = (stopTime - startTime) * (1.0E6 / os::timeFrequency);
+
+ std::cout
+ << call.no << " "
+ << "[" << timeInterval << " usec] "
+ ;
+ trace::dump(call, std::cout, trace::DUMP_FLAG_NO_CALL_NO | trace::DUMP_FLAG_NO_COLOR);
+ } else {
+ callback(call);
+ }
+/**
+ * Add profiling data to the dump when retracing.
+ */
+extern bool profiling;
+
std::ostream &warning(trace::Call &call);
std::ostream &warning(trace::Call &call);