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
qssgrenderextensions.h
Go to the documentation of this file.
1// Copyright (C) 2023 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 QSSGRENDEREXTENSIIONS_H
7#define QSSGRENDEREXTENSIIONS_H
8
9//
10// W A R N I N G
11// -------------
12//
13// This file is part of the QtQuick3D API, with limited compatibility guarantees.
14// Usage of this API may make your code source and binary incompatible with
15// future versions of Qt.
16//
17
18#include <QtQuick3DRuntimeRender/qtquick3druntimerenderexports.h>
19#include <ssg/qssgrenderbasetypes.h>
20#include <ssg/qssgrendergraphobject.h>
21#include <ssg/qssgrhicontext.h>
22#include <QtCore/qobject.h>
23#include <QtCore/qcompare.h>
24#include <QtCore/qshareddata.h>
25
26QT_BEGIN_NAMESPACE
27
28class QSSGRenderContextInterface;
30class QRhiTexture;
31class QRhiRenderBuffer;
32class QRhiBuffer;
33class QSSGRhiResourceHandlePrivate;
34QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QSSGRhiResourceHandlePrivate, Q_QUICK3DRUNTIMERENDER_EXPORT)
35
36class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRhiResourceHandle
37{
38public:
39 QSSGRhiResourceHandle() noexcept;
40 ~QSSGRhiResourceHandle();
41 QSSGRhiResourceHandle(const QSSGRhiResourceHandle &other) noexcept;
42 QSSGRhiResourceHandle &operator=(const QSSGRhiResourceHandle &other) noexcept;
43 QSSGRhiResourceHandle(QSSGRhiResourceHandle &&other) noexcept = default;
44 QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QSSGRhiResourceHandle)
45 void swap(QSSGRhiResourceHandle &other) noexcept { d.swap(other.d); }
46
47 [[nodiscard]] bool isValid() const noexcept;
48 [[nodiscard]] QRhiTexture *texture() const noexcept;
49 [[nodiscard]] QRhiBuffer *buffer() const noexcept;
50 [[nodiscard]] QRhiRenderBuffer *renderBuffer() const noexcept;
51 [[nodiscard]] quint64 globalResourceId() const noexcept;
52
53private:
54 friend bool comparesEqual(const QSSGRhiResourceHandle &lhs, const QSSGRhiResourceHandle &rhs) noexcept
55 {
56 return lhs.d == rhs.d;
57 }
58 Q_DECLARE_EQUALITY_COMPARABLE(QSSGRhiResourceHandle)
59
60 friend class QSSGRhiResourceHandlePrivate;
61 explicit QSSGRhiResourceHandle(QSSGRhiResourceHandlePrivate *dd) noexcept;
62
63 QExplicitlySharedDataPointer<QSSGRhiResourceHandlePrivate> d;
64};
65
67
68class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGFrameData
69{
70public:
71 enum class RenderResult : quint32
72 {
73 AoTexture,
74 DepthTexture,
75 ScreenTexture,
76 NormalTexture,
77 MotionVectorTexture,
78 };
79 Q_DECLARE_FLAGS(RenderResults, RenderResult)
80
81 enum class AttachmentSelector : quint32
82 {
83 Attachment0 = 0,
84 Attachment1 = 1,
85 Attachment2 = 2,
86 Attachment3 = 3,
87 DepthAttachment = 0x8000,
88 };
89
90#if QT_DEPRECATED_SINCE(6, 13)
91 QT_WARNING_PUSH
92 QT_WARNING_DISABLE_DEPRECATED
93 struct QT_DEPRECATED_VERSION_X_6_13("Use getRhiResource() instead") Result
94 {
95 QRhiTexture *texture = nullptr;
96 QRhiRenderBuffer *buffer = nullptr;
97 };
98 QT_WARNING_POP
99#endif
100
101 using TypeMask = QSSGRenderGraphObject::TypeT;
102 static constexpr TypeMask NodeMask = QSSGRenderGraphObject::BaseType::Node;
103
104 void scheduleRenderResults(RenderResults results) const;
105
106#if QT_DEPRECATED_SINCE(6, 13)
107 QT_WARNING_PUSH
108 QT_WARNING_DISABLE_DEPRECATED
109 QT_DEPRECATED_VERSION_X_6_13("Use getRhiResource() instead")
110 Result getRenderResult(RenderResult id) const;
111 QT_DEPRECATED_VERSION_X_6_13("Use getRhiResource() instead")
112 Result getRenderResult(QSSGResourceId userPassId, AttachmentSelector attachment) const;
113 QT_WARNING_POP
114#endif
115 [[nodiscard]] QSSGRhiResourceHandle getRhiResource(QSSGResourceId resourceId) const;
116 [[nodiscard]] QSSGRhiResourceHandle getRhiResource(RenderResult id) const;
117 [[nodiscard]] QSSGRhiResourceHandle getRhiResource(QSSGResourceId userPassId, AttachmentSelector attachment) const;
118
119 qsizetype getAttachmentCount(QSSGResourceId userPassId) const;
120
121 [[nodiscard]] QSSGRhiGraphicsPipelineState getPipelineState() const;
122
123 [[nodiscard]] QSSGCameraId activeCamera() const;
124
125 [[nodiscard]] QSSGRenderContextInterface *contextInterface() const;
126
127 [[nodiscard]] QSSGNodeIdList getLayerNodes(quint32 layerMask, TypeMask typeMask = NodeMask) const;
128 [[nodiscard]] QSSGNodeIdList getLayerNodes(QSSGCameraId cameraId, TypeMask typeMask = NodeMask) const;
129
130private:
131 friend class QSSGLayerRenderData;
132 friend class QSSGRenderOutputProviderExtension;
133
134 void clear();
135
136 [[nodiscard]] QSSGLayerRenderData *getCurrent() const;
137
138 void scheduleRenderResults(QSSGResourceId userPassId) const;
139
140 QSSGFrameData() = default;
141 explicit QSSGFrameData(QSSGRenderContextInterface *ctx);
142 QSSGRenderContextInterface *m_ctx = nullptr;
143};
144
145class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderExtension : public QSSGRenderGraphObject
146{
147public:
148 enum class RenderMode
149 {
150 Standalone,
151 Main
152 };
153
154 enum class RenderStage
155 {
156 PreColor,
157 PostColor
158 };
159
160 QSSGRenderExtension();
161 virtual ~QSSGRenderExtension();
162
163 virtual bool prepareData(QSSGFrameData &data) = 0;
164 virtual void prepareRender(QSSGFrameData &data) = 0;
165 virtual void render(QSSGFrameData &data) = 0;
166
167 virtual void resetForFrame() = 0;
168
169 virtual RenderMode mode() const = 0;
170 virtual RenderStage stage() const = 0;
171
172protected:
173 QSSGRenderExtension(Type inType, FlagT inFlags);
174};
175
176class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGRenderTextureProviderExtension : public QSSGRenderExtension
177{
178public:
179 QSSGRenderTextureProviderExtension();
180 ~QSSGRenderTextureProviderExtension() override;
181
182 RenderMode mode() const final;
183 RenderStage stage() const final;
184};
185
186QT_END_NAMESPACE
187
188#endif // QSSGRENDEREXTENSIIONS_H
\inmodule QtQuick3D
\inmodule QtQuick3D
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
static QSSGRhiResourceRegistry & resourceRegistry(const QSSGRenderContextInterface &ctx)
static bool isRenderResultRequired(const QSSGLayerRenderPreparationResultFlags &flags, QSSGFrameData::RenderResult id)
static QSSGRhiRenderableTextureV2Ptr userPassRenderTarget(const QSSGRenderContextInterface &ctx, QSSGResourceId userPassId)