+ if (lastVsizeUsage < call.vsizeStart + call.vsizeDuration) {
+ lastVsizeUsage = call.vsizeStart + call.vsizeDuration;
+ }
+
+ if (lastRssUsage < call.rssStart + call.rssDuration) {
+ lastRssUsage = call.rssStart + call.rssDuration;
+ }
+
+ profile->calls.push_back(call);
+
+ if (call.pixels >= 0) {
+ if (profile->programs.size() <= call.program) {
+ profile->programs.resize(call.program + 1);
+ }
+
+ Profile::Program& program = profile->programs[call.program];
+ program.cpuTotal += call.cpuDuration;
+ program.gpuTotal += call.gpuDuration;
+ program.pixelTotal += call.pixels;
+ program.vsizeTotal += call.vsizeDuration;
+ program.rssTotal += call.rssDuration;
+ program.calls.push_back(profile->calls.size() - 1);
+ }
+ } else if (type.compare("frame_end") == 0) {
+ Profile::Frame frame;
+ frame.no = profile->frames.size();
+
+ if (frame.no == 0) {
+ frame.gpuStart = 0;
+ frame.cpuStart = 0;
+ frame.vsizeStart = 0;
+ frame.rssStart = 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.vsizeStart = profile->frames.back().vsizeStart + profile->frames.back().vsizeDuration;
+ frame.rssStart = profile->frames.back().rssStart + profile->frames.back().rssDuration;
+ frame.calls.begin = profile->frames.back().calls.end + 1;
+ }
+
+ frame.gpuDuration = lastGpuTime - frame.gpuStart;
+ frame.cpuDuration = lastCpuTime - frame.cpuStart;
+ frame.vsizeDuration = lastVsizeUsage - frame.vsizeStart;
+ frame.rssDuration = lastRssUsage - frame.rssStart;
+ frame.calls.end = profile->calls.size() - 1;
+
+ profile->frames.push_back(frame);
+ }