VTK  9.7.1
vtkOpenGLRenderTimerLog.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
3 
4 #ifndef vtkOpenGLRenderTimerLog_h
5 #define vtkOpenGLRenderTimerLog_h
6 
7 #include "vtkRenderTimerLog.h"
8 #include "vtkRenderingOpenGL2Module.h" // For export macros
9 
10 #include <deque> // for deque!
11 #include <queue> // for queue!
12 
13 VTK_ABI_NAMESPACE_BEGIN
16 
20 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderTimerLog : public vtkRenderTimerLog
21 {
22 public:
23  struct OGLEvent
24  {
26  : Timer(nullptr)
27  {
28  }
29 
32  std::vector<OGLEvent> Events;
33  };
34 
35  struct OGLFrame
36  {
38  : ChildCount(0)
39  {
40  }
41 
42  unsigned int ChildCount;
43  std::vector<OGLEvent> Events;
44  };
45 
46  static vtkOpenGLRenderTimerLog* New();
48  static vtkOverrideAttribute* CreateOverrideAttributes();
50  void PrintSelf(ostream& os, vtkIndent indent) override;
51 
52  bool IsSupported() VTK_FUTURE_CONST override;
53 
57  bool GetLoggingEnabled() VTK_FUTURE_CONST override { return this->DoLogging(); }
58 
59  void MarkFrame() override;
60 
61  void MarkStartEvent(const std::string& name) override;
62  void MarkEndEvent() override;
63 
64  bool FrameReady() override;
65 
66  Frame PopFirstReadyFrame() override;
67 
71  void ReleaseGraphicsResources() override;
72 
83  vtkSetMacro(MinTimerPoolSize, size_t);
84  vtkGetMacro(MinTimerPoolSize, size_t);
85 
86 protected:
88  // We use a deque since they are iterable. convention is push back, pop front
89  std::deque<OGLFrame> PendingFrames;
90  std::queue<Frame> ReadyFrames;
91 
92  std::queue<vtkOpenGLRenderTimer*> TimerPool;
93 
95 
97  ~vtkOpenGLRenderTimerLog() override;
98 
99  bool DoLogging() VTK_FUTURE_CONST;
100 
101  Frame Convert(const OGLFrame& oglFrame);
102  Event Convert(const OGLEvent& oglEvent);
103 
104  OGLEvent& NewEvent();
105  OGLEvent* DeepestOpenEvent();
106  OGLEvent& WalkOpenEvents(OGLEvent& event);
107 
108  vtkOpenGLRenderTimer* NewTimer();
109  void ReleaseTimer(vtkOpenGLRenderTimer* timer);
110 
111  void ReleaseOGLFrame(OGLFrame& frame);
112  void ReleaseOGLEvent(OGLEvent& event);
113 
114  void TrimTimerPool();
115 
116  void CheckPendingFrames();
117  bool IsFrameReady(OGLFrame& frame);
118  bool IsEventReady(OGLEvent& event);
119 
120  void ForceCloseFrame(OGLFrame& frame);
121  void ForceCloseEvent(OGLEvent& event);
122 
123 private:
125  void operator=(const vtkOpenGLRenderTimerLog&) = delete;
126 };
127 
128 #define vtkOpenGLRenderTimerLog_OVERRIDE_ATTRIBUTES \
129  vtkOpenGLRenderTimerLog::CreateOverrideAttributes()
130 VTK_ABI_NAMESPACE_END
131 #endif // vtkOpenGLRenderTimerLog_h
Attribute for vtkObjectFactory overrides.
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:28
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.
#define VTK_NEWINSTANCE
virtual void ReleaseGraphicsResources()
Releases any resources allocated on the graphics device.
VTKACCELERATORSVTKMCORE_EXPORT vtkDataArray * Convert(const viskores::cont::Field &input)
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.