6#ifndef QSSGRENDERHELPERS_P_H
7#define QSSGRENDERHELPERS_P_H
20#include <QtQuick3DRuntimeRender/qtquick3druntimerenderglobal.h>
22#include <QtQuick3DUtils/private/qssgaosettings_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h>
28class QSSGRenderShadowMap;
29class QRhiRenderPassDescriptor;
30class QSSGRenderReflectionMap;
31class QSSGRenderMotionVectorMap;
34class QSSGRhiShaderPipeline;
41 QSSGRhiGraphicsPipelineState &ps,
42 QSSGRenderShadowMap &shadowMapManager,
43 const QSSGRenderCamera &camera,
44 QSSGRenderCamera *debugCamera,
46 const QSSGRenderableObjectList &sortedOpaqueObjects,
48 const QSSGBounds3 &castingObjectsBox,
49 const QSSGBounds3 &receivingObjectsBox);
54 QSSGRhiGraphicsPipelineState *ps,
55 QSSGRenderReflectionMap &reflectionMapManager,
56 const QVector<QSSGRenderReflectionProbe *> &reflectionProbes,
57 const QSSGRenderableObjectList &reflectionPassObjects,
62 const QSSGRhiGraphicsPipelineState &basePipelineState,
63 QRhiRenderPassDescriptor *rpDesc,
65 const QSSGRenderableObjectList &sortedOpaqueObjects,
66 const QSSGRenderableObjectList &sortedTransparentObjects,
71 const QSSGRenderableObjectList &sortedOpaqueObjects,
72 const QSSGRenderableObjectList &sortedTransparentObjects,
73 bool *needsSetViewport);
77 const QSSGRhiGraphicsPipelineState &basePipelineState,
78 QRhiRenderPassDescriptor *rpDesc,
80 const QSSGRenderableObjectList &sortedOpaqueObjects);
83 const QSSGRenderableObjectList &sortedOpaqueObjects,
84 bool *needsSetViewport);
88 QSSGRhiRenderableTexture *renderableTex,
94 QSSGRhiShaderPipeline &shaderPipeline,
95 QSSGRhiGraphicsPipelineState &ps,
96 const QSSGAmbientOcclusionSettings &ao,
97 const QSSGRhiRenderableTexture &rhiAoTexture,
98 const QSSGRhiRenderableTexture &rhiDepthTexture,
99 const QSSGRenderCamera &camera);
104 QSSGRhiRenderableTexture *renderableTex,
108 QSSGRhiShaderResourceBindingList &bindings);
112 QSSGRenderLayer &layer,
113 QSSGRenderCameraList &cameras,
118 QSSGRenderLayer &layer,
119 QSSGRenderCameraList &cameras,
121 uint tonemapMode = 0);
125 QSSGRenderLayer &layer,
126 QSSGRenderCamera &inCamera,
129 QSSGRenderTextureCubeFace cubeFace);
133 const QSSGRhiGraphicsPipelineState &basePipelineState,
134 QRhiRenderPassDescriptor *rpDesc,
135 QSSGRenderGraphObject *overrideMaterial,
137 QSSGRenderableObjectList &inObjects,
138 QSSGShaderFeatures featureSet);
142 const QSSGRhiGraphicsPipelineState &basePipelineState,
143 QRhiRenderPassDescriptor *rpDesc,
145 QSSGRenderableObjectList &inObjects,
146 QSSGShaderFeatures featureSet);
150 const QSSGRhiGraphicsPipelineState &basePipelineState,
151 QRhiRenderPassDescriptor *rpDesc,
154 QSSGRenderableObjectList &inObjects,
155 QSSGShaderFeatures featureSet);
158 QSSGRenderableObjectList &inObjects);
164 QRhiRenderPassDescriptor *renderPassDescriptor,
165 QSSGRhiGraphicsPipelineState *ps,
166 QSSGShaderFeatures featureSet,
169 QSSGRenderCamera *alteredCamera =
nullptr,
170 QMatrix4x4 *alteredModelViewProjection =
nullptr,
179 QRhiRenderPassDescriptor *renderPassDescriptor,
180 QSSGRhiGraphicsPipelineState *ps,
181 QSSGShaderFeatures featureSet,
184 QSSGRenderCamera *alteredCamera =
nullptr,
185 QMatrix4x4 *alteredModelViewProjection =
nullptr,
191 const QSSGRhiGraphicsPipelineState &state,
193 bool *needsSetViewport,
195 qsizetype userPassIndex = -1);
199 QSSGRhiRenderableTexture *renderableTex,
205 QSSGRhiRenderableTexture *renderableTex);
210 const QMatrix4x4 &viewProjection,
212 QRhiRenderPassDescriptor *renderPassDescriptor,
213 QSSGRhiGraphicsPipelineState *ps,
214 QSSGRenderMotionVectorMap &motionVectorMapManager);
217 const QSSGRhiGraphicsPipelineState &state,
218 const QSSGRenderableObjectList *motionVectorPassObjects,
223 const int y = deviceRect.bottom() - layerViewport.bottom() + 1;
224 return QRect(layerViewport.x(), y, layerViewport.width(), layerViewport.height());
229 quint32 s = nodeCount;
230 quint32 s_sqrt = qSqrt(s);
231 quint32 s2 = s_sqrt * s_sqrt;
234 s2 = s_sqrt * s_sqrt;
241 quint32 s = size.width() * size.height() * levels;
242 return rhiCalculateABufferSize(s);
bool isLayerVisible() const
QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer)
QSize textureDimensions() const
friend class QSSGLayerRenderData
friend class QSSGRenderer
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)
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)
qsizetype reflectionProbeCount
QSSGDefaultMaterialPreparationResult(QSSGShaderDefaultMaterialKey inMaterialKey)