Overte C++ Documentation
EngineStats.h
1 //
2 // EngineStats.h
3 // render/src/render
4 //
5 // Created by Sam Gateau on 3/27/16.
6 // Copyright 2016 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_render_EngineStats_h
13 #define hifi_render_EngineStats_h
14 
15 #include <gpu/Context.h>
16 
17 #include <QElapsedTimer>
18 
19 #include "Engine.h"
20 
21 namespace render {
22 
23  // A simple job collecting global stats on the Engine / Scene / GPU
24  class EngineStatsConfig : public Job::Config{
25  Q_OBJECT
26 
27  Q_PROPERTY(quint32 bufferCPUCount MEMBER bufferCPUCount NOTIFY newStats)
28  Q_PROPERTY(quint32 bufferGPUCount MEMBER bufferGPUCount NOTIFY newStats)
29  Q_PROPERTY(qint64 bufferCPUMemSize MEMBER bufferCPUMemSize NOTIFY newStats)
30  Q_PROPERTY(qint64 bufferGPUMemSize MEMBER bufferGPUMemSize NOTIFY newStats)
31 
32  Q_PROPERTY(quint32 textureCPUCount MEMBER textureCPUCount NOTIFY newStats)
33  Q_PROPERTY(quint32 textureGPUCount MEMBER textureGPUCount NOTIFY newStats)
34  Q_PROPERTY(quint32 textureResidentGPUCount MEMBER textureResidentGPUCount NOTIFY newStats)
35  Q_PROPERTY(quint32 textureFramebufferGPUCount MEMBER textureFramebufferGPUCount NOTIFY newStats)
36  Q_PROPERTY(quint32 textureResourceGPUCount MEMBER textureResourceGPUCount NOTIFY newStats)
37  Q_PROPERTY(quint32 textureExternalGPUCount MEMBER textureExternalGPUCount NOTIFY newStats)
38 
39  Q_PROPERTY(qint64 textureCPUMemSize MEMBER textureCPUMemSize NOTIFY newStats)
40  Q_PROPERTY(qint64 textureGPUMemSize MEMBER textureGPUMemSize NOTIFY newStats)
41  Q_PROPERTY(qint64 textureResidentGPUMemSize MEMBER textureResidentGPUMemSize NOTIFY newStats)
42  Q_PROPERTY(qint64 textureFramebufferGPUMemSize MEMBER textureFramebufferGPUMemSize NOTIFY newStats)
43  Q_PROPERTY(qint64 textureResourceGPUMemSize MEMBER textureResourceGPUMemSize NOTIFY newStats)
44  Q_PROPERTY(qint64 textureExternalGPUMemSize MEMBER textureExternalGPUMemSize NOTIFY newStats)
45 
46  Q_PROPERTY(quint32 texturePendingGPUTransferCount MEMBER texturePendingGPUTransferCount NOTIFY newStats)
47  Q_PROPERTY(qint64 texturePendingGPUTransferSize MEMBER texturePendingGPUTransferSize NOTIFY newStats)
48  Q_PROPERTY(qint64 textureResourcePopulatedGPUMemSize MEMBER textureResourcePopulatedGPUMemSize NOTIFY newStats)
49 
50  Q_PROPERTY(quint32 frameAPIDrawcallCount MEMBER frameAPIDrawcallCount NOTIFY newStats)
51  Q_PROPERTY(quint32 frameDrawcallCount MEMBER frameDrawcallCount NOTIFY newStats)
52  Q_PROPERTY(quint32 frameDrawcallRate MEMBER frameDrawcallRate NOTIFY newStats)
53 
54  Q_PROPERTY(quint32 frameTriangleCount MEMBER frameTriangleCount NOTIFY newStats)
55  Q_PROPERTY(quint32 frameTriangleRate MEMBER frameTriangleRate NOTIFY newStats)
56 
57  Q_PROPERTY(quint32 frameTextureCount MEMBER frameTextureCount NOTIFY newStats)
58  Q_PROPERTY(quint32 frameTextureRate MEMBER frameTextureRate NOTIFY newStats)
59  Q_PROPERTY(quint64 frameTextureMemoryUsage MEMBER frameTextureMemoryUsage NOTIFY newStats)
60 
61  Q_PROPERTY(quint32 frameSetPipelineCount MEMBER frameSetPipelineCount NOTIFY newStats)
62  Q_PROPERTY(quint32 frameSetInputFormatCount MEMBER frameSetInputFormatCount NOTIFY newStats)
63 
64 
65  public:
66  EngineStatsConfig() : Job::Config(true) {}
67 
68  quint32 bufferCPUCount{ 0 };
69  quint32 bufferGPUCount{ 0 };
70  qint64 bufferCPUMemSize { 0 };
71  qint64 bufferGPUMemSize { 0 };
72 
73  quint32 textureCPUCount{ 0 };
74  quint32 textureGPUCount { 0 };
75  quint32 textureResidentGPUCount { 0 };
76  quint32 textureFramebufferGPUCount { 0 };
77  quint32 textureResourceGPUCount { 0 };
78  quint32 textureExternalGPUCount { 0 };
79  quint32 texturePendingGPUTransferCount { 0 };
80 
81  qint64 textureCPUMemSize { 0 };
82  qint64 textureGPUMemSize { 0 };
83  qint64 textureResidentGPUMemSize { 0 };
84  qint64 textureFramebufferGPUMemSize { 0 };
85  qint64 textureResourceGPUMemSize { 0 };
86  qint64 textureExternalGPUMemSize { 0 };
87  qint64 texturePendingGPUTransferSize { 0 };
88  qint64 textureResourcePopulatedGPUMemSize { 0 };
89 
90  quint32 frameAPIDrawcallCount{ 0 };
91  quint32 frameDrawcallCount{ 0 };
92  quint32 frameDrawcallRate{ 0 };
93 
94  quint32 frameTriangleCount{ 0 };
95  quint32 frameTriangleRate{ 0 };
96 
97  quint32 frameTextureCount{ 0 };
98  quint32 frameTextureRate{ 0 };
99  quint64 frameTextureMemoryUsage{ 0 };
100 
101  quint32 frameSetPipelineCount{ 0 };
102 
103  quint32 frameSetInputFormatCount{ 0 };
104  };
105 
106  class EngineStats {
107  gpu::ContextStats _gpuStats;
108  QElapsedTimer _frameTimer;
109  public:
110  using Config = EngineStatsConfig;
111  using JobModel = Job::Model<EngineStats, Config>;
112 
113  EngineStats() { _frameTimer.start(); }
114 
115  void configure(const Config& configuration) {}
116  void run(const RenderContextPointer& renderContext);
117  };
118 }
119 
120 #endif