1 // Copyright (c) 2018 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
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.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #ifndef _Graphic3d_FrameStatsData_HeaderFile
15 #define _Graphic3d_FrameStatsData_HeaderFile
17 #include <NCollection_Array1.hxx>
18 #include <Graphic3d_FrameStatsCounter.hxx>
19 #include <Graphic3d_FrameStatsTimer.hxx>
20 #include <OSD_Timer.hxx>
24 //! Data frame definition.
25 class Graphic3d_FrameStatsData
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; }
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; }
43 //! Get counter value.
44 Standard_Size CounterValue (Graphic3d_FrameStatsCounter theIndex) const { return myCounters[theIndex]; }
46 //! Get counter value.
47 Standard_Size operator[] (Graphic3d_FrameStatsCounter theIndex) const { return CounterValue (theIndex); }
50 Standard_Real TimerValue (Graphic3d_FrameStatsTimer theIndex) const { return myTimers[theIndex]; }
53 Standard_Real operator[] (Graphic3d_FrameStatsTimer theIndex) const { return TimerValue (theIndex); }
55 //! Empty constructor.
56 Standard_EXPORT Graphic3d_FrameStatsData();
58 //! Assignment operator.
59 Standard_EXPORT Graphic3d_FrameStatsData& operator= (const Graphic3d_FrameStatsData& theOther);
62 Standard_EXPORT void Reset();
64 //! Fill with maximum values.
65 Standard_EXPORT void FillMax (const Graphic3d_FrameStatsData& theOther);
68 std::vector<Standard_Size> myCounters; //!< counters
69 std::vector<Standard_Real> myTimers; //!< timers
70 std::vector<Standard_Real> myTimersMin; //!< minimal values of timers
71 std::vector<Standard_Real> myTimersMax; //!< maximum values of timers
72 Standard_Real myFps; //!< FPS meter (frames per seconds, elapsed time)
73 Standard_Real myFpsCpu; //!< CPU FPS meter (frames per seconds, CPU time)
76 //! Temporary data frame definition.
77 class Graphic3d_FrameStatsDataTmp : public Graphic3d_FrameStatsData
80 //! Empty constructor.
81 Standard_EXPORT Graphic3d_FrameStatsDataTmp();
83 //! Compute average data considering the amount of rendered frames.
84 Standard_EXPORT void FlushTimers (Standard_Size theNbFrames, bool theIsFinal);
87 Standard_EXPORT void Reset();
89 //! Assignment operator (skip copying irrelevant properties).
90 void operator= (const Graphic3d_FrameStatsData& theOther) { Graphic3d_FrameStatsData::operator= (theOther); }
92 //! Returns FPS (frames per seconds, elapsed time).
93 Standard_Real& ChangeFrameRate() { return myFps; }
95 //! Returns CPU FPS (frames per seconds, CPU time).
96 Standard_Real& ChangeFrameRateCpu() { return myFpsCpu; }
98 //! Return a timer object for time measurements.
99 OSD_Timer& ChangeTimer (Graphic3d_FrameStatsTimer theTimer) { return myOsdTimers[theTimer]; }
101 //! Get counter value.
102 Standard_Size& ChangeCounterValue (Graphic3d_FrameStatsCounter theIndex) { return myCounters[theIndex]; }
104 //! Modify counter value.
105 Standard_Size& operator[] (Graphic3d_FrameStatsCounter theIndex) { return ChangeCounterValue (theIndex); }
107 //! Modify timer value.
108 Standard_Real& ChangeTimerValue (Graphic3d_FrameStatsTimer theIndex) { return myTimers[theIndex]; }
110 //! Modify timer value.
111 Standard_Real& operator[] (Graphic3d_FrameStatsTimer theIndex) { return ChangeTimerValue (theIndex); }
114 std::vector<OSD_Timer> myOsdTimers; //!< precise timers for time measurements
115 std::vector<Standard_Real> myTimersPrev; //!< previous timers values
118 #endif // _Graphic3d_FrameStatsData_HeaderFile