VTK  9.0.1
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 : public vtkRenderTimerLog
31 {
32 public:
33  struct OGLEvent
34  {
36  : Timer(nullptr)
37  {
38  }
39 
42  std::vector<OGLEvent> Events;
43  };
44 
45  struct OGLFrame
46  {
48  : ChildCount(0)
49  {
50  }
51 
52  unsigned int ChildCount;
53  std::vector<OGLEvent> Events;
54  };
55 
56  static vtkOpenGLRenderTimerLog* New();
58  void PrintSelf(ostream& os, vtkIndent indent) override;
59 
60  bool IsSupported() override;
61 
65  bool GetLoggingEnabled() override { return this->DoLogging(); }
66 
67  void MarkFrame() override;
68 
69  void MarkStartEvent(const std::string& name) override;
70  void MarkEndEvent() override;
71 
72  bool FrameReady() override;
73 
74  Frame PopFirstReadyFrame() override;
75 
79  void ReleaseGraphicsResources() override;
80 
91  vtkSetMacro(MinTimerPoolSize, size_t);
92  vtkGetMacro(MinTimerPoolSize, size_t);
93 
94 protected:
96  // We use a deque since they are iterable. convention is push back, pop front
97  std::deque<OGLFrame> PendingFrames;
98  std::queue<Frame> ReadyFrames;
99 
100  std::queue<vtkOpenGLRenderTimer*> TimerPool;
101 
103 
105  ~vtkOpenGLRenderTimerLog() override;
106 
107  bool DoLogging();
108 
109  Frame Convert(const OGLFrame& oglFrame);
110  Event Convert(const OGLEvent& oglEvent);
111 
112  OGLEvent& NewEvent();
113  OGLEvent* DeepestOpenEvent();
114  OGLEvent& WalkOpenEvents(OGLEvent& event);
115 
116  vtkOpenGLRenderTimer* NewTimer();
117  void ReleaseTimer(vtkOpenGLRenderTimer* timer);
118 
119  void ReleaseOGLFrame(OGLFrame& frame);
120  void ReleaseOGLEvent(OGLEvent& event);
121 
122  void TrimTimerPool();
123 
124  void CheckPendingFrames();
125  bool IsFrameReady(OGLFrame& frame);
126  bool IsEventReady(OGLEvent& event);
127 
128  void ForceCloseFrame(OGLFrame& frame);
129  void ForceCloseEvent(OGLEvent& event);
130 
131 private:
133  void operator=(const vtkOpenGLRenderTimerLog&) = delete;
134 };
135 
136 #endif // vtkOpenGLRenderTimerLog_h
std::queue< vtkOpenGLRenderTimer * > TimerPool
std::queue< Frame > ReadyFrames
bool GetLoggingEnabled() override
Overridden to do support check before returning.
OpenGL2 override for vtkRenderTimerLog.
std::deque< OGLFrame > PendingFrames
a simple class to control print indentation
Definition: vtkIndent.h:33
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)