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
39std::pair<QSSGBounds3, QSSGBounds3> calculateSortedObjectBounds(const QSSGRenderableObjectList &sortedOpaqueObjects,
40 const QSSGRenderableObjectList &sortedTransparentObjects);
41
42void rhiRenderShadowMap(QSSGRhiContext *rhiCtx,
43 QSSGPassKey passKey,
44 QSSGRhiGraphicsPipelineState &ps,
45 QSSGRenderShadowMap &shadowMapManager,
46 const QSSGRenderCamera &camera,
47 QSSGRenderCamera *debugCamera,
48 const QSSGShaderLightList &globalLights,
49 const QSSGRenderableObjectList &sortedOpaqueObjects,
50 QSSGRenderer &renderer,
51 const QSSGBounds3 &castingObjectsBox,
52 const QSSGBounds3 &receivingObjectsBox);
53
54void rhiRenderReflectionMap(QSSGRhiContext *rhiCtx,
55 QSSGPassKey passKey,
56 const QSSGLayerRenderData &inData,
57 QSSGRhiGraphicsPipelineState *ps,
58 QSSGRenderReflectionMap &reflectionMapManager,
59 const QVector<QSSGRenderReflectionProbe *> &reflectionProbes,
60 const QSSGRenderableObjectList &reflectionPassObjects,
61 QSSGRenderer &renderer);
62
63bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx,
64 QSSGPassKey passKey,
65 const QSSGRhiGraphicsPipelineState &basePipelineState,
66 QRhiRenderPassDescriptor *rpDesc,
67 QSSGLayerRenderData &inData,
68 const QSSGRenderableObjectList &sortedOpaqueObjects,
69 const QSSGRenderableObjectList &sortedTransparentObjects,
70 int samples,
71 int viewCount);
72
73void rhiRenderDepthPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps,
74 const QSSGRenderableObjectList &sortedOpaqueObjects,
75 const QSSGRenderableObjectList &sortedTransparentObjects,
76 bool *needsSetViewport);
77
78bool rhiPrepareNormalPass(QSSGRhiContext *rhiCtx,
79 QSSGPassKey passKey,
80 const QSSGRhiGraphicsPipelineState &basePipelineState,
81 QRhiRenderPassDescriptor *rpDesc,
82 QSSGLayerRenderData &inData,
83 const QSSGRenderableObjectList &sortedOpaqueObjects);
84
85void rhiRenderNormalPass(QSSGRhiContext *rhiCtx, const QSSGRhiGraphicsPipelineState &ps,
86 const QSSGRenderableObjectList &sortedOpaqueObjects,
87 bool *needsSetViewport);
88
89bool rhiPrepareAoTexture(QSSGRhiContext *rhiCtx,
90 const QSize &size,
91 QSSGRhiRenderableTexture *renderableTex,
92 quint8 viewCount);
93
94void rhiRenderAoTexture(QSSGRhiContext *rhiCtx,
95 QSSGPassKey passKey,
96 QSSGRenderer &renderer,
97 QSSGRhiShaderPipeline &shaderPipeline,
98 QSSGRhiGraphicsPipelineState &ps,
99 const QSSGAmbientOcclusionSettings &ao,
100 const QSSGRhiRenderableTexture &rhiAoTexture,
101 const QSSGRhiRenderableTexture &rhiDepthTexture,
102 const QSSGRenderCamera &camera);
103
104bool rhiPrepareScreenTexture(QSSGRhiContext *rhiCtx,
105 const QSize &size,
106 bool wantsMips,
107 QSSGRhiRenderableTexture *renderableTex,
108 quint8 viewCount);
109
110void addAccumulatorImageBindings(QSSGRhiShaderPipeline *shaderPipeline,
111 QSSGRhiShaderResourceBindingList &bindings);
112
113void rhiPrepareGrid(QSSGRhiContext *rhiCtx,
114 QSSGPassKey passKey,
115 QSSGRenderLayer &layer,
116 QSSGRenderCameraList &cameras,
117 QSSGRenderer &renderer);
118
119void rhiPrepareSkyBox(QSSGRhiContext *rhiCtx,
120 QSSGPassKey passKey,
121 QSSGRenderLayer &layer,
122 QSSGRenderCameraList &cameras,
123 QSSGRenderer &renderer,
124 uint tonemapMode = 0);
125
126void rhiPrepareSkyBoxForReflectionMap(QSSGRhiContext *rhiCtx,
127 QSSGPassKey passKey,
128 QSSGRenderLayer &layer,
129 QSSGRenderCamera &inCamera,
130 QSSGRenderer &renderer,
132 QSSGRenderTextureCubeFace cubeFace);
133
134void rhiPrepareOverrideMaterialUserPass(QSSGRhiContext *rhiCtx,
135 QSSGPassKey passKey,
136 const QSSGRhiGraphicsPipelineState &basePipelineState,
137 QRhiRenderPassDescriptor *rpDesc,
138 QSSGRenderGraphObject *overrideMaterial,
139 QSSGLayerRenderData &inData,
140 QSSGRenderableObjectList &inObjects,
141 QSSGShaderFeatures featureSet,
142 size_t index);
143
144void rhiPrepareOriginalMaterialUserPass(QSSGRhiContext *rhiCtx,
145 QSSGPassKey passKey,
146 const QSSGRhiGraphicsPipelineState &basePipelineState,
147 QRhiRenderPassDescriptor *rpDesc,
148 const QSSGLayerRenderData &inData,
149 QSSGRenderableObjectList &inObjects,
150 QSSGShaderFeatures featureSet,
151 size_t index);
152
153void rhiPrepareAugmentedUserPass(QSSGRhiContext *rhiCtx,
154 QSSGPassKey passKey,
155 const QSSGRhiGraphicsPipelineState &basePipelineState,
156 QRhiRenderPassDescriptor *rpDesc,
157 const QSSGUserShaderAugmentation &shaderAugmentation,
158 const QSSGLayerRenderData &inData,
159 QSSGRenderableObjectList &inObjects,
160 QSSGShaderFeatures featureSet, size_t index);
161
162void rhiRenderUserAugmentedPass(QSSGRhiContext *rhiCtx,
163 QSSGRenderableObjectList &inObjects);
164
165Q_QUICK3DRUNTIMERENDER_EXPORT void rhiPrepareRenderable(QSSGRhiContext *rhiCtx,
166 QSSGPassKey passKey,
167 const QSSGLayerRenderData &inData,
168 QSSGRenderableObject &inObject,
169 QRhiRenderPassDescriptor *renderPassDescriptor,
170 QSSGRhiGraphicsPipelineState *ps,
171 QSSGShaderFeatures featureSet,
172 int samples,
173 int viewCount,
174 QSSGRenderCamera *alteredCamera = nullptr,
175 QMatrix4x4 *alteredModelViewProjection = nullptr,
176 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
177 QSSGReflectionMapEntry *entry = nullptr,
178 bool oit = false);
179
180Q_QUICK3DRUNTIMERENDER_EXPORT void rhiRenderRenderable(QSSGRhiContext *rhiCtx,
181 const QSSGRhiGraphicsPipelineState &state,
182 QSSGRenderableObject &object,
183 bool *needsSetViewport,
184 QSSGRenderTextureCubeFace cubeFace = QSSGRenderTextureCubeFaceNone,
185 qsizetype userPassIndex = -1);
186
187bool rhiPrepareDepthTexture(QSSGRhiContext *rhiCtx,
188 const QSize &size,
189 QSSGRhiRenderableTexture *renderableTex,
190 quint8 viewCount,
191 int samples = 1);
192
193bool rhiPrepareMotionVectorTexture(QSSGRhiContext *rhiCtx,
194 const QSize &size,
195 QSSGRhiRenderableTexture *renderableTex);
196
197void rhiPrepareMotionVectorRenderable(QSSGRhiContext *rhiCtx,
198 QSSGPassKey passKey,
199 const QSSGLayerRenderData &inData,
200 const QMatrix4x4 &viewProjection,
201 QSSGRenderableObject &inObject,
202 QRhiRenderPassDescriptor *renderPassDescriptor,
203 QSSGRhiGraphicsPipelineState *ps,
204 QSSGRenderMotionVectorMap &motionVectorMapManager);
205
206void rhiRenderMotionVector(QSSGRhiContext *rhiCtx,
207 const QSSGRhiGraphicsPipelineState &state,
208 const QSSGRenderableObjectList *motionVectorPassObjects,
209 int bucketsCount);
210
211inline QRect correctViewportCoordinates(const QRectF &layerViewport, const QRect &deviceRect)
212{
213 const int y = deviceRect.bottom() - layerViewport.bottom() + 1;
214 return QRect(layerViewport.x(), y, layerViewport.width(), layerViewport.height());
215}
216
217inline quint32 rhiCalculateABufferSize(int nodeCount)
218{
219 quint32 s = nodeCount;
220 quint32 s_sqrt = qSqrt(s);
221 quint32 s2 = s_sqrt * s_sqrt;
222 while (s2 < s) {
223 s_sqrt += 1;
224 s2 = s_sqrt * s_sqrt;
225 }
226 return s_sqrt;
227}
228
229inline quint32 rhiCalculateABufferSize(const QSize &size, int levels)
230{
231 quint32 s = size.width() * size.height() * levels;
232 return rhiCalculateABufferSize(s);
233}
234
235}
236
237QT_END_NAMESPACE
238
239
240#endif // QSSGRENDERHELPERS_P_H
QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer)
friend class QSSGRenderContextInterface
Combined button and popup list for selecting options.
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)
void rhiPrepareOverrideMaterialUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGRenderGraphObject *overrideMaterial, QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet, size_t index)
void rhiPrepareAugmentedUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, const QSSGUserShaderAugmentation &shaderAugmentation, const QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet, size_t index)
bool rhiPrepareDepthPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, QSSGLayerRenderData &inData, const QSSGRenderableObjectList &sortedOpaqueObjects, const QSSGRenderableObjectList &sortedTransparentObjects, int samples, int viewCount)
std::pair< QSSGBounds3, QSSGBounds3 > calculateSortedObjectBounds(const QSSGRenderableObjectList &sortedOpaqueObjects, const QSSGRenderableObjectList &sortedTransparentObjects)
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 rhiPrepareOriginalMaterialUserPass(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGRhiGraphicsPipelineState &basePipelineState, QRhiRenderPassDescriptor *rpDesc, const QSSGLayerRenderData &inData, QSSGRenderableObjectList &inObjects, QSSGShaderFeatures featureSet, size_t index)
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 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)
static void cullLodInstances(QByteArray &lodData, const void *instances, int count, const QVector3D &cameraPosition, float minThreshold, float maxThreshold)
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)