VTK  9.2.6
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() VTK_FUTURE_CONST override;
61 
65  bool GetLoggingEnabled() VTK_FUTURE_CONST 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() VTK_FUTURE_CONST;
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
OpenGL2 override for vtkRenderTimerLog.
virtual void MarkFrame()
Call to mark the start of a new frame, or the end of an old one.
std::deque< OGLFrame > PendingFrames
static vtkRenderTimerLog * New()
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:39
VTKACCELERATORSVTKMCORE_EXPORT vtkDataArray * Convert(const vtkm::cont::Field &input)
Container for a frame's events.
virtual void MarkStartEvent(const std::string &name)
Mark the beginning or end of an event.
virtual void MarkEndEvent()
Mark the beginning or end of an event.
virtual bool IsSupported() VTK_FUTURE_CONST
Returns true if stream timings are implemented for the current graphics backend.
virtual bool FrameReady()
Returns true if there are any frames ready with complete timing info.
virtual void ReleaseGraphicsResources()
Releases any resources allocated on the graphics device.
virtual Frame PopFirstReadyFrame()
Retrieve the first available frame's timing info.
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.