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
30class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderTimerLog : public vtkRenderTimerLog
31{
32public:
33 struct OGLEvent
34 {
36 : Timer(nullptr)
37 {
38 }
39
40 std::string Name;
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
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
75
79 void ReleaseGraphicsResources() override;
80
91 vtkSetMacro(MinTimerPoolSize, size_t);
92 vtkGetMacro(MinTimerPoolSize, size_t);
93
94protected:
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
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
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
131private:
133 void operator=(const vtkOpenGLRenderTimerLog&) = delete;
134};
135
136#endif // vtkOpenGLRenderTimerLog_h
a simple class to control print indentation
Definition vtkIndent.h:34
OpenGL2 override for vtkRenderTimerLog.
bool DoLogging() VTK_FUTURE_CONST
std::queue< vtkOpenGLRenderTimer * > TimerPool
static vtkOpenGLRenderTimerLog * New()
~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.
Container for a single timed event.
Container for a frame's events.