VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtImGuiLoaderStatsData.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2026 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <vlutil/vlPerformanceStats.h>
15 
16 #include <vrvUtil/signalslib.h>
17 #include <map>
18 #include <string>
19 #include <deque>
20 #include <unordered_map>
21 #include <mutex>
22 
23 namespace osg
24 {
25  class RenderInfo;
26  class Camera;
27  class FrameStamp;
28  class Object;
29 }
30 
31 namespace osgDB
32 {
33  class DatabasePager;
34 }
35 
36 class DtDynamicLibrary;
37 
38 namespace makVrv
39 {
40  class DtOsgStatsHandler;
41  class DtProfileNode;
42 
46  {
47  public:
48 
50  {
51  ProfilerOverlayStates_OFF = 0,
52  ProfilerOverlayStates_FPS = 1,
53  ProfilerOverlayStates_FULL = 2
54  };
55 
56  const int NUM_PAGING_ENTRIES = 4;
57 
58  struct GPUData
59  {
61  : temp(0)
62  , shutdownTemp(0)
63  , slowdownTemp(0)
64  , maxTemp(0)
65  , clocksThrottleReasons(0)
66  , dllAvailable(-1)
67  , pState(0)
68  {
69  ;
70  }
71  unsigned int temp;
72  unsigned int shutdownTemp;
73  unsigned int slowdownTemp;
74  unsigned int maxTemp;
75  unsigned long long clocksThrottleReasons;
76  int pState;
78  };
79 
81  {
82  OsgObjectData(osg::Object* object);
83 
84  osg::Object* myObject;
85  std::string myClassName;
86  std::string myName;
88 
89  };
90 
93  {
100 
101  // osgEarth job arenas
106  };
107 
110  {
131  };
132 
135  {
136  // Group 1: Process info (from mi_process_info)
137  float myRssCurrentMb = 0.0f;
138  float myRssPeakMb = 0.0f;
139  float myCommitCurrentMb = 0.0f;
140  float myCommitPeakMb = 0.0f;
141  float myPageFaultsPerSec = 0.0f;
142 
143  // Group 2: Allocator health (from mi_stats_get)
144  // In mimalloc v3, stats.committed covers only the small/medium slab arenas.
145  // Huge allocations (> MI_LARGE_OBJ_SIZE_MAX, ~64KB) go directly to the OS
146  // and are tracked separately in malloc_huge -- NOT in committed.
147  // Therefore any committed-based ratio is invalid when huge allocs dominate.
148  // Instead expose the raw allocation paths directly.
149  float myNormalPeakMb = 0.0f; // peak committed slab bytes (stats.committed.peak)
150  float myHugeLiveMb = 0.0f; // huge direct-OS live bytes
151  float myTotalLiveMb = 0.0f; // combined; use this for leak detection
152  float mySlabCommittedMb = 0.0f; // committed slab arena memory (excludes huge)
153  float myHugePeakMb = 0.0f;
154  long long myHugeTotalCount = 0LL;
155  };
156 
159  {
160  float myPeakUploadMB = 0.0f;
161  double myPeakHoldTime = 0.0;
162  double myLastTime = 0.0;
163 
164  // seconds to hold peak
165  double myPeakHoldDuration = 2.0;
166 
167  // falloff rate
168  double myFadeSpeed = 0.9f;
169 
170  float myCurrentUploadMB = 0.0f;
171  float myMaxMB = 1.0f;
172  float myBarSizeX = 100.0f;
173  float myBarSizeY = 24.0f;
174 
175  };
176 
177  static const int GRAPH_ENTRIES = 180;
178  static const int GPU_UPLOADED_MEMORY_HISTORY_SIZE = 120;
179  static const float theOneMbBytes;
180 
181  public:
184 
186  virtual ~DtImGuiLoaderStatsData();
187 
189  DtImGuiLoaderStatsData(const DtImGuiLoaderStatsData& rhs) = delete;
190 
192  DtImGuiLoaderStatsData& operator=(const DtImGuiLoaderStatsData& rhs) = delete;
193 
194  public:
195 
197  virtual void updateStats(DtDe& de, osg::Camera* camera, osg::FrameStamp* frameStamp, osgDB::DatabasePager* databasePager, int mipthreads);
198 
200  virtual void createUI(osg::RenderInfo& renderInfo, DtDe& de, unsigned int state);
201 
203  virtual int getNumberOf60HtzFrames();
204 
206  virtual float getGoodFrameDuration();
207 
209  virtual int getNumberOfBlownFrames();
210 
212  virtual float getBlownFrameDuration();
213 
215  virtual int getNumberOfVeryBlownFrames();
216 
218  virtual float getVeryBlownFrameDuration();
219 
221  virtual void reset();
222 
224  virtual void setStatsHandler(DtOsgStatsHandler* stats) { myStats = stats; }
225 
227  virtual void updateGpuStats(DtDe& de);
228 
231  virtual void addIntStat(const std::string& name, int value);
232 
235  virtual void addFloatStat(const std::string& name, float value);
236 
239  virtual void addIntStat(const std::string& subsystem, const std::string& name, int value);
240 
243  virtual void addFloatStat(const std::string& subsystem, const std::string& name, float value);
244 
246  float getLastCullTime();
247 
249  float getLastUpdateTime();
250 
252  float getLastDrawTime();
253 
255  float getLastGpuTime();
256 
257  protected:
258  virtual void updateMimallocStats();
259 
261  virtual void updateMimallocStatsFast();
262 
264  virtual void createMimallocStatsUI();
265 
268  virtual void updateOsgCameraStats(osg::Camera* camera, osg::FrameStamp* frameStamp);
269 
270  // adds child nodes to tree
271  virtual int treeTraverse(DtProfileNode* node, int depth);
272 
274  virtual void printOsgTextures(void);
275 
277  void printOsgEarthGLMemory(void);
278 
280  virtual void printVrvTextures(void);
281 
283  virtual void printVrvBuffers(void);
284 
286  virtual void printTextureBreaksup(const std::unordered_map<unsigned int, int>& textures);
287 
289  virtual void updateVrvGpuArenaStats(DtDe& de);
290 
292  virtual void createVrvGpuArenaStats();
293 
295  virtual void drawPeakBar(PeakBarState& state, float nonClippedPercent);
296 
298  virtual void drawGpuArenaMultiLinePlot(int budgetMB, float nonClippedPercent);
299 
300  protected:
301  DtTimedSection myTimedSection;
303  struct PagingTime
304  {
305  PagingTime() : myPagingTime(0.0f), myPagingFrameCount(0) { ; }
306  PagingTime(float pagingTime, int count) : myPagingTime(pagingTime), myPagingFrameCount(count) { ; }
309  };
310  std::deque<PagingTime> myPagingTimeArray;
311 
318  float myMaxYAxis;
322  float myHistogramData[25];
323  float myBlownHistogramData[5];
325  float myPhase;
326  float myFrameTimeArray[GRAPH_ENTRIES];
327  float myCullTimeArray[GRAPH_ENTRIES];
328  float myUpdateTimeArray[GRAPH_ENTRIES];
329  float myDrawTimeArray[GRAPH_ENTRIES];
330  float myGpuTimeArray[GRAPH_ENTRIES];
331  float my8ms[GRAPH_ENTRIES];
332  float my16ms[GRAPH_ENTRIES];
333  float my33ms[GRAPH_ENTRIES];
336 
337 
339  std::map<std::string, std::vector<OsgObjectData> > myObjectInfo;
340  std::map<std::string, std::vector<OsgObjectData> > myObjectInfoPrevious;
341  std::map<std::string, std::vector<OsgObjectData> > myObjectsInBoth;
343 
345 
346  typedef std::map<std::string, int> intStats;
347  typedef std::map<std::string, float> floatStats;
348  std::map<std::string, intStats> myIntStats;
349  std::map<std::string, floatStats> myFloatStats;
350 
352  std::map<std::string, std::string> myNvidiaSmiLog;
353  DtDynamicLibrary* myGpuPlugin;
354  typedef void(*addProc)(makVrv::DtImGuiLoaderStatsData::GPUData* gpu);
356 
358 
364 
365  float myIndirectUploadedMemoryTotalHistory[GPU_UPLOADED_MEMORY_HISTORY_SIZE] = { 0 };
366  float myIndirectUploadedBufferMemoryHistory[GPU_UPLOADED_MEMORY_HISTORY_SIZE] = { 0 };
367  float myIndirectUploadedTextureMemoryHistory[GPU_UPLOADED_MEMORY_HISTORY_SIZE] = { 0 };
372 
373  // Mimalloc stats (Groups 1-4)
374  static const int MIMALLOC_ERROR_LOG_SIZE = 10;
376  float myMimallocRssHistory[GRAPH_ENTRIES];
377  float myMimallocFragHistory[GRAPH_ENTRIES];
378  float myMimallocSlabHistory[GRAPH_ENTRIES]; // 60 Hz slab committed, captures transient spikes
379  float myMimallocCommitHistory[GRAPH_ENTRIES]; // 60 Hz process committed (for growth-rate diagnosis)
382  float myMimallocCollectBeforeMb; // committed before last mi_collect(true) call
383  float myMimallocCollectAfterMb; // committed after last mi_collect(true) call
384  double myMimallocCollectResultTime; // ImGui::GetTime() when last collect result was recorded
385  bool myMimallocCollectRequested; // set by UI button; serviced on next updateMimallocStats() tick
386 
387  // Error log for Group 4 (written from mimalloc error callback, potentially any thread)
388  static void onMimallocError(int err, void* arg);
389  static std::mutex theMimallocErrorMutex;
390  static std::deque<std::string> theMimallocErrorLog;
392  };
393 }
Profile node class stores timing data for a profiled section.
Definition: DtProfileNode.h:22
int myStateGraphCount
Definition: DtImGuiLoaderStatsData.h:114
int myCurrentIndex
Definition: DtImGuiLoaderStatsData.h:324
DtDynamicLibrary * myGpuPlugin
Definition: DtImGuiLoaderStatsData.h:353
int myRequestCount
Definition: DtImGuiLoaderStatsData.h:99
float myMimallocCollectBeforeMb
Definition: DtImGuiLoaderStatsData.h:382
std::map< std::string, float > floatStats
Definition: DtImGuiLoaderStatsData.h:347
int myLineCount
Definition: DtImGuiLoaderStatsData.h:122
static int theMimallocErrorCount
Definition: DtImGuiLoaderStatsData.h:391
Definition: DtImGuiLoaderStatsData.h:58
bool myEnableOsgCameraStats
Definition: DtImGuiLoaderStatsData.h:314
bool myIndirectShowBufferHistory
Definition: DtImGuiLoaderStatsData.h:370
Structure for holding the stats from the osg camera rendering stats.
Definition: DtImGuiLoaderStatsData.h:109
GPUData myGpuState
Definition: DtImGuiLoaderStatsData.h:351
float myPagingTime
Definition: DtImGuiLoaderStatsData.h:307
#define DT_DLL_VRVOSG
Definition: vrvOsg.h:23
float myFrameRunningAverage
Definition: DtImGuiLoaderStatsData.h:320
float myTimeSpentUnresponsive
Definition: DtImGuiLoaderStatsData.h:302
std::map< std::string, std::string > myNvidiaSmiLog
Definition: DtImGuiLoaderStatsData.h:352
double myMimallocCollectResultTime
Definition: DtImGuiLoaderStatsData.h:384
unsigned int slowdownTemp
Definition: DtImGuiLoaderStatsData.h:73
std::map< std::string, std::vector< OsgObjectData > > myObjectInfoPrevious
Definition: DtImGuiLoaderStatsData.h:340
DatabasePagerData myLastDatabasePagerData
Definition: DtImGuiLoaderStatsData.h:312
std::map< std::string, int > intStats
Definition: DtImGuiLoaderStatsData.h:346
OsgSceneGraphCameraStats myLastOsgCameraStats
Definition: DtImGuiLoaderStatsData.h:313
DtTimedSection myTimedSection
Definition: DtImGuiLoaderStatsData.h:301
std::map< std::string, std::vector< OsgObjectData > > myObjectInfo
Definition: DtImGuiLoaderStatsData.h:339
int myIndirectUploadedBufferMemory
Definition: DtImGuiLoaderStatsData.h:361
unsigned int shutdownTemp
Definition: DtImGuiLoaderStatsData.h:72
int myLightCount
Definition: DtImGuiLoaderStatsData.h:111
unsigned long long clocksThrottleReasons
Definition: DtImGuiLoaderStatsData.h:75
std::map< std::string, std::vector< OsgObjectData > > myObjectsInBoth
Definition: DtImGuiLoaderStatsData.h:341
unsigned int maxTemp
Definition: DtImGuiLoaderStatsData.h:74
int myQuadStripCount
Definition: DtImGuiLoaderStatsData.h:129
int myTriangleCount
Definition: DtImGuiLoaderStatsData.h:125
int myPolygonCount
Definition: DtImGuiLoaderStatsData.h:130
int myMaxPagedLods
Definition: DtImGuiLoaderStatsData.h:95
osg::Object * myObject
Definition: DtImGuiLoaderStatsData.h:84
int myVertexCount
Definition: DtImGuiLoaderStatsData.h:119
DtOsgStatsHandler * myStats
Definition: DtImGuiLoaderStatsData.h:335
static std::mutex theMimallocErrorMutex
Definition: DtImGuiLoaderStatsData.h:389
bool myIndirectShowTextureHistory
Definition: DtImGuiLoaderStatsData.h:371
float myMimallocCollectAfterMb
Definition: DtImGuiLoaderStatsData.h:383
class that gathers per frame stats and puts up UI
Definition: DtImGuiLoaderStatsData.h:45
int mySamples
Definition: DtImGuiLoaderStatsData.h:315
int myLineStripCount
Definition: DtImGuiLoaderStatsData.h:123
int myOsgEarthPendingJobs
Definition: DtImGuiLoaderStatsData.h:102
int myQuadCount
Definition: DtImGuiLoaderStatsData.h:128
int myTriFanCount
Definition: DtImGuiLoaderStatsData.h:127
float myMaxFrameTime
Definition: DtImGuiLoaderStatsData.h:319
int myDDSThreads
Definition: DtImGuiLoaderStatsData.h:334
DtDe & myDe
Definition: DtImGuiLoaderStatsData.h:357
float myMaxYAxis
Definition: DtImGuiLoaderStatsData.h:318
size_t myMimallocLastPageFaults
Definition: DtImGuiLoaderStatsData.h:381
int myDepthCount
Definition: DtImGuiLoaderStatsData.h:113
MimallocData myMimallocData
Definition: DtImGuiLoaderStatsData.h:375
static const float theOneMbBytes
Definition: DtImGuiLoaderStatsData.h:179
int dllAvailable
Definition: DtImGuiLoaderStatsData.h:77
float myPhase
Definition: DtImGuiLoaderStatsData.h:325
int myPrimitiveSetCount
Definition: DtImGuiLoaderStatsData.h:120
int myIndirectGpuUploadMemoryBudget
Definition: DtImGuiLoaderStatsData.h:360
int myOsgEarthRunningJobs
Definition: DtImGuiLoaderStatsData.h:103
bool myOnlyShowDifferentCounts
Definition: DtImGuiLoaderStatsData.h:342
PeakBarState myGpuUploadedMemoryPeakBarState
Definition: DtImGuiLoaderStatsData.h:369
int myBinCount
Definition: DtImGuiLoaderStatsData.h:112
double myMimallocLastUpdateTime
Definition: DtImGuiLoaderStatsData.h:380
bool myEnableObjectProfiling
Definition: DtImGuiLoaderStatsData.h:338
static std::deque< std::string > theMimallocErrorLog
Definition: DtImGuiLoaderStatsData.h:390
unsigned int temp
Definition: DtImGuiLoaderStatsData.h:71
int myTriStripCount
Definition: DtImGuiLoaderStatsData.h:126
int myActivePagedLods
Definition: DtImGuiLoaderStatsData.h:96
float myFrameDuration
Definition: DtImGuiLoaderStatsData.h:317
bool myAutoResetEnabled
Definition: DtImGuiLoaderStatsData.h:344
int myIndirectGpuOneTimeOpsRemaining
Definition: DtImGuiLoaderStatsData.h:359
float myFrameRunningAverageMax
Definition: DtImGuiLoaderStatsData.h:321
int myToMergeCount
Definition: DtImGuiLoaderStatsData.h:97
GPUData()
Definition: DtImGuiLoaderStatsData.h:60
std::map< std::string, intStats > myIntStats
Definition: DtImGuiLoaderStatsData.h:348
PPP: 10/2021:
Definition: DtOsgStatsHandler.h:51
int myFastDrawableCount
Definition: DtImGuiLoaderStatsData.h:118
Snapshot of mimalloc process-level and allocator health statistics.
Definition: DtImGuiLoaderStatsData.h:134
int myToCompileCount
Definition: DtImGuiLoaderStatsData.h:98
float myRefreshTime
Definition: DtImGuiLoaderStatsData.h:316
int myIndirectUploadedTextureMemory
Definition: DtImGuiLoaderStatsData.h:362
int myRefCount
Definition: DtImGuiLoaderStatsData.h:87
Definition: DtImGuiLoaderStatsData.h:303
Contains DLL export macros.
std::deque< PagingTime > myPagingTimeArray
Definition: DtImGuiLoaderStatsData.h:310
Structure for holding the stats from the osg database pager.
Definition: DtImGuiLoaderStatsData.h:92
Definition: DtImGuiLoaderStatsData.h:80
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:76
PagingTime(float pagingTime, int count)
Definition: DtImGuiLoaderStatsData.h:306
PagingTime()
Definition: DtImGuiLoaderStatsData.h:305
int myDrawableCount
Definition: DtImGuiLoaderStatsData.h:116
int myIndirectUploadedMemoryHistoryIndex
Definition: DtImGuiLoaderStatsData.h:368
int myPointCount
Definition: DtImGuiLoaderStatsData.h:121
bool myMimallocCollectRequested
Definition: DtImGuiLoaderStatsData.h:385
std::string myClassName
Definition: DtImGuiLoaderStatsData.h:85
int mySensorizedObjectsPending
Definition: DtImGuiLoaderStatsData.h:105
int myImposterCount
Definition: DtImGuiLoaderStatsData.h:115
int myPagingFrameCount
Definition: DtImGuiLoaderStatsData.h:308
virtual void setStatsHandler(DtOsgStatsHandler *stats)
gui handler
Definition: DtImGuiLoaderStatsData.h:224
int myOsgEarthICOJobs
Definition: DtImGuiLoaderStatsData.h:104
int pState
Definition: DtImGuiLoaderStatsData.h:76
ProfilerOverlayStates
Definition: DtImGuiLoaderStatsData.h:49
int myLineLoopCount
Definition: DtImGuiLoaderStatsData.h:124
std::map< std::string, floatStats > myFloatStats
Definition: DtImGuiLoaderStatsData.h:349
int mySortedDrawableCount
Definition: DtImGuiLoaderStatsData.h:117
int myIndirectGpuBufferUpdatesRemaining
Definition: DtImGuiLoaderStatsData.h:363
std::string myName
Definition: DtImGuiLoaderStatsData.h:86
int myPagingThreads
Definition: DtImGuiLoaderStatsData.h:94
Structure for holding peak upload bar state.
Definition: DtImGuiLoaderStatsData.h:158
addProc myAddGpuImguiUI
Definition: DtImGuiLoaderStatsData.h:355

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)