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 void scheduleUserPass(QSSGRenderUserPass *userPasses);
46 void unscheduleUserPass(const QSSGRenderUserPass *userPasses);
47
48 QSSGRhiRenderableTextureV2Ptr getOrCreateRenderableTexture(const QSSGRenderUserPass &userPass);
49 QSSGRhiRenderableTextureV2Ptr getUserPassTexureResult(const QSSGRenderUserPass &userPass) const;
50
51 // Should be called before scheduledUserPasses is called.
52 void updateUserPassOrder(bool forceUpdate = false);
53
54 const UserPassSet &scheduledUserPasses() const { return m_scheduledUserPasses; }
55
56 void releaseAll();
57
58 void unregisterManagedTexture(QSSGManagedRhiTexture *textureWrapper);
59 void registerManagedTexture(QSSGManagedRhiTexture *textureWrapper);
60
61 static constexpr size_t maxUserPassSlots() { return 16; }
62 qsizetype acquireUserPassSlot();
63
64 void resetForFrame();
65
66private:
67 Q_DISABLE_COPY_MOVE(QSSGUserRenderPassManager)
68
69 friend class QSSGBufferManager;
70
71 using TextureWrappers = std::vector<QSSGManagedRhiTexture *>;
72 using DeferredReleaseTextures = QSet<QRhiTexture *>;
73
74 // If return false the texture is not tracked and should be released by caller!!!
75 [[nodiscard]] bool derefTexture(QRhiTexture *texture);
76 void refTexture(QRhiTexture *texture);
77
78 [[nodiscard]] bool derefTexture(const std::unique_ptr<QRhiTexture> &texture);
79 void refTexture(const std::unique_ptr<QRhiTexture> &texture);
80
81 QHash<const QSSGRenderUserPass *, QSSGRhiRenderableTextureV2Ptr> m_renderPassRenderTargets;
82 UserPassSet m_scheduledUserPasses;
83
84 QHash<QRhiTexture *, size_t> m_trackedTextures;
85
86 // We keep a list of these so we can notify them that it's
87 // time to release their textures.
88 TextureWrappers m_trackedTextureWrappers;
89
90 DeferredReleaseTextures m_deferredReleaseTextures;
91
92 size_t m_userPassSlotsUsed = 0;
93
94 bool m_passlistDirty = false;
95};
96
97using QSSGUserRenderPassManagerPtr = std::shared_ptr<QSSGUserRenderPassManager>;
98
99QT_END_NAMESPACE
100
101#endif // QSSGUSERRENDERPASSMANAGER_P_H
Combined button and popup list for selecting options.