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
25QT_BEGIN_NAMESPACE
26
27class QSSGRenderer;
28class QSSGRenderShadowMap;
29class QSSGRenderReflectionMap;
30class QSSGLayerRenderData;
31struct QSSGRenderCamera;
32struct QSSGRenderItem2D;
33
34class QSSGRenderPass
35{
36public:
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
57class ShadowMapPass : public QSSGRenderPass
58{
59public:
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
75class ReflectionMapPass : public QSSGRenderPass
76{
77public:
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
89class ZPrePassPass : public QSSGRenderPass
90{
91public:
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
103class SSAOMapPass : public QSSGRenderPass
104{
105public:
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
129class Q_QUICK3DRUNTIMERENDER_PRIVATE_EXPORT DepthMapPass : public QSSGRenderPass
130{
131public:
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
143class ScreenMapPass : public QSSGRenderPass
144{
145public:
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
160class ScreenReflectionPass : public QSSGRenderPass
161{
162public:
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
173class OpaquePass : public QSSGRenderPass
174{
175public:
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
186class TransparentPass : public QSSGRenderPass
187{
188public:
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
199class SkyboxPass : public QSSGRenderPass
200{
201public:
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
213class SkyboxCubeMapPass : public QSSGRenderPass
214{
215public:
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
226class Item2DPass : public QSSGRenderPass
227{
228public:
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
238class InfiniteGridPass : public QSSGRenderPass
239{
240public:
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
250class DebugDrawPass : public QSSGRenderPass
251{
252public:
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
261class QSSGRenderExtension;
262
263class UserPass : public QSSGRenderPass
264{
265public:
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
276QT_END_NAMESPACE
277
278#endif // QSSGRENDERPASS_H
279

source code of qtquick3d/src/runtimerender/rendererimpl/qssgrenderpass_p.h