1 | // Copyright (C) 2022 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QSSGRENDERPASS_H |
5 | #define QSSGRENDERPASS_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtCore/qglobal.h> |
19 | |
20 | #include <QtQuick3DUtils/private/qtquick3dutilsglobal_p.h> |
21 | #include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h> |
22 | #include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h> |
23 | #include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h> |
24 | |
25 | QT_BEGIN_NAMESPACE |
26 | |
27 | class QSSGRenderer; |
28 | class QSSGRenderShadowMap; |
29 | class QSSGRenderReflectionMap; |
30 | class QSSGLayerRenderData; |
31 | struct QSSGRenderCamera; |
32 | struct QSSGRenderItem2D; |
33 | |
34 | class QSSGRenderPass |
35 | { |
36 | public: |
37 | enum class Type |
38 | { |
39 | Standalone, |
40 | Main, |
41 | Extension |
42 | }; |
43 | // Input: |
44 | |
45 | virtual void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) = 0; |
46 | virtual void renderPass(QSSGRenderer &renderer) = 0; |
47 | virtual Type passType() const = 0; |
48 | virtual void release() = 0; |
49 | |
50 | // Output: |
51 | |
52 | // Flags: Debug markers(?) |
53 | |
54 | // Dependency |
55 | }; |
56 | |
57 | class ShadowMapPass : public QSSGRenderPass |
58 | { |
59 | public: |
60 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
61 | void renderPass(QSSGRenderer &renderer) final; |
62 | Type passType() const final { return Type::Standalone; } |
63 | void release() final; |
64 | |
65 | std::shared_ptr<QSSGRenderShadowMap> shadowMapManager; |
66 | QSSGRenderableObjectList shadowPassObjects; |
67 | QSSGShaderLightList globalLights; |
68 | QSSGRenderCamera *camera = nullptr; |
69 | QSSGRhiGraphicsPipelineState ps; |
70 | QSSGBoxPoints castingObjectsBox; |
71 | QSSGBoxPoints receivingObjectsBox; |
72 | bool enabled = false; |
73 | }; |
74 | |
75 | class ReflectionMapPass : public QSSGRenderPass |
76 | { |
77 | public: |
78 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
79 | void renderPass(QSSGRenderer &renderer) final; |
80 | Type passType() const final { return Type::Standalone; } |
81 | void release() final; |
82 | |
83 | std::shared_ptr<QSSGRenderReflectionMap> reflectionMapManager; |
84 | QList<QSSGRenderReflectionProbe *> reflectionProbes; |
85 | QSSGRenderableObjectList reflectionPassObjects; |
86 | QSSGRhiGraphicsPipelineState ps; |
87 | }; |
88 | |
89 | class ZPrePassPass : public QSSGRenderPass |
90 | { |
91 | public: |
92 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
93 | void renderPass(QSSGRenderer &renderer) final; |
94 | Type passType() const final { return Type::Main; } |
95 | void release() final; |
96 | |
97 | QSSGRenderableObjectList renderedDepthWriteObjects; |
98 | QSSGRenderableObjectList renderedOpaqueDepthPrepassObjects; |
99 | QSSGRhiGraphicsPipelineState ps; |
100 | bool active = false; |
101 | }; |
102 | |
103 | class SSAOMapPass : public QSSGRenderPass |
104 | { |
105 | public: |
106 | struct AmbientOcclusion |
107 | { |
108 | float aoStrength = 0.0f; |
109 | float aoDistance = 5.0f; |
110 | float aoSoftness = 50.0f; |
111 | float aoBias = 0.0f; |
112 | qint32 aoSamplerate = 2; |
113 | bool aoDither = false; |
114 | } ambientOcclusion; |
115 | |
116 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
117 | void renderPass(QSSGRenderer &renderer) final; |
118 | Type passType() const final { return Type::Standalone; } |
119 | void release() final; |
120 | |
121 | const QSSGRhiRenderableTexture *rhiDepthTexture = nullptr; |
122 | const QSSGRenderCamera *camera = nullptr; |
123 | AmbientOcclusion ao; |
124 | QSSGRhiGraphicsPipelineState ps; |
125 | QSSGRhiRenderableTexture *rhiAoTexture = nullptr; |
126 | QSSGRhiShaderPipelinePtr ssaoShaderPipeline; |
127 | }; |
128 | |
129 | class Q_QUICK3DRUNTIMERENDER_PRIVATE_EXPORT DepthMapPass : public QSSGRenderPass |
130 | { |
131 | public: |
132 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
133 | void renderPass(QSSGRenderer &renderer) final; |
134 | Type passType() const final { return Type::Standalone; } |
135 | void release() final; |
136 | |
137 | QSSGRenderableObjectList sortedOpaqueObjects; |
138 | QSSGRenderableObjectList sortedTransparentObjects; |
139 | QSSGRhiGraphicsPipelineState ps; |
140 | QSSGRhiRenderableTexture *rhiDepthTexture = nullptr; |
141 | }; |
142 | |
143 | class ScreenMapPass : public QSSGRenderPass |
144 | { |
145 | public: |
146 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
147 | void renderPass(QSSGRenderer &renderer) final; |
148 | Type passType() const final { return Type::Standalone; } |
149 | void release() final; |
150 | |
151 | QSSGRhiRenderableTexture *rhiScreenTexture = nullptr; |
152 | QSSGRenderPass *skyboxPass = nullptr; |
153 | QSSGShaderFeatures shaderFeatures; |
154 | QSSGRenderableObjectList sortedOpaqueObjects; |
155 | QSSGRhiGraphicsPipelineState ps; |
156 | QColor clearColor{Qt::transparent}; |
157 | bool wantsMips = false; |
158 | }; |
159 | |
160 | class ScreenReflectionPass : public QSSGRenderPass |
161 | { |
162 | public: |
163 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
164 | void renderPass(QSSGRenderer &renderer) final; |
165 | Type passType() const final { return Type::Main; } |
166 | void release() final; |
167 | |
168 | QSSGRenderableObjectList sortedScreenTextureObjects; |
169 | const QSSGRhiRenderableTexture *rhiScreenTexture = nullptr; |
170 | QSSGRhiGraphicsPipelineState ps {}; |
171 | }; |
172 | |
173 | class OpaquePass : public QSSGRenderPass |
174 | { |
175 | public: |
176 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
177 | void renderPass(QSSGRenderer &renderer) final; |
178 | Type passType() const final { return Type::Main; } |
179 | void release() final; |
180 | |
181 | QSSGRenderableObjectList sortedOpaqueObjects; |
182 | QSSGRhiGraphicsPipelineState ps; |
183 | QSSGShaderFeatures shaderFeatures; |
184 | }; |
185 | |
186 | class TransparentPass : public QSSGRenderPass |
187 | { |
188 | public: |
189 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
190 | void renderPass(QSSGRenderer &renderer) final; |
191 | Type passType() const final { return Type::Main; } |
192 | void release() final; |
193 | |
194 | QSSGRenderableObjectList sortedTransparentObjects; |
195 | QSSGRhiGraphicsPipelineState ps; |
196 | QSSGShaderFeatures shaderFeatures; |
197 | }; |
198 | |
199 | class SkyboxPass : public QSSGRenderPass |
200 | { |
201 | public: |
202 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
203 | void renderPass(QSSGRenderer &renderer) final; |
204 | Type passType() const final { return Type::Main; } |
205 | void release() final; |
206 | |
207 | QSSGRenderLayer *layer = nullptr; |
208 | QSSGRhiGraphicsPipelineState ps; |
209 | bool skipTonemapping = false; |
210 | bool skipPrep = false; |
211 | }; |
212 | |
213 | class SkyboxCubeMapPass : public QSSGRenderPass |
214 | { |
215 | public: |
216 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
217 | void renderPass(QSSGRenderer &renderer) final; |
218 | Type passType() const final { return Type::Main; } |
219 | void release() final; |
220 | |
221 | QSSGRenderLayer *layer = nullptr; |
222 | QSSGRhiGraphicsPipelineState ps; |
223 | bool skipTonemapping = false; |
224 | }; |
225 | |
226 | class Item2DPass : public QSSGRenderPass |
227 | { |
228 | public: |
229 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
230 | void renderPass(QSSGRenderer &renderer) final; |
231 | Type passType() const final { return Type::Main; } |
232 | void release() final; |
233 | |
234 | QList<QSSGRenderItem2D *> item2Ds; |
235 | QSSGRhiGraphicsPipelineState ps {}; |
236 | }; |
237 | |
238 | class InfiniteGridPass : public QSSGRenderPass |
239 | { |
240 | public: |
241 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
242 | void renderPass(QSSGRenderer &renderer) final; |
243 | Type passType() const final { return Type::Main; } |
244 | void release() final; |
245 | |
246 | QSSGRhiGraphicsPipelineState ps {}; |
247 | QSSGRenderLayer *layer = nullptr; |
248 | }; |
249 | |
250 | class DebugDrawPass : public QSSGRenderPass |
251 | { |
252 | public: |
253 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
254 | void renderPass(QSSGRenderer &renderer) final; |
255 | Type passType() const final { return Type::Main; } |
256 | void release() final; |
257 | |
258 | QSSGRhiGraphicsPipelineState ps; |
259 | }; |
260 | |
261 | class QSSGRenderExtension; |
262 | |
263 | class UserPass : public QSSGRenderPass |
264 | { |
265 | public: |
266 | void renderPrep(QSSGRenderer &renderer, QSSGLayerRenderData &data) final; |
267 | void renderPass(QSSGRenderer &renderer) final; |
268 | Type passType() const final { return Type::Extension; } |
269 | void release() final; |
270 | |
271 | bool hasData() const { return extensions.size() != 0; } |
272 | |
273 | QList<QSSGRenderExtension *> extensions; |
274 | }; |
275 | |
276 | QT_END_NAMESPACE |
277 | |
278 | #endif // QSSGRENDERPASS_H |
279 | |