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
qssguserrenderpassmanager_p.h
Go to the documentation of this file.
1// Copyright (C) 2025 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 QSSGUSERRENDERPASSMANAGER_P_H
7#define QSSGUSERRENDERPASSMANAGER_P_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 <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
21
22#include <QtCore/qlist.h>
23
24#include <memory>
25
26QT_BEGIN_NAMESPACE
27
28class QSSGRenderUserPass;
29class QSSGRenderUserPassBase;
30class QSSGRenderComputePass;
31class QSSGBufferManager;
32
33class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGUserRenderPassManager
34{
35 enum class Private { Initialize };
36public:
37 // A set of user passes (no duplicates)
38 using UserPassSet = QList<QSSGRenderUserPassBase *>;
39
40 explicit QSSGUserRenderPassManager(Private);
41 ~QSSGUserRenderPassManager();
42
43 [[nodiscard]] static std::shared_ptr<QSSGUserRenderPassManager> create()
44 {
45 return std::make_shared<QSSGUserRenderPassManager>(Private::Initialize);
46 }
47
48 // Establishes the complete set of scheduled (top-level) passes for the frame
49 // in one operation. Replacing the set wholesale each sync implicitly drops
50 // passes that were removed or that flipped to being a sub-pass.
51 void setScheduledPasses(const UserPassSet &topLevelPasses);
52
53 // On-demand scheduling used by the extension/provider path. A sub-pass is
54 // rejected; a top-level pass is added if not already scheduled. This backs up
55 // setScheduledPasses on the first frame, before the layer render data (and
56 // thus the manager) exists at sync time.
57 void scheduleUserPass(QSSGRenderUserPassBase *userPasses);
58 void unscheduleUserPass(const QSSGRenderUserPassBase *userPasses);
59
60 QSSGRhiRenderableTextureV2Ptr getOrCreateRenderableTexture(const QSSGRenderUserPass &userPass);
61 QSSGRhiRenderableTextureV2Ptr getUserPassTexureResult(const QSSGRenderUserPass &userPass) const;
62
63 // Should be called before scheduledUserPasses is called.
64 void updateUserPassOrder(bool forceUpdate = false);
65
66 const UserPassSet &scheduledUserPasses() const { return m_scheduledUserPasses; }
67
68 void selectPassesForFrame(QSSGBufferManager &bufferManager, bool willRender,
69 UserPassSet &startOfFramePasses, UserPassSet &preColorPasses);
70 void deferExecution(QSSGBufferManager &bufferManager, const QSSGRenderComputePass &pass);
71
72 void releaseAll(QSSGRhiResourceRegistry *registry);
73
74 static constexpr size_t maxUserPassSlots() { return 16; }
75 qsizetype acquireUserPassSlot();
76
77 void resetForFrame();
78 // Releases what the manager holds for a pass that is going away.
79 void releaseUserPass(const QSSGRenderUserPassBase *pass, QSSGRhiResourceRegistry *registry);
80
81private:
82 Q_DISABLE_COPY_MOVE(QSSGUserRenderPassManager)
83
84 friend class QSSGBufferManager;
85
86 bool hasPendingExecution(const QSSGBufferManager &bufferManager, const QSSGRenderComputePass &pass) const;
87 void markExecuted(QSSGBufferManager &bufferManager, const QSSGRenderComputePass &pass);
88
89 // The render targets of the passes rendered by this layer. The QRhiTextures
90 // backing them are owned by the QSSGRhiContext, see QSSGManagedRhiTexture.
91 QHash<const QSSGRenderUserPass *, QSSGRhiRenderableTextureV2Ptr> m_renderPassRenderTargets;
92 UserPassSet m_scheduledUserPasses;
93
94 // Sub-passes we have already warned about when a schedule request was
95 // rejected; keeps the per-frame provider path from spamming the warning.
96 QSet<const QSSGRenderUserPassBase *> m_subPassScheduleWarned;
97
98 size_t m_userPassSlotsUsed = 0;
99
100 bool m_passlistDirty = false;
101 bool m_hasComputePasses = false;
102};
103
104using QSSGUserRenderPassManagerPtr = std::shared_ptr<QSSGUserRenderPassManager>;
105
106QT_END_NAMESPACE
107
108#endif // QSSGUSERRENDERPASSMANAGER_P_H
static void warnIfStartOfFramePassUsesSceneTextures(QSSGRenderComputePass &pass)