#define TRACE_PROFILER_H
#include <string>
+#include <vector>
#include <stdint.h>
namespace trace
{
-class Profiler
-{
-public:
- struct GpuTime
- {
- GpuTime()
- : start(0), duration(0)
- {
- }
-
- GpuTime(uint64_t start_, uint64_t duration_)
- : start(start_), duration(duration_)
- {
- }
-
- uint64_t start;
- uint64_t duration;
- };
-
- struct Call
- {
- Call()
- : no(0)
- {
- }
-
- Call(unsigned no_, const char* name_, uint64_t gpu_start, uint64_t gpu_duration)
- : no(no_), name(name_), gpu(gpu_start, gpu_duration)
- {
- }
+struct Profile {
+ struct Call {
unsigned no;
+ int64_t gpuStart;
+ int64_t gpuDuration;
+ int64_t cpuStart;
+ int64_t cpuDuration;
+ int64_t pixels;
+ unsigned program;
std::string name;
- GpuTime gpu;
+ typedef std::vector<Call>::iterator iterator;
+ typedef std::vector<Call>::const_iterator const_iterator;
};
- struct Frame
- {
- Frame()
- : no(0)
- {
- }
+ struct Frame {
+ unsigned no;
+ int64_t gpuStart;
+ int64_t gpuDuration;
+ int64_t cpuStart;
+ int64_t cpuDuration;
- Frame(unsigned no_, uint64_t gpu_start, uint64_t gpu_duration)
- : no(no_), gpu(gpu_start, gpu_duration)
- {
- }
+ std::vector<Call> calls;
- unsigned no;
- GpuTime gpu;
+ typedef std::vector<Frame>::iterator iterator;
+ typedef std::vector<Frame>::const_iterator const_iterator;
};
+ std::vector<Frame> frames;
+};
+
+class Profiler
+{
public:
Profiler();
~Profiler();
- void addCall(const Call& call);
- void addFrame(const Frame& frame);
+ void setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_);
+
+ void addFrameStart(unsigned no, uint64_t gpuStart, uint64_t cpuStart);
+ void addFrameEnd(uint64_t gpuEnd, uint64_t cpuEnd);
+
+ void addCall(unsigned no,
+ const char* name,
+ unsigned program,
+ uint64_t pixels,
+ uint64_t gpuStart, uint64_t gpuDuration,
+ uint64_t cpuStart, uint64_t cpuDuration);
+
+ static void parseLine(const char* line, Profile* profile);
private:
- uint64_t baseTime;
+ uint64_t baseGpuTime;
+ uint64_t baseCpuTime;
+
+ bool cpuTimes;
+ bool gpuTimes;
+ bool pixelsDrawn;
+
+ struct {
+ unsigned no;
+ uint64_t gpuStart;
+ uint64_t cpuStart;
+ } lastFrame;
};
}