X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_parser.cpp;h=12cedac5b7b4ef054b00d952a479f1539104504b;hb=67964385bd2abb065787c52625ed19dbe08f2bf8;hp=dc9634f0d36f823b635d26c7efd7bc1a1082625f;hpb=dc9e9c6addb436b7b2d87984d4bd9b0a18d5c5e2;p=apitrace diff --git a/common/trace_parser.cpp b/common/trace_parser.cpp index dc9634f..12cedac 100644 --- a/common/trace_parser.cpp +++ b/common/trace_parser.cpp @@ -43,6 +43,7 @@ Parser::Parser() { file = NULL; next_call_no = 0; version = 0; + api = API_UNKNOWN; glGetErrorSig = NULL; } @@ -65,6 +66,7 @@ bool Parser::open(const char *filename) { std::cerr << "error: unsupported trace format version " << version << "\n"; return false; } + api = API_UNKNOWN; return true; } @@ -232,6 +234,25 @@ Parser::parse_function_sig(void) { sig->offset = file->currentOffset(); functions[id] = sig; + /** + * Try to autodetect the API. + * + * XXX: Ideally we would allow to mix multiple APIs in a single trace, + * but as it stands today, retrace is done separately for each API. + */ + if (api == API_UNKNOWN) { + const char *n = sig->name; + if ((n[0] == 'g' && n[1] == 'l' && n[2] == 'X') || // glX + (n[0] == 'w' && n[1] == 'g' && n[2] == 'g' && n[3] >= 'A' && n[3] <= 'Z') || // wgl[A-Z] + (n[0] == 'C' && n[1] == 'G' && n[2] == 'L')) { // CGL + api = trace::API_GL; + } else if (n[0] == 'e' && n[1] == 'g' && n[2] == 'l' && n[3] >= 'A' && n[3] <= 'Z') { // egl + api = trace::API_EGL; + } else { + /* TODO */ + } + } + /** * Note down the signature of special functions for future reference. *