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;
29
30class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGUserRenderPassManager : public std::enable_shared_from_this<QSSGUserRenderPassManager>
31{
32 enum class Private { Initialize };
33public:
34 // A set of user passes (no duplicates)
35 using UserPassSet = QList<QSSGRenderUserPass *>;
36
37 explicit QSSGUserRenderPassManager(Private);
38 ~QSSGUserRenderPassManager();
39
40 [[nodiscard]] static std::shared_ptr<QSSGUserRenderPassManager> create()
41 {
42 return std::make_shared<QSSGUserRenderPassManager>(Private::Initialize);
43 }
44
45 // Establishes the complete set of scheduled (top-level) passes for the frame
46 // in one operation. Replacing the set wholesale each sync implicitly drops
47 // passes that were removed or that flipped to being a sub-pass.
48 void setScheduledPasses(const UserPassSet &topLevelPasses);
49
50 // On-demand scheduling used by the extension/provider path. A sub-pass is
51 // rejected; a top-level pass is added if not already scheduled. This backs up
52 // setScheduledPasses on the first frame, before the layer render data (and
53 // thus the manager) exists at sync time.
54 void scheduleUserPass(QSSGRenderUserPass *userPasses);
55 void unscheduleUserPass(const QSSGRenderUserPass *userPasses);
56
57 QSSGRhiRenderableTextureV2Ptr getOrCreateRenderableTexture(const QSSGRenderUserPass &userPass);
58 QSSGRhiRenderableTextureV2Ptr getUserPassTexureResult(const QSSGRenderUserPass &userPass) const;
59
60 // Should be called before scheduledUserPasses is called.
61 void updateUserPassOrder(bool forceUpdate = false);
62
63 const UserPassSet &scheduledUserPasses() const { return m_scheduledUserPasses; }
64
65 void releaseAll();
66
67 void unregisterManagedTexture(QSSGManagedRhiTexture *textureWrapper);
68 void registerManagedTexture(QSSGManagedRhiTexture *textureWrapper);
69
70 static constexpr size_t maxUserPassSlots() { return 16; }
71 qsizetype acquireUserPassSlot();
72
73 void resetForFrame();
74
75private:
76 Q_DISABLE_COPY_MOVE(QSSGUserRenderPassManager)
77
78 friend class QSSGBufferManager;
79
80 using TextureWrappers = std::vector<QSSGManagedRhiTexture *>;
81 using DeferredReleaseTextures = QSet<QRhiTexture *>;
82
83 // If return false the texture is not tracked and should be released by caller!!!
84 [[nodiscard]] bool derefTexture(QRhiTexture *texture);
85 void refTexture(QRhiTexture *texture);
86
87 [[nodiscard]] bool derefTexture(const std::unique_ptr<QRhiTexture> &texture);
88 void refTexture(const std::unique_ptr<QRhiTexture> &texture);
89
90 QHash<const QSSGRenderUserPass *, QSSGRhiRenderableTextureV2Ptr> m_renderPassRenderTargets;
91 UserPassSet m_scheduledUserPasses;
92
93 // Sub-passes we have already warned about when a schedule request was
94 // rejected; keeps the per-frame provider path from spamming the warning.
95 QSet<const QSSGRenderUserPass *> m_subPassScheduleWarned;
96
97 QHash<QRhiTexture *, size_t> m_trackedTextures;
98
99 // We keep a list of these so we can notify them that it's
100 // time to release their textures.
101 TextureWrappers m_trackedTextureWrappers;
102
103 DeferredReleaseTextures m_deferredReleaseTextures;
104
105 size_t m_userPassSlotsUsed = 0;
106
107 bool m_passlistDirty = false;
108};
109
110using QSSGUserRenderPassManagerPtr = std::shared_ptr<QSSGUserRenderPassManager>;
111
112QT_END_NAMESPACE
113
114#endif // QSSGUSERRENDERPASSMANAGER_P_H
Combined button and popup list for selecting options.