]> git.cworth.org Git - apitrace/blobdiff - common/trace_profiler.hpp
Improved profiling capabilities.
[apitrace] / common / trace_profiler.hpp
index 19a874f9b4fb4199c538d11aff68a161f84f12f3..da60d72e532d210ada7a75bbf318a6aa8bebcf6a 100644 (file)
@@ -34,65 +34,37 @@ 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)
-        {
-        }
+    Profiler();
+    ~Profiler();
 
-        Call(unsigned no_, const char* name_, uint64_t gpu_start, uint64_t gpu_duration)
-            : no(no_), name(name_), gpu(gpu_start, gpu_duration)
-        {
-        }
+    void setup(bool cpuTimes_, bool gpuTimes_, bool pixelsDrawn_);
 
-        unsigned no;
-        std::string name;
+    void addFrameStart(unsigned no, uint64_t gpuStart, uint64_t cpuStart);
+    void addFrameEnd(uint64_t gpuEnd, uint64_t cpuEnd);
 
-        GpuTime gpu;
-    };
+    void addCall(unsigned no,
+                 const char* name,
+                 unsigned program,
+                 uint64_t pixels,
+                 uint64_t gpuStart, uint64_t gpuDuration,
+                 uint64_t cpuStart, uint64_t cpuDuration);
 
-    struct Frame
-    {
-        Frame()
-            : no(0)
-        {
-        }
+private:
+    unsigned lastProgram;
+    uint64_t baseGpuTime;
+    uint64_t baseCpuTime;
 
-        Frame(unsigned no_, uint64_t gpu_start, uint64_t gpu_duration)
-            : no(no_), gpu(gpu_start, gpu_duration)
-        {
-        }
+    bool cpuTimes;
+    bool gpuTimes;
+    bool pixelsDrawn;
 
+    struct {
         unsigned no;
-        GpuTime gpu;
-    };
-
-public:
-    Profiler();
-    ~Profiler();
-
-    void addCall(const Call& call);
-    void addFrame(const Frame& frame);
-
-private:
-    uint64_t baseTime;
+        uint64_t gpuStart;
+        uint64_t gpuEnd;
+        uint64_t cpuStart;
+        uint64_t cpuEnd;
+    } lastFrame;
 };
 }