X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_profiler.hpp;h=dc3c4be0b0e9bafc868360366cf00f366132c9b3;hb=c53c649fae47d25824e905e3a08d7a27585ffc3f;hp=19a874f9b4fb4199c538d11aff68a161f84f12f3;hpb=addf7f90727a50040d79e6da6d59ffb031074674;p=apitrace diff --git a/common/trace_profiler.hpp b/common/trace_profiler.hpp index 19a874f..dc3c4be 100644 --- a/common/trace_profiler.hpp +++ b/common/trace_profiler.hpp @@ -27,72 +27,78 @@ #define TRACE_PROFILER_H #include +#include #include 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::iterator iterator; + typedef std::vector::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 calls; - unsigned no; - GpuTime gpu; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; + std::vector 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 setBaseTimes(int64_t gpuStart, int64_t cpuStart); + bool hasBaseTimes(); + + void addFrameStart(unsigned no, int64_t gpuStart, int64_t cpuStart); + void addFrameEnd(int64_t gpuEnd, int64_t cpuEnd); + + void addCall(unsigned no, + const char* name, + unsigned program, + int64_t pixels, + int64_t gpuStart, int64_t gpuDuration, + int64_t cpuStart, int64_t cpuDuration); + + static void parseLine(const char* line, Profile* profile); private: - uint64_t baseTime; + int64_t baseGpuTime; + int64_t baseCpuTime; + + bool cpuTimes; + bool gpuTimes; + bool pixelsDrawn; + + struct { + unsigned no; + int64_t gpuStart; + int64_t cpuStart; + } lastFrame; }; }