VTK  9.3.20240328
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 
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 
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 
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
a simple class to control print indentation
Definition: vtkIndent.h:108
OpenGL2 override for vtkRenderTimerLog.
std::queue< Frame > ReadyFrames
bool DoLogging() VTK_FUTURE_CONST
static vtkOpenGLRenderTimerLog * New()
std::queue< vtkOpenGLRenderTimer * > TimerPool
~vtkOpenGLRenderTimerLog() override
void MarkFrame() override
Call to mark the start of a new frame, or the end of an old one.
void MarkEndEvent() override
Mark the beginning or end of an event.
Frame PopFirstReadyFrame() override
Retrieve the first available frame's timing info.
std::deque< OGLFrame > PendingFrames
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void ReleaseGraphicsResources() override
Releases any resources allocated on the graphics device.
bool IsSupported() VTK_FUTURE_CONST override
Returns true if stream timings are implemented for the current graphics backend.
void MarkStartEvent(const std::string &name) override
Mark the beginning or end of an event.
bool FrameReady() override
Returns true if there are any frames ready with complete timing info.
Asynchronously measures GPU execution time for a single event.
Asynchronously measures GPU execution times for a series of events.
VTKACCELERATORSVTKMCORE_EXPORT vtkDataArray * Convert(const vtkm::cont::Field &input)
@ name
Definition: vtkX3D.h:219
@ string
Definition: vtkX3D.h:490
Container for a single timed event.
Container for a frame's events.