Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquick3drenderstats_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4#ifndef QQUICK3DRENDERSTATS_H
5#define QQUICK3DRENDERSTATS_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuick3D/qtquick3dglobal.h>
19#include <QtCore/qobject.h>
20#include <QtCore/qelapsedtimer.h>
21#include <ssg/qssgrendercontextcore.h>
22#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
23
24#include <QtQml/qqmlregistration.h>
25
27
28struct QSSGRenderLayer;
29class QQuickItem;
30
31class Q_QUICK3D_EXPORT QQuick3DRenderStats : public QObject
32{
33 Q_OBJECT
34 Q_PROPERTY(int fps READ fps NOTIFY fpsChanged)
35 Q_PROPERTY(float frameTime READ frameTime NOTIFY frameTimeChanged)
36 Q_PROPERTY(float renderTime READ renderTime NOTIFY renderTimeChanged)
37 Q_PROPERTY(float renderPrepareTime READ renderPrepareTime NOTIFY renderTimeChanged)
38 Q_PROPERTY(float syncTime READ syncTime NOTIFY syncTimeChanged)
39 Q_PROPERTY(float maxFrameTime READ maxFrameTime NOTIFY maxFrameTimeChanged)
40
41 Q_PROPERTY(bool extendedDataCollectionEnabled READ extendedDataCollectionEnabled WRITE setExtendedDataCollectionEnabled NOTIFY extendedDataCollectionEnabledChanged)
42 Q_PROPERTY(quint64 drawCallCount READ drawCallCount NOTIFY drawCallCountChanged)
43 Q_PROPERTY(quint64 drawVertexCount READ drawVertexCount NOTIFY drawVertexCountChanged)
44 Q_PROPERTY(quint64 imageDataSize READ imageDataSize NOTIFY imageDataSizeChanged)
45 Q_PROPERTY(quint64 meshDataSize READ meshDataSize NOTIFY meshDataSizeChanged)
46 Q_PROPERTY(int renderPassCount READ renderPassCount NOTIFY renderPassCountChanged)
47 Q_PROPERTY(QString renderPassDetails READ renderPassDetails NOTIFY renderPassDetailsChanged)
48 Q_PROPERTY(QString textureDetails READ textureDetails NOTIFY textureDetailsChanged)
49 Q_PROPERTY(QString meshDetails READ meshDetails NOTIFY meshDetailsChanged)
50 Q_PROPERTY(int pipelineCount READ pipelineCount NOTIFY pipelineCountChanged)
51 Q_PROPERTY(qint64 materialGenerationTime READ materialGenerationTime NOTIFY materialGenerationTimeChanged)
52 Q_PROPERTY(qint64 effectGenerationTime READ effectGenerationTime NOTIFY effectGenerationTimeChanged)
53 Q_PROPERTY(qint64 pipelineCreationTime READ pipelineCreationTime NOTIFY pipelineCreationTimeChanged)
54 Q_PROPERTY(quint32 vmemAllocCount READ vmemAllocCount NOTIFY vmemAllocCountChanged)
55 Q_PROPERTY(quint64 vmemUsedBytes READ vmemUsedBytes NOTIFY vmemUsedBytesChanged)
56 Q_PROPERTY(QString graphicsApiName READ graphicsApiName NOTIFY graphicsApiNameChanged)
57 Q_PROPERTY(float lastCompletedGpuTime READ lastCompletedGpuTime NOTIFY lastCompletedGpuTimeChanged)
58
59 QML_NAMED_ELEMENT(RenderStats)
60 QML_UNCREATABLE("The type is internal and only intended to be accessed by user through a View3D.")
61 QML_ADDED_IN_VERSION(6, 10)
62
63public:
64 QQuick3DRenderStats(QObject *parent = nullptr);
65
66 int fps() const;
67 float frameTime() const;
68 float renderTime() const;
69 float renderPrepareTime() const;
70 float syncTime() const;
71 float maxFrameTime() const;
72
73 void startSync();
74 void endSync(bool dump = false);
75
76 void startRender();
77 void startRenderPrepare();
78 void endRenderPrepare();
79 void endRender(bool dump = false);
80
81 void setRhiContext(QSSGRhiContext *ctx, QSSGRenderLayer *layer);
82
83 bool extendedDataCollectionEnabled() const;
84 void setExtendedDataCollectionEnabled(bool enable);
85
86 quint64 drawCallCount() const;
87 quint64 drawVertexCount() const;
88 quint64 imageDataSize() const;
89 quint64 meshDataSize() const;
90 int renderPassCount() const;
91 QString renderPassDetails() const;
92 QString textureDetails() const;
93 QString meshDetails() const;
94 int pipelineCount() const;
95 qint64 materialGenerationTime() const;
96 qint64 effectGenerationTime() const;
97 qint64 pipelineCreationTime() const;
98 quint32 vmemAllocCount() const;
99 quint64 vmemUsedBytes() const;
100 QString graphicsApiName() const;
101 float lastCompletedGpuTime() const;
102
103 Q_INVOKABLE void releaseCachedResources();
104
105 void setWindow(QQuickWindow *window);
106
107Q_SIGNALS:
108 void fpsChanged();
109 void frameTimeChanged();
110 void renderTimeChanged();
111 void syncTimeChanged();
112 void maxFrameTimeChanged();
113 void extendedDataCollectionEnabledChanged();
114 void drawCallCountChanged();
115 void drawVertexCountChanged();
116 void imageDataSizeChanged();
117 void meshDataSizeChanged();
118 void renderPassCountChanged();
119 void renderPassDetailsChanged();
120 void textureDetailsChanged();
121 void meshDetailsChanged();
122 void pipelineCountChanged();
123 void materialGenerationTimeChanged();
124 void effectGenerationTimeChanged();
125 void pipelineCreationTimeChanged();
126 void vmemAllocCountChanged();
127 void vmemUsedBytesChanged();
128 void graphicsApiNameChanged();
129 void lastCompletedGpuTimeChanged();
130
131private Q_SLOTS:
132 void onFrameSwapped();
133
134private:
135 float timestamp() const;
136 void processRhiContextStats();
137 void notifyRhiContextStats();
138
139 QElapsedTimer m_frameTimer;
140 int m_frameCount = 0;
141 float m_secTimer = 0;
142 float m_notifyTimer = 0;
143 float m_renderStartTime = 0;
144 float m_renderPrepareStartTime = 0;
145 float m_syncStartTime = 0;
146
147 float m_internalMaxFrameTime = 0;
148 float m_maxFrameTime = 0;
149
150 int m_fps = 0;
151
152 struct Results {
153 float frameTime = 0;
154 float renderTime = 0;
155 float renderPrepareTime = 0;
156 float syncTime = 0;
157 float lastCompletedGpuTime = 0;
158 quint64 drawCallCount = 0;
159 quint64 drawVertexCount = 0;
160 quint64 imageDataSize = 0;
161 quint64 meshDataSize = 0;
162 int renderPassCount = 0;
163 QString renderPassDetails;
164 QString textureDetails;
165 QString meshDetails;
166 QSet<QRhiTexture *> activeTextures;
167 QSet<QSSGRenderMesh *> activeMeshes;
168 int pipelineCount = 0;
169 qint64 materialGenerationTime = 0;
170 qint64 effectGenerationTime = 0;
171 QRhiStats rhiStats;
172 };
173
174 Results m_results;
175 Results m_notifiedResults;
176 QSSGRhiContextStats *m_contextStats = nullptr;
177 bool m_extendedDataCollectionEnabled = false;
178 QSSGRenderLayer *m_layer = nullptr;
179 QMetaObject::Connection m_frameSwappedConnection;
180 QQuickWindow *m_window = nullptr;
181 bool m_renderingThisFrame = false;
182 QString m_graphicsApiName;
183};
184
185QT_END_NAMESPACE
186
187Q_DECLARE_METATYPE(QQuick3DRenderStats *)
188
189#endif // QQUICK3DRENDERSTATS_H
static QByteArray prepareCustomShader(QSSGRenderCustomMaterial *customMaterial, const QSSGShaderCustomMaterialAdapter::StringPairList &uniforms, const QByteArray &snippet, QSSGShaderCache::ShaderType shaderType, QSSGCustomShaderMetaData &meta, bool multiViewCompatible)
static QT_BEGIN_NAMESPACE QRhiGraphicsPipeline::BlendFactor toRhiBlendFactor(QQuick3DCustomMaterial::BlendMode mode)
\qmlproperty url CustomMaterial::vertexShader
static void setCustomMaterialFlagsFromShader(QSSGRenderCustomMaterial *material, const QSSGCustomShaderMetaData &meta)