Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:03:48

0001 // Copyright (c) 2018 OPEN CASCADE SAS
0002 //
0003 // This file is part of Open CASCADE Technology software library.
0004 //
0005 // This library is free software; you can redistribute it and/or modify it under
0006 // the terms of the GNU Lesser General Public License version 2.1 as published
0007 // by the Free Software Foundation, with special exception defined in the file
0008 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0009 // distribution for complete text of the license and disclaimer of any warranty.
0010 //
0011 // Alternatively, this file may be used under the terms of Open CASCADE
0012 // commercial license or contractual agreement.
0013 
0014 #ifndef _Graphic3d_FrameStatsData_HeaderFile
0015 #define _Graphic3d_FrameStatsData_HeaderFile
0016 
0017 #include <NCollection_Array1.hxx>
0018 #include <Graphic3d_FrameStatsCounter.hxx>
0019 #include <Graphic3d_FrameStatsTimer.hxx>
0020 #include <OSD_Timer.hxx>
0021 
0022 #include <vector>
0023 
0024 //! Data frame definition.
0025 class Graphic3d_FrameStatsData
0026 {
0027 public:
0028   DEFINE_STANDARD_ALLOC
0029 
0030   //! Returns FPS (frames per seconds, elapsed time).
0031   //! This number indicates an actual frame rate averaged for several frames within UpdateInterval() duration,
0032   //! basing on a real elapsed time between updates.
0033   Standard_Real FrameRate() const { return myFps; }
0034 
0035   //! Returns CPU FPS (frames per seconds, CPU time).
0036   //! This number indicates a PREDICTED frame rate,
0037   //! basing on CPU elapsed time between updates and NOT real elapsed time (which might include periods of CPU inactivity).
0038   //! Number is expected to be greater then actual frame rate returned by FrameRate().
0039   //! Values significantly greater actual frame rate indicate that rendering is limited by GPU performance (CPU is stalled in-between),
0040   //! while values around actual frame rate indicate rendering being limited by CPU performance (GPU is stalled in-between).
0041   Standard_Real FrameRateCpu() const { return myFpsCpu; }
0042 
0043   //! Returns FPS for immediate redraws.
0044   Standard_Real ImmediateFrameRate() const { return myFpsImmediate; }
0045 
0046   //! Returns CPU FPS for immediate redraws.
0047   Standard_Real ImmediateFrameRateCpu() const { return myFpsCpuImmediate; }
0048 
0049   //! Get counter value.
0050   Standard_Size CounterValue (Graphic3d_FrameStatsCounter theIndex) const { return myCounters[theIndex]; }
0051 
0052   //! Get counter value.
0053   Standard_Size operator[] (Graphic3d_FrameStatsCounter theIndex) const { return CounterValue (theIndex); }
0054 
0055   //! Get timer value.
0056   Standard_Real TimerValue (Graphic3d_FrameStatsTimer theIndex) const { return myTimers[theIndex]; }
0057 
0058   //! Get timer value.
0059   Standard_Real operator[] (Graphic3d_FrameStatsTimer theIndex) const { return TimerValue (theIndex); }
0060 
0061   //! Empty constructor.
0062   Standard_EXPORT Graphic3d_FrameStatsData();
0063 
0064   //! Copy constructor.
0065   Standard_EXPORT Graphic3d_FrameStatsData(const Graphic3d_FrameStatsData& theOther);
0066 
0067   //! Move constructor.
0068   Standard_EXPORT Graphic3d_FrameStatsData(Graphic3d_FrameStatsData&& theOther) noexcept;
0069 
0070   //! Assignment operator.
0071   Standard_EXPORT Graphic3d_FrameStatsData& operator= (const Graphic3d_FrameStatsData& theOther);
0072 
0073   //! Assignment with move operator.
0074   Standard_EXPORT Graphic3d_FrameStatsData& operator= (Graphic3d_FrameStatsData&& theOther) noexcept;
0075 
0076   //! Reset data.
0077   Standard_EXPORT void Reset();
0078 
0079   //! Fill with maximum values.
0080   Standard_EXPORT void FillMax (const Graphic3d_FrameStatsData& theOther);
0081 
0082 protected:
0083   std::vector<Standard_Size> myCounters;  //!< counters
0084   std::vector<Standard_Real> myTimers;    //!< timers
0085   std::vector<Standard_Real> myTimersMin; //!< minimal values of timers
0086   std::vector<Standard_Real> myTimersMax; //!< maximum values of timers
0087   Standard_Real              myFps;       //!< FPS     meter (frames per seconds, elapsed time)
0088   Standard_Real              myFpsCpu;    //!< CPU FPS meter (frames per seconds, CPU time)
0089   Standard_Real              myFpsImmediate;    //!< FPS     meter for immediate redraws
0090   Standard_Real              myFpsCpuImmediate; //!< CPU FPS meter for immediate redraws
0091 };
0092 
0093 //! Temporary data frame definition.
0094 class Graphic3d_FrameStatsDataTmp : public Graphic3d_FrameStatsData
0095 {
0096 public:
0097   //! Empty constructor.
0098   Standard_EXPORT Graphic3d_FrameStatsDataTmp();
0099 
0100   //! Compute average data considering the amount of rendered frames.
0101   Standard_EXPORT void FlushTimers (Standard_Size theNbFrames, bool theIsFinal);
0102 
0103   //! Reset data.
0104   Standard_EXPORT void Reset();
0105 
0106   //! Assignment operator (skip copying irrelevant properties).
0107   void operator= (const Graphic3d_FrameStatsData& theOther) { Graphic3d_FrameStatsData::operator= (theOther); }
0108 
0109   //! Returns FPS (frames per seconds, elapsed time).
0110   Standard_Real& ChangeFrameRate() { return myFps; }
0111 
0112   //! Returns CPU FPS (frames per seconds, CPU time).
0113   Standard_Real& ChangeFrameRateCpu() { return myFpsCpu; }
0114 
0115   //! Returns FPS for immediate redraws.
0116   Standard_Real& ChangeImmediateFrameRate() { return myFpsImmediate; }
0117 
0118   //! Returns CPU FPS for immediate redraws.
0119   Standard_Real& ChangeImmediateFrameRateCpu() { return myFpsCpuImmediate; }
0120 
0121   //! Return a timer object for time measurements.
0122   OSD_Timer& ChangeTimer (Graphic3d_FrameStatsTimer theTimer) { return myOsdTimers[theTimer]; }
0123 
0124   //! Get counter value.
0125   Standard_Size& ChangeCounterValue (Graphic3d_FrameStatsCounter theIndex) { return myCounters[theIndex]; }
0126 
0127   //! Modify counter value.
0128   Standard_Size& operator[] (Graphic3d_FrameStatsCounter theIndex) { return ChangeCounterValue (theIndex); }
0129 
0130   //! Modify timer value.
0131   Standard_Real& ChangeTimerValue (Graphic3d_FrameStatsTimer theIndex) { return myTimers[theIndex]; }
0132 
0133   //! Modify timer value.
0134   Standard_Real& operator[] (Graphic3d_FrameStatsTimer theIndex) { return ChangeTimerValue (theIndex); }
0135 
0136 protected:
0137   std::vector<OSD_Timer>     myOsdTimers;  //!< precise timers for time measurements
0138   std::vector<Standard_Real> myTimersPrev; //!< previous timers values
0139 };
0140 
0141 #endif // _Graphic3d_FrameStatsData_HeaderFile