0030640: Visualization, Graphic3d_Camera - add option creating Projection matrix...
[occt.git] / src / Graphic3d / Graphic3d_FrameStatsData.hxx
CommitLineData
5e30547b 1// Copyright (c) 2018 OPEN CASCADE SAS
2//
3// This file is part of Open CASCADE Technology software library.
4//
5// This library is free software; you can redistribute it and/or modify it under
6// the terms of the GNU Lesser General Public License version 2.1 as published
7// by the Free Software Foundation, with special exception defined in the file
8// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9// distribution for complete text of the license and disclaimer of any warranty.
10//
11// Alternatively, this file may be used under the terms of Open CASCADE
12// commercial license or contractual agreement.
13
14#ifndef _Graphic3d_FrameStatsData_HeaderFile
15#define _Graphic3d_FrameStatsData_HeaderFile
16
17#include <NCollection_Array1.hxx>
18#include <Graphic3d_FrameStatsCounter.hxx>
19#include <Graphic3d_FrameStatsTimer.hxx>
20#include <OSD_Timer.hxx>
21
22#include <vector>
23
24//! Data frame definition.
25class Graphic3d_FrameStatsData
26{
27public:
28 DEFINE_STANDARD_ALLOC
29
30 //! Returns FPS (frames per seconds, elapsed time).
31 //! This number indicates an actual frame rate averaged for several frames within UpdateInterval() duration,
32 //! basing on a real elapsed time between updates.
33 Standard_Real FrameRate() const { return myFps; }
34
35 //! Returns CPU FPS (frames per seconds, CPU time).
36 //! This number indicates a PREDICTED frame rate,
37 //! basing on CPU elapsed time between updates and NOT real elapsed time (which might include periods of CPU inactivity).
38 //! Number is expected to be greater then actual frame rate returned by FrameRate().
39 //! Values significantly greater actual frame rate indicate that rendering is limited by GPU performance (CPU is stalled in-between),
40 //! while values around actual frame rate indicate rendering being limited by CPU performance (GPU is stalled in-between).
41 Standard_Real FrameRateCpu() const { return myFpsCpu; }
42
8f5760bc 43 //! Returns FPS for immediate redraws.
44 Standard_Real ImmediateFrameRate() const { return myFpsImmediate; }
45
46 //! Returns CPU FPS for immediate redraws.
47 Standard_Real ImmediateFrameRateCpu() const { return myFpsCpuImmediate; }
48
5e30547b 49 //! Get counter value.
50 Standard_Size CounterValue (Graphic3d_FrameStatsCounter theIndex) const { return myCounters[theIndex]; }
51
52 //! Get counter value.
53 Standard_Size operator[] (Graphic3d_FrameStatsCounter theIndex) const { return CounterValue (theIndex); }
54
55 //! Get timer value.
56 Standard_Real TimerValue (Graphic3d_FrameStatsTimer theIndex) const { return myTimers[theIndex]; }
57
58 //! Get timer value.
59 Standard_Real operator[] (Graphic3d_FrameStatsTimer theIndex) const { return TimerValue (theIndex); }
60
61 //! Empty constructor.
62 Standard_EXPORT Graphic3d_FrameStatsData();
63
64 //! Assignment operator.
65 Standard_EXPORT Graphic3d_FrameStatsData& operator= (const Graphic3d_FrameStatsData& theOther);
66
67 //! Reset data.
68 Standard_EXPORT void Reset();
69
70 //! Fill with maximum values.
71 Standard_EXPORT void FillMax (const Graphic3d_FrameStatsData& theOther);
72
73protected:
74 std::vector<Standard_Size> myCounters; //!< counters
75 std::vector<Standard_Real> myTimers; //!< timers
76 std::vector<Standard_Real> myTimersMin; //!< minimal values of timers
77 std::vector<Standard_Real> myTimersMax; //!< maximum values of timers
78 Standard_Real myFps; //!< FPS meter (frames per seconds, elapsed time)
79 Standard_Real myFpsCpu; //!< CPU FPS meter (frames per seconds, CPU time)
8f5760bc 80 Standard_Real myFpsImmediate; //!< FPS meter for immediate redraws
81 Standard_Real myFpsCpuImmediate; //!< CPU FPS meter for immediate redraws
5e30547b 82};
83
84//! Temporary data frame definition.
85class Graphic3d_FrameStatsDataTmp : public Graphic3d_FrameStatsData
86{
87public:
88 //! Empty constructor.
89 Standard_EXPORT Graphic3d_FrameStatsDataTmp();
90
91 //! Compute average data considering the amount of rendered frames.
92 Standard_EXPORT void FlushTimers (Standard_Size theNbFrames, bool theIsFinal);
93
94 //! Reset data.
95 Standard_EXPORT void Reset();
96
97 //! Assignment operator (skip copying irrelevant properties).
98 void operator= (const Graphic3d_FrameStatsData& theOther) { Graphic3d_FrameStatsData::operator= (theOther); }
99
100 //! Returns FPS (frames per seconds, elapsed time).
101 Standard_Real& ChangeFrameRate() { return myFps; }
102
103 //! Returns CPU FPS (frames per seconds, CPU time).
104 Standard_Real& ChangeFrameRateCpu() { return myFpsCpu; }
105
8f5760bc 106 //! Returns FPS for immediate redraws.
107 Standard_Real& ChangeImmediateFrameRate() { return myFpsImmediate; }
108
109 //! Returns CPU FPS for immediate redraws.
110 Standard_Real& ChangeImmediateFrameRateCpu() { return myFpsCpuImmediate; }
111
5e30547b 112 //! Return a timer object for time measurements.
113 OSD_Timer& ChangeTimer (Graphic3d_FrameStatsTimer theTimer) { return myOsdTimers[theTimer]; }
114
115 //! Get counter value.
116 Standard_Size& ChangeCounterValue (Graphic3d_FrameStatsCounter theIndex) { return myCounters[theIndex]; }
117
118 //! Modify counter value.
119 Standard_Size& operator[] (Graphic3d_FrameStatsCounter theIndex) { return ChangeCounterValue (theIndex); }
120
121 //! Modify timer value.
122 Standard_Real& ChangeTimerValue (Graphic3d_FrameStatsTimer theIndex) { return myTimers[theIndex]; }
123
124 //! Modify timer value.
125 Standard_Real& operator[] (Graphic3d_FrameStatsTimer theIndex) { return ChangeTimerValue (theIndex); }
126
127protected:
128 std::vector<OSD_Timer> myOsdTimers; //!< precise timers for time measurements
129 std::vector<Standard_Real> myTimersPrev; //!< previous timers values
130};
131
132#endif // _Graphic3d_FrameStatsData_HeaderFile