VTK  9.3.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
15 
19 class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderTimerLog : public vtkRenderTimerLog
20 {
21 public:
22  struct OGLEvent
23  {
25  : Timer(nullptr)
26  {
27  }
28 
31  std::vector<OGLEvent> Events;
32  };
33 
34  struct OGLFrame
35  {
37  : ChildCount(0)
38  {
39  }
40 
41  unsigned int ChildCount;
42  std::vector<OGLEvent> Events;
43  };
44 
45  static vtkOpenGLRenderTimerLog* New();
47  void PrintSelf(ostream& os, vtkIndent indent) override;
48 
49  bool IsSupported() VTK_FUTURE_CONST override;
50 
54  bool GetLoggingEnabled() VTK_FUTURE_CONST override { return this->DoLogging(); }
55 
56  void MarkFrame() override;
57 
58  void MarkStartEvent(const std::string& name) override;
59  void MarkEndEvent() override;
60 
61  bool FrameReady() override;
62 
63  Frame PopFirstReadyFrame() override;
64 
68  void ReleaseGraphicsResources() override;
69 
80  vtkSetMacro(MinTimerPoolSize, size_t);
81  vtkGetMacro(MinTimerPoolSize, size_t);
82 
83 protected:
85  // We use a deque since they are iterable. convention is push back, pop front
86  std::deque<OGLFrame> PendingFrames;
87  std::queue<Frame> ReadyFrames;
88 
89  std::queue<vtkOpenGLRenderTimer*> TimerPool;
90 
92 
94  ~vtkOpenGLRenderTimerLog() override;
95 
96  bool DoLogging() VTK_FUTURE_CONST;
97 
98  Frame Convert(const OGLFrame& oglFrame);
99  Event Convert(const OGLEvent& oglEvent);
100 
101  OGLEvent& NewEvent();
102  OGLEvent* DeepestOpenEvent();
103  OGLEvent& WalkOpenEvents(OGLEvent& event);
104 
105  vtkOpenGLRenderTimer* NewTimer();
106  void ReleaseTimer(vtkOpenGLRenderTimer* timer);
107 
108  void ReleaseOGLFrame(OGLFrame& frame);
109  void ReleaseOGLEvent(OGLEvent& event);
110 
111  void TrimTimerPool();
112 
113  void CheckPendingFrames();
114  bool IsFrameReady(OGLFrame& frame);
115  bool IsEventReady(OGLEvent& event);
116 
117  void ForceCloseFrame(OGLFrame& frame);
118  void ForceCloseEvent(OGLEvent& event);
119 
120 private:
122  void operator=(const vtkOpenGLRenderTimerLog&) = delete;
123 };
124 
125 VTK_ABI_NAMESPACE_END
126 #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:28
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.