Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquick3dscenemanager_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 QSSGSCENEMANAGER_P_H
5#define QSSGSCENEMANAGER_P_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 <QtCore/QObject>
19#include <QtCore/QSet>
20
21#include <QtQuick3D/private/qtquick3dglobal_p.h>
22
23#include <QtQuick3DRuntimeRender/private/qssgrendergraphobject_p.h>
24
25#include "qquick3dnode_p.h"
26
27#include <QtCore/qpointer.h>
28
30
32class QQuickWindow;
35
36class Q_QUICK3D_EXPORT QQuick3DWindowAttachment : public QObject
37{
39public:
42
43 Q_INVOKABLE void preSync();
44 Q_INVOKABLE void cleanupResources();
45 Q_INVOKABLE bool synchronize(QSet<QSSGRenderGraphObject *> &resourceLoaders);
46 Q_INVOKABLE void requestUpdate();
47 Q_INVOKABLE void evaluateEol();
48
49 QQuickWindow *window() const;
50
51 const std::shared_ptr<QSSGRenderContextInterface> &rci() const { return m_rci; }
52 void setRci(const std::shared_ptr<QSSGRenderContextInterface> &rciptr);
53
54 void registerSceneManager(QQuick3DSceneManager &manager);
55 void unregisterSceneManager(QQuick3DSceneManager &manager);
56
57 void queueForCleanup(QSSGRenderGraphObject *obj);
58 void queueForCleanup(QQuick3DSceneManager *manager);
59
63
64private:
65 Q_INVOKABLE void onReleaseCachedResources();
66 Q_INVOKABLE void onInvalidated();
67
68 QPointer<QQuickWindow> m_window;
69 std::shared_ptr<QSSGRenderContextInterface> m_rci;
70 QList<QQuick3DSceneManager *> sceneManagers;
71 QList<QQuick3DSceneManager *> sceneManagerCleanupQueue;
72 QList<QSSGRenderGraphObject *> pendingResourceCleanupQueue;
73 QSet<QSSGRenderGraphObject *> resourceCleanupQueue;
74};
75
76class Q_QUICK3D_EXPORT QQuick3DSceneManager : public QObject
77{
79public:
80 explicit QQuick3DSceneManager(QObject *parent = nullptr);
81 ~QQuick3DSceneManager() override;
82
83 void setWindow(QQuickWindow *window);
85
86 void dirtyItem(QQuick3DObject *item);
87 void requestUpdate();
88 void cleanup(QSSGRenderGraphObject *item);
89
90 void polishItems();
91 void forcePolish();
92 void sync();
93 void preSync();
94
95 bool cleanupNodes();
96 bool updateDirtyResourceNodes();
97 void updateDirtySpatialNodes();
98 void updateDiryExtensions();
99 bool updateDirtyResourceSecondPass();
100
101 void updateDirtyResource(QQuick3DObject *resourceObject);
102 void updateDirtySpatialNode(QQuick3DNode *spatialNode);
103 void updateBoundingBoxes(QSSGBufferManager &mgr);
104
105 QQuick3DObject *lookUpNode(const QSSGRenderGraphObject *node) const;
106
107 // Where the enumerator is placed will decide the priority it gets.
108 // NOTE: Place new list types before 'Count'.
109 // NOTE: InstanceNodes are nodes that have an instance root set, we'll process these
110 // after the other nodes but before light nodes; this implies that lights are not good candidates
111 // for being instance roots...
112 enum class NodePriority { Skeleton, Other, ModelWithInstanceRoot, Lights, Count };
113 enum class ResourcePriority { TextureData, Texture, Other, Count };
114 enum class ExtensionPriority { RenderExtension, Count };
115
117 {
119
121 return size_t(ResourcePriority::Texture);
122
123 if (type == QSSGRenderGraphObject::Type::TextureData)
124 return size_t(ResourcePriority::TextureData);
125
126 return size_t(ResourcePriority::Other);
127 }
128
130 {
132
134 return size_t(NodePriority::Lights);
135
136 if (type == QSSGRenderGraphObject::Type::Skeleton)
137 return size_t(NodePriority::Skeleton);
138
139 return size_t(NodePriority::Other);
140 }
141
143 {
145
146 return size_t(ExtensionPriority::RenderExtension);
147 }
148
149 static QQuick3DWindowAttachment *getOrSetWindowAttachment(QQuickWindow &window);
150
151 QQuick3DObject *dirtyResources[size_t(ResourcePriority::Count)] {};
152 QQuick3DObject *dirtyNodes[size_t(NodePriority::Count)] {};
153 QQuick3DObject *dirtyExtensions[size_t(ExtensionPriority::Count)] {};
154 // For exceptions to the norm we create a list of resources that
155 // we get a second update.
156 // In the case of the render extensions the resources are update first and for the
157 // first time the extensions have not been run and therefore have no backend node, which
158 // we'll need to use connect the render result from the extension with the texture.
159 QSet<QQuick3DObject *> dirtySecondPassResources;
160
161 QList<QQuick3DObject *> dirtyBoundingBoxList;
162 QSet<QSSGRenderGraphObject *> cleanupNodeList;
163 QList<QSSGRenderGraphObject *> resourceCleanupQueue;
164
165 QSet<QQuick3DObject *> parentlessItems;
166 QVector<QSGDynamicTexture *> qsgDynamicTextures;
167 QHash<QSSGRenderGraphObject *, QQuick3DObject *> m_nodeMap;
168 QSet<QSSGRenderGraphObject *> resourceLoaders;
169 QQuickWindow *m_window = nullptr;
170 QPointer<QQuick3DWindowAttachment> wattached;
171 int inputHandlingEnabled = 0; // Holds the count of active item2Ds, input disabled if zero.
172 bool sharedResourceRemoved = false;
174
178
179private Q_SLOTS:
180 bool updateResources(QQuick3DObject **listHead);
181 void updateNodes(QQuick3DObject **listHead);
182 void updateExtensions(QQuick3DObject **listHead);
183};
184
186
188
189#endif // QSSGSCENEMANAGER_P_H
\inmodule QtCore
Definition qobject.h:103
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
static size_t nodeListIndex(QSSGRenderGraphObject::Type type)
QHash< QSSGRenderGraphObject *, QQuick3DObject * > m_nodeMap
QSet< QSSGRenderGraphObject * > resourceLoaders
QVector< QSGDynamicTexture * > qsgDynamicTextures
QPointer< QQuick3DWindowAttachment > wattached
QList< QSSGRenderGraphObject * > resourceCleanupQueue
QSet< QSSGRenderGraphObject * > cleanupNodeList
QList< QQuick3DObject * > dirtyBoundingBoxList
QSet< QQuick3DObject * > parentlessItems
QSet< QQuick3DObject * > dirtySecondPassResources
static size_t resourceListIndex(QSSGRenderGraphObject::Type type)
static constexpr size_t extensionListIndex(QSSGRenderGraphObject::Type type)
const std::shared_ptr< QSSGRenderContextInterface > & rci() const
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
The QSGDynamicTexture class serves as a baseclass for dynamically changing textures,...
Definition qsgtexture.h:100
static constexpr bool isNodeType(Type type) noexcept
static constexpr bool isExtension(Type type) noexcept
static constexpr bool isTexture(Type type) noexcept
static constexpr bool isLight(Type type) noexcept
Combined button and popup list for selecting options.
GLenum type
GLhandleARB obj
[2]
#define QML_DECLARE_TYPE(TYPE)
Definition qqml.h:19
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_OBJECT
#define Q_INVOKABLE
#define Q_SLOTS
#define Q_SIGNALS
QGraphicsItem * item
aWidget window() -> setWindowTitle("New Window Title")
[2]
QNetworkAccessManager manager