VTK
vtkOpenGLRenderTimerLog.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkOpenGLRenderTimerLog.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 #ifndef vtkOpenGLRenderTimerLog_h
17 #define vtkOpenGLRenderTimerLog_h
18 
19 #include "vtkRenderTimerLog.h"
20 #include "vtkRenderingOpenGL2Module.h" // For export macros
21 
22 #include <deque> // for deque!
23 #include <queue> // for queue!
24 
26 
30 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderTimerLog
31  : public vtkRenderTimerLog
32 {
33 public:
34  struct OGLEvent
35  {
36  OGLEvent() : Timer(nullptr) {}
37 
40  std::vector<OGLEvent> Events;
41  };
42 
43  struct OGLFrame
44  {
45  OGLFrame() : ChildCount(0) {}
46 
47  unsigned int ChildCount;
48  std::vector<OGLEvent> Events;
49  };
50 
51  static vtkOpenGLRenderTimerLog* New();
53  void PrintSelf(ostream &os, vtkIndent indent) override;
54 
55  bool IsSupported() override;
56 
60  bool GetLoggingEnabled() override { return this->DoLogging(); }
61 
62  void MarkFrame() override;
63 
64  void MarkStartEvent(const std::string &name) override;
65  void MarkEndEvent() override;
66 
67  bool FrameReady() override;
68 
69  Frame PopFirstReadyFrame() override;
70 
74  void ReleaseGraphicsResources() override;
75 
86  vtkSetMacro(MinTimerPoolSize, size_t)
87  vtkGetMacro(MinTimerPoolSize, size_t)
88 
89 protected:
91  // We use a deque since they are iterable. convention is push back, pop front
92  std::deque<OGLFrame> PendingFrames;
93  std::queue<Frame> ReadyFrames;
94 
95  std::queue<vtkOpenGLRenderTimer*> TimerPool;
96 
98 
100  ~vtkOpenGLRenderTimerLog() override;
101 
102  bool DoLogging();
103 
104  Frame Convert(const OGLFrame &oglFrame);
105  Event Convert(const OGLEvent &oglEvent);
106 
107  OGLEvent& NewEvent();
108  OGLEvent* DeepestOpenEvent();
109  OGLEvent& WalkOpenEvents(OGLEvent &event);
110 
111  vtkOpenGLRenderTimer* NewTimer();
112  void ReleaseTimer(vtkOpenGLRenderTimer *timer);
113 
114  void ReleaseOGLFrame(OGLFrame &frame);
115  void ReleaseOGLEvent(OGLEvent &event);
116 
117  void TrimTimerPool();
118 
119  void CheckPendingFrames();
120  bool IsFrameReady(OGLFrame &frame);
121  bool IsEventReady(OGLEvent &event);
122 
123  void ForceCloseFrame(OGLFrame &frame);
124  void ForceCloseEvent(OGLEvent &event);
125 
126 private:
128  void operator=(const vtkOpenGLRenderTimerLog&) = delete;
129 };
130 
131 #endif // vtkOpenGLRenderTimerLog_h
std::queue< vtkOpenGLRenderTimer * > TimerPool
std::queue< Frame > ReadyFrames
OpenGL2 override for vtkRenderTimerLog.
std::deque< OGLFrame > PendingFrames
a simple class to control print indentation
Definition: vtkIndent.h:39
Container for a frame&#39;s events.
Container for a single timed event.
Asynchronously measures GPU execution time for a single event.
Asynchronously measures GPU execution times for a series of events.
VTKACCELERATORSVTKM_EXPORT vtkm::cont::Field Convert(vtkDataArray *input, int association)