9#include <QtQuick/QQuickWindow>
11#include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h>
12#include <ssg/qssgrendercontextcore.h>
13#include <QtQuick3DRuntimeRender/private/qssgrendermodel_p.h>
14#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
15#include <QtQuick3DRuntimeRender/private/qssgrenderimage_p.h>
17#include <QtQuick3DUtils/private/qssgassert_p.h>
84 po->spatialNode =
nullptr;
110 for (
auto object : dirtyList) {
112 if (itemPriv->sceneManager ==
nullptr)
129 ret |= updateResources(
it);
147 updateExtensions(
it);
152 const auto updateDirtyResourceNode = [
this](
QQuick3DObject *resource) {
154 po->dirtyAttributes = 0;
156 po->spatialNode = resource->updateSpatialNode(node);
159 return po->sharedResource;
166 ret |= updateDirtyResourceNode(*
it);
179 quint32 dirty = itemPriv->dirtyAttributes;
181 itemPriv->dirtyAttributes = 0;
183 itemPriv->spatialNode = resourceObject->updateSpatialNode(itemPriv->spatialNode);
184 if (itemPriv->spatialNode) {
186 if (itemPriv->spatialNode->type == QSSGRenderGraphObject::Type::ResourceLoader) {
188 }
else if (itemPriv->spatialNode->type == QQuick3DObjectPrivate::Type::Image2D && itemPriv->spatialNode != oldNode) {
202 quint32 dirty = itemPriv->dirtyAttributes;
203 itemPriv->dirtyAttributes = 0;
209 if (itemPriv->spatialNode) {
211 if (itemPriv->type == QQuick3DObjectPrivate::Type::Item2D && itemPriv->spatialNode != oldNode)
218 QQuick3DNode *nodeParent = qobject_cast<QQuick3DNode *>(spatialNode->parentItem());
222 if (parentGraphNode) {
224 parentGraphNode->addChild(*graphNode);
229 if (graphNode && graphNode->parent ==
nullptr) {
230 QQuick3DNode *nodeParent = qobject_cast<QQuick3DNode *>(spatialNode->parentItem());
233 if (!parentGraphNode) {
236 parentNode->spatialNode = nodeParent->updateSpatialNode(parentNode->spatialNode);
237 if (parentNode->spatialNode)
239 parentGraphNode =
static_cast<QSSGRenderNode *
>(parentNode->spatialNode);
242 parentGraphNode->
addChild(*graphNode);
247 if (!sceneRoot->spatialNode)
248 sceneRoot->spatialNode = viewParent->scene()->updateSpatialNode(sceneRoot->spatialNode);
249 if (sceneRoot->spatialNode) {
251 static_cast<QSSGRenderNode *
>(sceneRoot->spatialNode)->addChild(*graphNode);
292 if (node->type == QQuick3DObjectPrivate::Type::Item2D) {
294 }
else if (node->type == QQuick3DObjectPrivate::Type::Image2D) {
296 if (
image &&
image->m_qsgTexture !=
nullptr ) {
308 if (node->hasGraphicsResources()) {
310 if (node->type == QSSGRenderGraphObject::Type::ResourceLoader)
323bool QQuick3DSceneManager::updateResources(
QQuick3DObject **listHead)
341 ret |= po->sharedResource;
342 po->removeFromDirtyList();
370void QQuick3DSceneManager::updateExtensions(
QQuick3DObject **listHead)
374 po->dirtyAttributes = 0;
376 po->spatialNode =
extension->updateSpatialNode(node);
394 updateDirtyExtensionNode(
item);
442 if (
QSSG_GUARD_X(rc,
"QQuickWindow has no QSGRenderContext, this should not happen")) {
459 for (
auto manager: sceneManagerCleanupQueue) {
471 QSSG_CHECK_X(!m_rci || m_rci.use_count() == 1,
"RCI has unexpected reference count!");
476 for (
auto &sceneManager : std::as_const(sceneManagers))
477 sceneManager->preSync();
496 if (resourceCleanupQueue.
size() != 0)
497 m_rci->renderer()->cleanupResources(resourceCleanupQueue);
501void QQuick3DWindowAttachment::onReleaseCachedResources()
504 m_rci->releaseCachedResources();
508void QQuick3DWindowAttachment::onInvalidated()
515 for (
auto &sceneManager :
std::as_const(sceneManagers)) {
516 const auto objects = sceneManager->m_nodeMap.keys();
518 if (
obj->hasGraphicsResources())
519 sceneManager->cleanup(
obj);
524 for (
auto &sceneManager :
std::as_const(sceneManagers))
525 sceneManager->cleanupNodes();
527 for (
const auto &pr :
std::as_const(pendingResourceCleanupQueue))
528 resourceCleanupQueue.
insert(pr);
529 pendingResourceCleanupQueue.
clear();
535 onReleaseCachedResources();
543 if (m_rci.use_count() == 1) {
552 for (
auto manager: sceneManagerCleanupQueue) {
557 sceneManagerCleanupQueue = {};
559 bool sharedUpdateNeeded =
false;
562 for (
auto &sceneManager : std::as_const(sceneManagers))
563 sharedUpdateNeeded |= sceneManager->cleanupNodes();
566 for (
auto &sceneManager : std::as_const(sceneManagers))
567 sharedUpdateNeeded |= sceneManager->updateDirtyResourceNodes();
569 for (
auto &sceneManager : std::as_const(sceneManagers))
570 sceneManager->updateDirtySpatialNodes();
571 for (
auto &sceneManager : std::as_const(sceneManagers))
572 sceneManager->updateDiryExtensions();
573 for (
auto &sceneManager : std::as_const(sceneManagers))
574 sharedUpdateNeeded |= sceneManager->updateDirtyResourceSecondPass();
576 for (
auto &sceneManager : std::as_const(sceneManagers))
577 sceneManager->updateBoundingBoxes(*m_rci->bufferManager());
579 for (
auto &sceneManager : std::as_const(sceneManagers))
580 resourceLoaders.unite(sceneManager->resourceLoaders);
582 if (sharedUpdateNeeded) {
585 for (
auto &sceneManager : std::as_const(sceneManagers))
586 sceneManager->requestUpdate();
590 for (
const auto &pr : std::as_const(pendingResourceCleanupQueue))
591 resourceCleanupQueue.
insert(pr);
592 pendingResourceCleanupQueue.
clear();
594 return sharedUpdateNeeded;
599 for (
const auto &sm : std::as_const(sceneManagers))
618 QSSG_CHECK_X(m_rci ==
nullptr || m_rci.use_count() == 1,
"Old render context was not released!");
bool remove(const Key &key)
Removes the item that has the key from the hash.
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
bool isEmpty() const noexcept
bool removeOne(const AT &t)
void push_back(parameter_type t)
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
QVariant property(const char *name) const
Returns the value of the object's name property.
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object's name property to value.
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
void deleteLater()
\threadsafe
QSSGRenderGraphObject * updateSpatialNode(QSSGRenderGraphObject *node) override
static QQuick3DObjectPrivate * get(QQuick3DObject *item)
\qmltype Object3D \inqmlmodule QtQuick3D \instantiates QQuick3DObject \inherits QtObject
QQuick3DObject * parent
\qmlproperty Object3D QtQuick3D::Object3D::parent This property holds the parent of the Object3D in a...
void setWindow(QQuickWindow *window)
void updateDirtyResource(QQuick3DObject *resourceObject)
bool sharedResourceRemoved
QHash< QSSGRenderGraphObject *, QQuick3DObject * > m_nodeMap
QSet< QSSGRenderGraphObject * > resourceLoaders
QQuick3DSceneManager(QObject *parent=nullptr)
QPointer< QQuick3DWindowAttachment > wattached
QSet< QSSGRenderGraphObject * > cleanupNodeList
QList< QQuick3DObject * > dirtyBoundingBoxList
QQuick3DObject * dirtyNodes[size_t(NodePriority::Count)]
bool updateDirtyResourceNodes()
static QQuick3DWindowAttachment * getOrSetWindowAttachment(QQuickWindow &window)
QQuick3DObject * lookUpNode(const QSSGRenderGraphObject *node) const
void updateDiryExtensions()
QQuick3DObject * dirtyExtensions[size_t(ExtensionPriority::Count)]
void dirtyItem(QQuick3DObject *item)
QQuick3DObject * dirtyResources[size_t(ResourcePriority::Count)]
void updateDirtySpatialNodes()
QSet< QQuick3DObject * > dirtySecondPassResources
~QQuick3DSceneManager() override
void updateBoundingBoxes(QSSGBufferManager &mgr)
bool updateDirtyResourceSecondPass()
void updateDirtySpatialNode(QQuick3DNode *spatialNode)
void cleanup(QSSGRenderGraphObject *item)
Q_INVOKABLE void requestUpdate()
void releaseCachedResources()
Q_INVOKABLE void cleanupResources()
void unregisterSceneManager(QQuick3DSceneManager &manager)
Q_INVOKABLE bool synchronize(QSet< QSSGRenderGraphObject * > &resourceLoaders)
Q_INVOKABLE void evaluateEol()
void renderContextInterfaceChanged()
void registerSceneManager(QQuick3DSceneManager &manager)
~QQuick3DWindowAttachment() override
QQuickWindow * window() const
void queueForCleanup(QSSGRenderGraphObject *obj)
QQuick3DWindowAttachment(QQuickWindow *window)
QQuick3DWindowAttachment.
void setRci(const std::shared_ptr< QSSGRenderContextInterface > &rciptr)
Q_INVOKABLE void preSync()
static QQuickWindowPrivate * get(QQuickWindow *c)
QSGRenderContext * context
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
void releaseCachedResourcesRequested()
Class representing 3D range or axis aligned bounding box.
static constexpr bool isNodeType(Type type) noexcept
static constexpr bool isExtension(Type type) noexcept
static constexpr bool isTexture(Type type) noexcept
bool remove(const T &value)
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
qDeleteAll(list.begin(), list.end())
cache insert(employee->id(), employee)
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static QT_BEGIN_NAMESPACE constexpr char qtQQ3DWAPropName[]
#define QSSG_DEBUG_COND(cond)
#define QSSG_GUARD_X(cond, msg)
#define QSSG_CHECK_X(cond, msg)
QSqlQueryModel * model
[16]
QNetworkAccessManager manager
bool contains(const AT &t) const noexcept
void addChild(QSSGRenderNode &inChild)
void removeChild(QSSGRenderNode &inChild)