VTK  9.5.20251215
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
13VTK_ABI_NAMESPACE_BEGIN
15
19class VTKRENDERINGOPENGL2_EXPORT vtkOpenGLRenderTimerLog : public vtkRenderTimerLog
20{
21public:
22 struct OGLEvent
23 {
25 : Timer(nullptr)
26 {
27 }
28
29 std::string Name;
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
83protected:
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
104
107
110
112
114 bool IsFrameReady(OGLFrame& frame);
115 bool IsEventReady(OGLEvent& event);
116
119
120private:
122 void operator=(const vtkOpenGLRenderTimerLog&) = delete;
123};
124
125VTK_ABI_NAMESPACE_END
126#endif // vtkOpenGLRenderTimerLog_h
a simple class to control print indentation
Definition vtkIndent.h:108
bool IsEventReady(OGLEvent &event)
void ForceCloseEvent(OGLEvent &event)
Frame Convert(const OGLFrame &oglFrame)
OGLEvent & WalkOpenEvents(OGLEvent &event)
bool DoLogging() VTK_FUTURE_CONST
bool IsFrameReady(OGLFrame &frame)
std::queue< vtkOpenGLRenderTimer * > TimerPool
vtkOpenGLRenderTimer * NewTimer()
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 ReleaseOGLFrame(OGLFrame &frame)
OGLEvent * DeepestOpenEvent()
void MarkEndEvent() override
Mark the beginning or end of an event.
Frame PopFirstReadyFrame() override
Retrieve the first available frame's timing info.
bool GetLoggingEnabled() VTK_FUTURE_CONST override
Overridden to do support check before returning.
std::deque< OGLFrame > PendingFrames
void ReleaseTimer(vtkOpenGLRenderTimer *timer)
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 ReleaseOGLEvent(OGLEvent &event)
void ForceCloseFrame(OGLFrame &frame)
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.
Container for a single timed event.
Container for a frame's events.