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