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
qssgrenderhelpers_p.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 QSSGRENDERHELPERS_P_H
7#define QSSGRENDERHELPERS_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/qtquick3druntimerenderglobal.h>
21
22#include <QtQuick3DUtils/private/qssgaosettings_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h>
24
25QT_BEGIN_NAMESPACE
26
27class QSSGRhiContext;
28class QSSGRenderShadowMap;
29class QRhiRenderPassDescriptor;
30class QSSGRenderReflectionMap;
31class QSSGRenderMotionVectorMap;
34class QSSGRhiShaderPipeline;
35
37{
38
39void rhiRenderShadowMap(QSSGRhiContext *rhiCtx,
40 QSSGPassKey passKey,
41 QSSGRhiGraphicsPipelineState &ps,
42 QSSGRenderShadowMap &shadowMapManager,
43 const QSSGRenderCamera &camera,
44 QSSGRenderCamera *debugCamera,
45 const QSSGShaderLightList &globalLights,
46 const QSSGRenderableObjectList &sortedOpaqueObjects,
47 QSSGRenderer &renderer,
48 const QSSGBounds3 &castingObjectsBox,
49 const QSSGBounds3 &receivingObjectsBox);
50
51void rhiRenderReflectionMap(QSSGRhiContext *rhiCtx,
52 QSSGPassKey passKey,
53 const QSSGLayerRenderData &inData,
54 QSSGRhiGraphicsPipelineState *ps,
55 QSSGRenderReflectionMap &reflectionMapManager,
56 const QVector<QSSGRenderReflectionProbe *> &reflectionProbes,
57 const QSSGRenderableObjectList &reflectionPassObjects,
58 QSSGRenderer &renderer);
59
60bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx,
61 QSSGPassKey passKey,
62 const QSSGRhiGraphicsPipelineState &basePipelineState,
63 QRhiRenderPassDescriptor *rpDesc,
64 QSSGLayerRenderData &inData,
65 const QSSGRenderableObjectList &sortedOpaqueObjects,
66 const QSSGRenderableObjectList &sortedTransparentObjects,
67 int samples,
68 int viewCount);
69
70void rhiRenderDepthPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps,
71 const QSSGRenderableObjectList &sortedOpaqueObjects,
72 const QSSGRenderableObjectList &sortedTransparentObjects,
73 bool *needsSetViewport);
74
75bool rhiPrepareNormalPass(QSSGRhiContext *rhiCtx,
76 QSSGPassKey passKey,
77 const QSSGRhiGraphicsPipelineState &basePipelineState,
78 QRhiRenderPassDescriptor *rpDesc,
79 QSSGLayerRenderData &inData,
80 const QSSGRenderableObjectList &sortedOpaqueObjects);
81
82void rhiRenderNormalPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps,
83 const QSSGRenderableObjectList &sortedOpaqueObjects,
84 bool *needsSetViewport);
85
86bool rhiPrepareAoTexture(QSSGRhiContext *rhiCtx,
87 const QSize &size,
88 QSSGRhiRenderableTexture *renderableTex,
89 quint8 viewCount);
90
91void rhiRenderAoTexture(QSSGRhiContext *rhiCtx,
92 QSSGPassKey passKey,
93 QSSGRenderer &renderer,
94 QSSGRhiShaderPipeline &shaderPipeline,
95 QSSGRhiGraphicsPipelineState &ps,
96 const QSSGAmbientOcclusionSettings &ao,
97 const QSSGRhiRenderableTexture &rhiAoTexture,
98 const QSSGRhiRenderableTexture &rhiDepthTexture,
99 const QSSGRenderCamera &camera);
100
101bool rhiPrepareScreenTexture(QSSGRhiContext *rhiCtx,
102 const QSize &size,
103 bool wantsMips,
104 QSSGRhiRenderableTexture *renderableTex,
105 quint8 viewCount);
106
107void addAccumulatorImageBindings(QSSGRhiShaderPipeline *shaderPipeline,
108 QSSGRhiShaderResourceBindingList &bindings);
109
110void rhiPrepareGrid(QSSGRhiContext *rhiCtx,
111 QSSGPassKey passKey,
112 QSSGRenderLayer &layer,
113 QSSGRenderCameraList &cameras,
114 QSSGRenderer &renderer);
115
116void rhiPrepareSkyBox(QSSGRhiContext *rhiCtx,
117 QSSGPassKey passKey,
118 QSSGRenderLayer &layer,
119 QSSGRenderCameraList &cameras,
120 QSSGRenderer &renderer,
121 uint tonemapMode = 0);
122
123void rhiPrepareSkyBoxForReflectionMap(QSSGRhiContext *rhiCtx,
124 QSSGPassKey passKey,
125 QSSGRenderLayer &layer,
126 QSSGRenderCamera &inCamera,
127 QSSGRenderer &renderer,
129 QSSGRenderTextureCubeFace cubeFace);
130
132 QSSGPassKey passKey,
133 const QSSGRhiGraphicsPipelineState &basePipelineState,
134 QRhiRenderPassDescriptor *rpDesc,
135 QSSGRenderGraphObject *overrideMaterial,
136 QSSGLayerRenderData &inData,
137 QSSGRenderableObjectList &inObjects,
138 QSSGShaderFeatures featureSet);
139
141 QSSGPassKey passKey,
142 const QSSGRhiGraphicsPipelineState &basePipelineState,
143 QRhiRenderPassDescriptor *rpDesc,
144 const QSSGLayerRenderData &inData,
145 QSSGRenderableObjectList &inObjects,
146 QSSGShaderFeatures featureSet);
147
148[[nodiscard]] qsizetype rhiPrepareAugmentedUserPass(QSSGRhiContext *rhiCtx,
149 QSSGPassKey passKey,
150 const QSSGRhiGraphicsPipelineState &basePipelineState,
151 QRhiRenderPassDescriptor *rpDesc,
152 const QSSGUserShaderAugmentation &shaderAugmentation,
153 const QSSGLayerRenderData &inData,
154 QSSGRenderableObjectList &inObjects,
155 QSSGShaderFeatures featureSet);
156
157void rhiRenderUserAugmentedPass(QSSGRhiContext *rhiCtx,
158 QSSGRenderableObjectList &inObjects);
159
160Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderable(QSSGRhiContext *rhiCtx,
161 QSSGPassKey passKey,
162 const QSSGLayerRenderData &inData,
163 QSSGRenderableObject &inObject,
164 QRhiRenderPassDescriptor *renderPassDescriptor,
165 QSSGRhiGraphicsPipelineState *ps,
166 QSSGShaderFeatures featureSet,
167 int samples,
168 int viewCount,
169 QSSGRenderCamera *alteredCamera = nullptr,
170 QMatrix4x4 *alteredModelViewProjection = nullptr,
171 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
172 QSSGReflectionMapEntry *entry = nullptr,
173 bool oit = false);
174
175Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderableForScreenMapPass(QSSGRhiContext *rhiCtx,
176 QSSGPassKey passKey,
177 const QSSGLayerRenderData &inData,
178 QSSGRenderableObject &inObject,
179 QRhiRenderPassDescriptor *renderPassDescriptor,
180 QSSGRhiGraphicsPipelineState *ps,
181 QSSGShaderFeatures featureSet,
182 int samples,
183 int viewCount,
184 QSSGRenderCamera *alteredCamera = nullptr,
185 QMatrix4x4 *alteredModelViewProjection = nullptr,
186 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
187 QSSGReflectionMapEntry *entry = nullptr,
188 bool oit = false);
189
190Q_QUICK3DRUNTIMERENDER_EXPORT void rhiRenderRenderable(QSSGRhiContext *rhiCtx,
191 const QSSGRhiGraphicsPipelineState &state,
192 QSSGRenderableObject &object,
193 bool *needsSetViewport,
194 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
195 qsizetype userPassIndex = -1);
196
197bool rhiPrepareDepthTexture(QSSGRhiContext *rhiCtx,
198 const QSize &size,
199 QSSGRhiRenderableTexture *renderableTex,
200 quint8 viewCount,
201 int samples = 1);
202
203bool rhiPrepareMotionVectorTexture(QSSGRhiContext *rhiCtx,
204 const QSize &size,
205 QSSGRhiRenderableTexture *renderableTex);
206
207void rhiPrepareMotionVectorRenderable(QSSGRhiContext *rhiCtx,
208 QSSGPassKey passKey,
209 const QSSGLayerRenderData &inData,
210 const QMatrix4x4 &viewProjection,
211 QSSGRenderableObject &inObject,
212 QRhiRenderPassDescriptor *renderPassDescriptor,
213 QSSGRhiGraphicsPipelineState *ps,
214 QSSGRenderMotionVectorMap &motionVectorMapManager);
215
216void rhiRenderMotionVector(QSSGRhiContext *rhiCtx,
217 const QSSGRhiGraphicsPipelineState &state,
218 const QSSGRenderableObjectList *motionVectorPassObjects,
219 int bucketsCount);
220
221inline QRect correctViewportCoordinates(const QRectF &layerViewport, const QRect &deviceRect)
222{
223 const int y = deviceRect.bottom() - layerViewport.bottom() + 1;
224 return QRect(layerViewport.x(), y, layerViewport.width(), layerViewport.height());
225}
226
227inline quint32 rhiCalculateABufferSize(int nodeCount)
228{
229 quint32 s = nodeCount;
230 quint32 s_sqrt = qSqrt(s);
231 quint32 s2 = s_sqrt * s_sqrt;
232 while (s2 < s) {
233 s_sqrt += 1;
234 s2 = s_sqrt * s_sqrt;
235 }
236 return s_sqrt;
237}
238
239inline quint32 rhiCalculateABufferSize(const QSize &size, int levels)
240{
241 quint32 s = size.width() * size.height() * levels;
242 return rhiCalculateABufferSize(s);
243}
244
245}
246
247QT_END_NAMESPACE
248
249
250#endif // QSSGRENDERHELPERS_P_H
QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer)
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
qsizetype rhiPrepareOverrideMaterialUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGRenderGraphObject *overrideMaterial, QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet)
void rhiPrepareSkyBox(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCameraList &cameras, QSSGRenderer &renderer, uint tonemapMode=0)
void rhiPrepareMotionVectorRenderable(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, const QMatrix4x4 &viewProjection, QSSGRenderableObject &inObject, QRhiRenderPassDescriptor *renderPassDescriptor, QSSGRhiGraphicsPipelineState *ps, QSSGRenderMotionVectorMap &motionVectorMapManager)
void rhiRenderShadowMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRhiGraphicsPipelineState &ps, QSSGRenderShadowMap &shadowMapManager, const QSSGRenderCamera &camera, QSSGRenderCamera *debugCamera, const QSSGShaderLightList &globalLights, const QSSGRenderableObjectList &sortedOpaqueObjects, QSSGRenderer &renderer, const QSSGBounds3 &castingObjectsBox, const QSSGBounds3 &receivingObjectsBox)
void rhiPrepareGrid(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCameraList &cameras, QSSGRenderer &renderer)
void rhiRenderUserAugmentedPass(QSSGRhiContext *rhiCtx, QSSGRenderableObjectList &inObjects)
quint32 rhiCalculateABufferSize(int nodeCount)
void rhiPrepareSkyBoxForReflectionMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCamera &inCamera, QSSGRenderer &renderer, QSSGReflectionMapEntry *entry, QSSGRenderTextureCubeFace cubeFace)
void rhiRenderAoTexture(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, QSSGRenderer &renderer, QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiGraphicsPipelineState &ps, const QSSGAmbientOcclusionSettings &ao, const QSSGRhiRenderableTexture &rhiAoTexture, const QSSGRhiRenderableTexture &rhiDepthTexture, const QSSGRenderCamera &camera)
bool rhiPrepareNormalPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGLayerRenderData &inData, const QSSGRenderableObjectList &sortedOpaqueObjects)
bool rhiPrepareMotionVectorTexture(QSSGRhiContext *rhiCtx, const QSize &size, QSSGRhiRenderableTexture *renderableTex)
Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderable(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRenderableObject &inObject, QRhiRenderPassDescriptor *renderPassDescriptor, QSSGRhiGraphicsPipelineState *ps, QSSGShaderFeatures featureSet, int samples, int viewCount, QSSGRenderCamera *alteredCamera=nullptr, QMatrix4x4 *alteredModelViewProjection=nullptr, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone, QSSGReflectionMapEntry *entry=nullptr, bool oit=false)
void rhiRenderNormalPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps, const QSSGRenderableObjectList &sortedOpaqueObjects, bool *needsSetViewport)
Q_QUICK3DRUNTIMERENDER_EXPORT void rhiRenderRenderable(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &state, QSSGRenderableObject &object, bool *needsSetViewport, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone, qsizetype userPassIndex=-1)
Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderableForScreenMapPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRenderableObject &inObject, QRhiRenderPassDescriptor *renderPassDescriptor, QSSGRhiGraphicsPipelineState *ps, QSSGShaderFeatures featureSet, int samples, int viewCount, QSSGRenderCamera *alteredCamera=nullptr, QMatrix4x4 *alteredModelViewProjection=nullptr, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone, QSSGReflectionMapEntry *entry=nullptr, bool oit=false)
qsizetype rhiPrepareAugmentedUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, const QSSGUserShaderAugmentation &shaderAugmentation, const QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet)
bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGLayerRenderData &inData, const QSSGRenderableObjectList &sortedOpaqueObjects, const QSSGRenderableObjectList &sortedTransparentObjects, int samples, int viewCount)
qsizetype rhiPrepareOriginalMaterialUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, const QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet)
bool rhiPrepareScreenTexture(QSSGRhiContext *rhiCtx, const QSize &size, bool wantsMips, QSSGRhiRenderableTexture *renderableTex, quint8 viewCount)
QRect correctViewportCoordinates(const QRectF &layerViewport, const QRect &deviceRect)
void addAccumulatorImageBindings(QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings)
bool rhiPrepareDepthTexture(QSSGRhiContext *rhiCtx, const QSize &size, QSSGRhiRenderableTexture *renderableTex, quint8 viewCount, int samples=1)
void rhiRenderMotionVector(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &state, const QSSGRenderableObjectList *motionVectorPassObjects, int bucketsCount)
void rhiRenderReflectionMap(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRhiGraphicsPipelineState *ps, QSSGRenderReflectionMap &reflectionMapManager, const QVector< QSSGRenderReflectionProbe * > &reflectionProbes, const QSSGRenderableObjectList &reflectionPassObjects, QSSGRenderer &renderer)
bool rhiPrepareAoTexture(QSSGRhiContext *rhiCtx, const QSize &size, QSSGRhiRenderableTexture *renderableTex, quint8 viewCount)
quint32 rhiCalculateABufferSize(const QSize &size, int levels)
void rhiRenderDepthPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps, const QSSGRenderableObjectList &sortedOpaqueObjects, const QSSGRenderableObjectList &sortedTransparentObjects, bool *needsSetViewport)
#define POS4BONETRANS(x)
#define POS4BONENORM(x)
static constexpr size_t getPrepContextIndex(QSSGPrepContextId id)
static bool scopeLight(QSSGRenderNode *node, QSSGRenderNode *lightScope)
static constexpr bool furthestToNearestCompare(const QSSGRenderableObjectHandle &lhs, const QSSGRenderableObjectHandle &rhs) noexcept
static int effectiveMaxDirectionalLightCount(const QSSGShaderFeatures &features)
static constexpr bool verifyPrepContext(QSSGPrepContextId id, const QSSGRenderer &renderer)
#define MAX_MORPH_TARGET_INDEX_SUPPORTS_NORMALS
static int cullLodInstances(QByteArray &lodData, const void *instances, int count, const QVector3D &cameraPosition, float minThreshold, float maxThreshold)
static bool isObjectCullable(const QSSGClippingFrustum &clipFrustum, const QSSGRenderableObject &obj)
static void clearTable(std::vector< T > &entry)
static constexpr quint16 PREP_CTX_INDEX_MASK
#define MAX_MORPH_TARGET_INDEX_SUPPORTS_TANGENTS
static void updateDirtySkeletons(const QSSGLayerRenderData &renderData, const QSSGLayerRenderData::QSSGModelsView &renderableNodes)
static bool hasCustomBlendMode(const QSSGRenderCustomMaterial &material)
static const int REDUCED_MAX_LIGHT_COUNT_THRESHOLD_BYTES
static bool checkParticleSupport(QRhi *rhi)
#define BONEDATASIZE4ID(x)
static void collectBoneTransforms(const QSSGLayerRenderData &renderData, QSSGRenderNode *node, QSSGRenderSkeleton *skeletonNode, const QVector< QMatrix4x4 > &poses)
static void sortInstances(QByteArray &sortedData, QList< QSSGRhiSortData > &sortData, const void *instances, int stride, int count, const QVector3D &cameraDirection)
#define CHECK_IMAGE_AND_PREPARE(img, imgtype, shadercomponent)
static constexpr bool nearestToFurthestCompare(const QSSGRenderableObjectHandle &lhs, const QSSGRenderableObjectHandle &rhs) noexcept
static constexpr size_t pipelineStateIndex(QSSGRenderablesFilter filter)
QSSGDataRef< T > RENDER_FRAME_NEW_BUFFER(QSSGRenderContextInterface &ctx, size_t count)
static const QVector2D s_ProgressiveAAVertexOffsets[QSSGLayerRenderData::MAX_AA_LEVELS]
static bool hasDirtyNonJointNodes(QSSGRenderNode *node, bool &hasChildJoints)
static int effectiveMaxLightCount(const QSSGShaderFeatures &features)
static constexpr QSSGPrepContextId createPrepId(size_t index, quint32 frame)
T * RENDER_FRAME_NEW(QSSGRenderContextInterface &ctx, Args &&... args)
static LayerNodeStatResult statLayerNodes(const QSSGLayerRenderData::LayerNodes &layerNodes, quint32 layerMask)
static float getCameraDistanceSq(const QSSGRenderableObject &obj, const QSSGRenderCameraData &camera) noexcept
static void createRenderablesHelper(QSSGLayerRenderData &layer, const QSSGRenderNode::ChildList &children, QSSGLayerRenderData::RenderableNodeEntries &renderables, QSSGRenderHelpers::CreateFlags createFlags)
QVarLengthArray< QSSGShaderLight, 16 > QSSGShaderLightList
friend QDebug operator<<(QDebug dbg, const LayerNodeStatResult &stat)
friend LayerNodeStatResult & operator+=(LayerNodeStatResult &lhs, const LayerNodeStatResult &rhs)
QSSGDefaultMaterialPreparationResult(QSSGShaderDefaultMaterialKey inMaterialKey)