X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_profiler.cpp;h=0f90ee2766318c54f790fc110efd772b8126f309;hb=93d51c3065260cdb088f33d3e6d5bdfb4707c1a9;hp=642ba6e88325560e235dd1d9cab0bc2aa6e023d2;hpb=56ad11c7849c7e6ca0ad66558cb1a99c58d4cd3d;p=apitrace diff --git a/common/trace_profiler.cpp b/common/trace_profiler.cpp index 642ba6e..0f90ee2 100644 --- a/common/trace_profiler.cpp +++ b/common/trace_profiler.cpp @@ -136,7 +136,7 @@ void Profiler::parseLine(const char* in, Profile* profile) if (in[0] == '#' || strlen(in) < 4) return; - if (profile->programs.size() == 0 && profile->cpuCalls.size() == 0 && profile->frames.size() == 0) { + if (profile->programs.size() == 0 && profile->calls.size() == 0 && profile->frames.size() == 0) { lastGpuTime = 0; lastCpuTime = 0; } @@ -144,43 +144,38 @@ void Profiler::parseLine(const char* in, Profile* profile) line >> type; if (type.compare("call") == 0) { - Profile::DrawCall draw; - unsigned program; - - line >> draw.no - >> draw.gpuStart - >> draw.gpuDuration - >> draw.cpuStart - >> draw.cpuDuration - >> draw.pixels - >> program - >> draw.name; - - if (lastGpuTime < draw.gpuStart + draw.gpuDuration) { - lastGpuTime = draw.gpuStart + draw.gpuDuration; + Profile::Call call; + + line >> call.no + >> call.gpuStart + >> call.gpuDuration + >> call.cpuStart + >> call.cpuDuration + >> call.pixels + >> call.program + >> call.name; + + if (lastGpuTime < call.gpuStart + call.gpuDuration) { + lastGpuTime = call.gpuStart + call.gpuDuration; } - if (lastCpuTime < draw.cpuStart + draw.cpuDuration) { - lastCpuTime = draw.cpuStart + draw.cpuDuration; + if (lastCpuTime < call.cpuStart + call.cpuDuration) { + lastCpuTime = call.cpuStart + call.cpuDuration; } - if (draw.pixels >= 0) { - if (profile->programs.size() <= program) { - profile->programs.resize(program + 1); + profile->calls.push_back(call); + + if (call.pixels >= 0) { + if (profile->programs.size() <= call.program) { + profile->programs.resize(call.program + 1); } - profile->programs[program].cpuTotal += draw.cpuDuration; - profile->programs[program].gpuTotal += draw.gpuDuration; - profile->programs[program].pixelTotal += draw.pixels; - profile->programs[program].drawCalls.push_back(draw); + Profile::Program& program = profile->programs[call.program]; + program.cpuTotal += call.cpuDuration; + program.gpuTotal += call.gpuDuration; + program.pixelTotal += call.pixels; + program.calls.push_back(profile->calls.size() - 1); } - - Profile::CpuCall call; - call.no = draw.no; - call.name = draw.name; - call.cpuStart = draw.cpuStart; - call.cpuDuration = draw.cpuDuration; - profile->cpuCalls.push_back(call); } else if (type.compare("frame_end") == 0) { Profile::Frame frame; frame.no = profile->frames.size(); @@ -188,13 +183,17 @@ void Profiler::parseLine(const char* in, Profile* profile) if (frame.no == 0) { frame.gpuStart = 0; frame.cpuStart = 0; + frame.calls.begin = 0; } else { frame.gpuStart = profile->frames.back().gpuStart + profile->frames.back().gpuDuration; frame.cpuStart = profile->frames.back().cpuStart + profile->frames.back().cpuDuration; + frame.calls.begin = profile->frames.back().calls.end + 1; } frame.gpuDuration = lastGpuTime - frame.gpuStart; frame.cpuDuration = lastCpuTime - frame.cpuStart; + frame.calls.end = profile->calls.size() - 1; + profile->frames.push_back(frame); } }