VTK  9.0.20201128
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
vtkOpenGLRenderTimerLog::OGLFrame::Events
std::vector< OGLEvent > Events
Definition: vtkOpenGLRenderTimerLog.h:53
vtkOpenGLRenderTimerLog::OGLFrame::ChildCount
unsigned int ChildCount
Definition: vtkOpenGLRenderTimerLog.h:52
vtkOpenGLRenderTimerLog
OpenGL2 override for vtkRenderTimerLog.
Definition: vtkOpenGLRenderTimerLog.h:30
fromvtkm::Convert
VTKACCELERATORSVTKMCORE_EXPORT vtkDataArray * Convert(const vtkm::cont::Field &input)
vtkRenderTimerLog::MarkFrame
virtual void MarkFrame()
Call to mark the start of a new frame, or the end of an old one.
vtkOpenGLRenderTimerLog::TimerPool
std::queue< vtkOpenGLRenderTimer * > TimerPool
Definition: vtkOpenGLRenderTimerLog.h:100
vtkOpenGLRenderTimerLog::OGLEvent::Timer
vtkOpenGLRenderTimer * Timer
Definition: vtkOpenGLRenderTimerLog.h:41
vtkOpenGLRenderTimerLog::OGLFrame
Definition: vtkOpenGLRenderTimerLog.h:45
vtkOpenGLRenderTimerLog::MinTimerPoolSize
size_t MinTimerPoolSize
Definition: vtkOpenGLRenderTimerLog.h:102
vtkRenderTimerLog.h
vtkOpenGLRenderTimer
Asynchronously measures GPU execution time for a single event.
Definition: vtkOpenGLRenderTimer.h:37
vtkOpenGLRenderTimerLog::OGLEvent::Events
std::vector< OGLEvent > Events
Definition: vtkOpenGLRenderTimerLog.h:42
vtkOpenGLRenderTimerLog::GetLoggingEnabled
bool GetLoggingEnabled() override
Overridden to do support check before returning.
Definition: vtkOpenGLRenderTimerLog.h:65
vtkRenderTimerLog::New
static vtkRenderTimerLog * New()
vtkOpenGLRenderTimerLog::PendingFrames
std::deque< OGLFrame > PendingFrames
Definition: vtkOpenGLRenderTimerLog.h:97
vtkRenderTimerLog::IsSupported
virtual bool IsSupported()
Returns true if stream timings are implemented for the current graphics backend.
vtkOpenGLRenderTimerLog::OGLEvent::Name
std::string Name
Definition: vtkOpenGLRenderTimerLog.h:40
vtkOpenGLRenderTimerLog::OGLEvent
Definition: vtkOpenGLRenderTimerLog.h:33
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkRenderTimerLog::MarkEndEvent
virtual void MarkEndEvent()
Mark the beginning or end of an event.
vtkRenderTimerLog::ReleaseGraphicsResources
virtual void ReleaseGraphicsResources()
Releases any resources allocated on the graphics device.
vtkOpenGLRenderTimerLog::CurrentFrame
OGLFrame CurrentFrame
Definition: vtkOpenGLRenderTimerLog.h:92
vtkRenderTimerLog::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkRenderTimerLog::MarkStartEvent
virtual void MarkStartEvent(const std::string &name)
Mark the beginning or end of an event.
vtkX3D::name
Definition: vtkX3D.h:225
vtkRenderTimerLog::Frame
Container for a frame's events.
Definition: vtkRenderTimerLog.h:121
vtkOpenGLRenderTimerLog::OGLEvent::OGLEvent
OGLEvent()
Definition: vtkOpenGLRenderTimerLog.h:35
vtkRenderTimerLog
Asynchronously measures GPU execution times for a series of events.
Definition: vtkRenderTimerLog.h:80
vtkRenderTimerLog::PopFirstReadyFrame
virtual Frame PopFirstReadyFrame()
Retrieve the first available frame's timing info.
vtkX3D::string
Definition: vtkX3D.h:496
vtkOpenGLRenderTimerLog::OGLFrame::OGLFrame
OGLFrame()
Definition: vtkOpenGLRenderTimerLog.h:47
vtkRenderTimerLog::FrameReady
virtual bool FrameReady()
Returns true if there are any frames ready with complete timing info.
vtkRenderTimerLog::Event
Container for a single timed event.
Definition: vtkRenderTimerLog.h:86
vtkOpenGLRenderTimerLog::ReadyFrames
std::queue< Frame > ReadyFrames
Definition: vtkOpenGLRenderTimerLog.h:98