6#ifndef QSSGRENDERDATA_P_H
7#define QSSGRENDERDATA_P_H
20#include <QtGui/qmatrix4x4.h>
25#include <unordered_map>
27#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
29#include <condition_variable>
32class tst_NodeIndexing;
41class QSGRenderContext;
47 Q_DISABLE_COPY_MOVE(QSSGGlobalRenderNodeData)
49 struct InstanceTransforms
61 using VersionType = QSSGRenderNodeVersionType;
63 using LayerNodeView = QSSGDataView<QSSGRenderNode *>;
65 using GlobalTransformStore = std::vector<QMatrix4x4>;
66 using GlobalOpacityStore = std::vector<
float>;
67 using InstanceTransformStore = std::vector<InstanceTransforms>;
68 using NodeStore = std::vector<QSSGRenderNode *>;
69 using LayerNodeViewStore = std::vector<LayerNodeSection>;
71 using NormalMatrixStore = std::vector<QMatrix3x3>;
72 using MeshStore = std::vector<QSSGRenderMesh *>;
73 using MaterialList = QVector<QSSGRenderGraphObject *>;
74 using MaterialStore = std::vector<MaterialList>;
76 explicit QSSGGlobalRenderNodeData(QSSGRenderRoot *root);
77 ~QSSGGlobalRenderNodeData();
104 [[nodiscard]]
float getGlobalOpacity(QSSGRenderNodeHandle h,
float defaultValue = 1.0f)
const;
126 QThreadPool *threadPool()
const;
130 friend class ::tst_NodeIndexing;
132 void collectNodes(QSSGRenderRoot *rootNode);
133 void updateGlobalState();
135#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
136 std::unique_ptr<QThreadPool> m_threadPool;
139 QSSGRenderRoot *m_rootNode =
nullptr;
141 size_t m_nodeCount = 0;
142 VersionType m_version = 0;
143 VersionType m_stateGeneration = 0;
146using QSSGGlobalRenderNodeDataPtr = std::shared_ptr<QSSGGlobalRenderNodeData>;
150 QSSGRenderDataHelpers() =
delete;
170
171
172
173
174
175
176
177
178
179
180
181
182
183
185 static bool calcGlobalNodeData(QSSGRenderNode *node,
186 const VersionType version,
187 QSSGGlobalRenderNodeData::GlobalTransformStore &globalTransforms,
188 QSSGGlobalRenderNodeData::GlobalOpacityStore &globalOpacities)
191 return calcGlobalVariablesIndexed(node, version, globalTransforms, globalOpacities);
193 return updateGlobalNodeDataIndexed(node, version, globalTransforms, globalOpacities);
197
198
199
200
201
202
203
204
205
206
207
208
210 const VersionType version,
211 QSSGGlobalRenderNodeData::GlobalTransformStore &globalTransforms,
212 QSSGGlobalRenderNodeData::InstanceTransformStore &instanceTransforms);
216
217
218
219
220
221
222
223
226 static bool updateGlobalNodeDataIndexed(QSSGRenderNode *node,
227 const VersionType version,
228 QSSGGlobalRenderNodeData::GlobalTransformStore &globalTransforms,
229 QSSGGlobalRenderNodeData::GlobalOpacityStore &globalOpacities);
230 static bool calcGlobalVariablesIndexed(QSSGRenderNode *node,
231 const VersionType version,
232 QSSGGlobalRenderNodeData::GlobalTransformStore &globalTransforms,
233 QSSGGlobalRenderNodeData::GlobalOpacityStore &globalOpacities);
263 static quint32 getThreadPoolThreshold();
265 ModelViewProjectionStore modelViewProjections;
267 void prepareMeshData(
const QSSGModelsView &models,
QSSGRenderer *renderer);
268 void prepareMaterials(
const QSSGModelsView &models);
270 QSSGGlobalRenderNodeDataPtr m_gnd;
272 quint32 m_version = 0;
274#if QT_CONFIG(thread) && !defined(Q_OS_WASM)
310 QSSGGlobalRenderNodeDataPtr m_gnd;
312 QPointer<QSGRenderContext> item2DRenderContext;
313 Item2DRendererStore item2DRenderers;
314 ModelViewProjectionStore modelViewProjections;
316 const QMatrix4x4 flipMatrix { 1.0f, 0.0f, 0.0f, 0.0f,
317 0.0f, -1.0f, 0.0f, 0.0f,
318 0.0f, 0.0f, 1.0f, 0.0f,
319 0.0f, 0.0f, 0.0f, 1.0f };
322 quint32 m_version = 0;
QSSGRhiShaderPipelinePtr debugObjectShader
QSSGRhiGraphicsPipelineState ps
Type passType() const final
void resetForFrame() final
QSSGRhiGraphicsPipelineState ps
QSSGRhiShaderPipelinePtr gridShader
void resetForFrame() final
Type passType() const final
Type passType() const final
std::vector< QSGRenderer * > prepdItem2DRenderers
void resetForFrame() final
static constexpr int MaxBuckets
QSSGRhiGraphicsPipelineState ps
QSSGRenderMotionVectorMapPtr motionVectorMapManager
QSSGRenderableObjectList motionVectorPassObjects[MaxBuckets]
Type passType() const final
QSSGRhiRenderableTexture * rhiMotionVectorTexture
QSSGRenderCamera * camera
void resetForFrame() final
QSSGShaderFeatures shaderFeatures
QSSGRhiRenderableTexture * rhiABufferImage
QSSGRhiRenderableTexture * rhiAccumTexture
QRhiShaderResourceBindings * compositeSrb
QSSGRhiShaderPipelinePtr compositeShaderPipeline
QRhiBuffer * rhiAuxBuffer
QSSGRhiRenderableTexture * rhiAuxiliaryImage
QSSGRenderLayer::OITMethod method
void resetForFrame() final
Type passType() const final
QSSGRhiRenderableTexture * rhiRevealageTexture
QSSGRhiGraphicsPipelineState ps
void setMethod(QSSGRenderLayer::OITMethod m)
QSSGRhiRenderableTexture * rhiRevealageTexture
QRhiResourceUpdateBatch * rub
void setMethod(QSSGRenderLayer::OITMethod m)
QSSGRhiRenderableTexture * rhiABufferImage
QList< QRhiReadbackResult * > results
quint32 reportedNodeCount
QSSGShaderFeatures shaderFeatures
QSSGRenderLayer::OITMethod method
QRhiShaderResourceBindings * clearSrb
QSSGRenderableObjectList sortedTransparentObjects
QSSGRhiRenderableTexture * rhiAuxiliaryImage
QSSGRhiRenderableTexture * rhiCounterImage
QRhiTextureRenderTarget * renderTarget
QRhiBuffer * rhiAuxBuffer
void resetForFrame() final
QSSGRhiShaderPipelinePtr clearPipeline
QSSGRhiRenderableTexture * rhiDepthTexture
QSSGRhiGraphicsPipelineState ps
QRhiTexture * readbackImage
bool linkedListRequiresResize(QSize dim)
Type passType() const final
QRhiBuffer * rhiCounterBuffer
QSSGRhiRenderableTexture * rhiAccumTexture
static void prep(const QSSGRenderContextInterface &ctx, QSSGLayerRenderData &data, QSSGPassKey passKey, QSSGRhiGraphicsPipelineState &ps, QSSGShaderFeatures shaderFeatures, QRhiRenderPassDescriptor *rpDesc, const QSSGRenderableObjectList &sortedOpaqueObjects)
void resetForFrame() final
Type passType() const final
QSSGShaderFeatures shaderFeatures
QSSGRhiGraphicsPipelineState ps
static void render(const QSSGRenderContextInterface &ctx, const QSSGRhiGraphicsPipelineState &ps, const QSSGRenderableObjectList &sortedOpaqueObjects)
QSSGRenderableObjectList sortedOpaqueObjects
QRect viewport() const
Returns the viewport rectangle.
InstanceTransforms getInstanceTransforms(QSSGRenderNodeHandle h) const
float getGlobalOpacity(const QSSGRenderNode &node) const
LayerNodeView getLayerNodeView(const QSSGRenderLayer &layer) const
float getGlobalOpacity(QSSGRenderNodeHandle h, float defaultValue=1.0f) const
void bumpStateGeneration()
InstanceTransformStore instanceTransforms
size_t storageSize() const
GlobalOpacityStore globalOpacities
QMatrix4x4 getGlobalTransform(QSSGRenderNodeHandle h) const
QMatrix4x4 getGlobalTransform(const QSSGRenderNode &node) const
LayerNodeView getLayerNodeView(QSSGRenderLayerHandle h) const
QMatrix4x4 getGlobalTransform(QSSGRenderNodeHandle h, const QMatrix4x4 &defaultValue) const
VersionType stateGeneration() const
InstanceTransforms getInstanceTransforms(const QSSGRenderNode &node) const
VersionType version() const
GlobalTransformStore globalTransforms
NormalMatrixStore normalMatrices
LayerNodeViewStore layerNodes
bool isLayerVisible() const
QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer)
QSize textureDimensions() const
void setState(State state)
QRectF getViewport() const
QSSGRenderLayer * getLayer() const
const QSSGLayerRenderPreparationResultFlags & getFlags() const
QSSGLayerRenderPreparationResult()=default
friend class QSSGLayerRenderData
friend class QSSGRenderer
friend class QQuick3DWindowAttachment
static GlobalStateResult updateGlobalNodeState(QSSGRenderNode *node, const VersionType version)
updateGlobalNodeState
static bool calcInstanceTransforms(QSSGRenderNode *node, const VersionType version, QSSGGlobalRenderNodeData::GlobalTransformStore &globalTransforms, QSSGGlobalRenderNodeData::InstanceTransformStore &instanceTransforms)
calcInstanceTransforms
void releaseRenderData(const QSSGRenderItem2D &item)
void updateItem2DData(QSSGItem2DsView &items, QSSGRenderer *renderer, const QSSGRenderCameraDataList &renderCameraData)
Item2DRenderer getItem2DRenderer(const QSSGRenderItem2D &item) const
const QSSGGlobalRenderNodeDataPtr & globalNodeData() const
ModelViewProjections getModelViewProjection(const QSSGRenderItem2D &item) const
ModelViewProjections getModelViewProjection(QSSGRenderNodeHandle h) const
ModelViewProjections getModelViewProjection(QSSGRenderNodeHandle h) const
void updateModelData(QSSGModelsView &models, QSSGRenderer *renderer, const QSSGRenderCameraDataList &renderCameraData)
QMatrix3x3 getNormalMatrix(const QSSGRenderModel &model) const
const QSSGGlobalRenderNodeDataPtr & globalNodeData() const
QSSGRenderMesh * getMesh(const QSSGRenderModel &model) const
ModelViewProjections getModelViewProjection(const QSSGRenderModel &model) const
MaterialList getMaterials(const QSSGRenderModel &model) const
QMatrix3x3 getNormalMatrix(QSSGRenderNodeHandle h, QMatrix3x3 defaultValue) const
virtual ~QSSGRenderPass()
virtual void resetForFrame()=0
virtual Type passType() const =0
friend class QSSGParticleRenderer
void releaseItem2DData(const QSSGRenderItem2D &item2D)
const std::unique_ptr< QSSGRhiQuadRenderer > & rhiQuadRenderer() const
quint32 frameDepth() const
friend class QSSGRenderContextInterface
QRect scissorRect() const
void cleanupResources(QSet< QSSGRenderGraphObject * > &resources)
void setViewport(QRect inViewport)
void beginSubLayerRender(QSSGLayerRenderData &inLayer)
const std::unique_ptr< QSSGRhiCubeRenderer > & rhiCubeRenderer() const
void setScissorRect(QRect inScissorRect)
void endSubLayerRender(QSSGLayerRenderData &inLayer)
QSSGRenderContextInterface * contextInterface() const
void resetForFrame() final
std::shared_ptr< QSSGRenderReflectionMap > reflectionMapManager
QSSGRenderableObjectList reflectionPassObjects
std::vector< QSSGRenderReflectionProbe * > reflectionProbes
QSSGRhiGraphicsPipelineState ps
Type passType() const final
Type passType() const final
QSSGRhiRenderableTexture * rhiAoTexture
const QSSGRhiRenderableTexture * rhiDepthTexture
void resetForFrame() final
QSSGRhiShaderPipelinePtr ssaoShaderPipeline
QSSGAmbientOcclusionSettings aoSettings
const QSSGRenderCamera * camera
QSSGRhiGraphicsPipelineState ps
void resetForFrame() final
QSSGRhiGraphicsPipelineState ps
Type passType() const final
std::optional< SkyboxPass > skyboxPass
QSSGShaderFeatures shaderFeatures
QSSGRenderableObjectList sortedOpaqueObjects
std::optional< SkyboxCubeMapPass > skyboxCubeMapPass
QSSGRhiRenderableTexture * rhiScreenTexture
QSSGRenderableObjectList sortedScreenTextureObjects
const QSSGRhiRenderableTexture * rhiScreenTexture
QSSGRhiGraphicsPipelineState ps
void resetForFrame() final
Type passType() const final
QSSGRenderCamera * camera
QSSGBounds3 castingObjectsBox
QSSGShaderLightList globalLights
QSSGRenderableObjectList shadowPassObjects
QSSGRhiGraphicsPipelineState ps
QSSGBounds3 receivingObjectsBox
void resetForFrame() final
std::unique_ptr< QSSGRenderCamera > debugCamera
Type passType() const final
std::shared_ptr< QSSGRenderShadowMap > shadowMapManager
QSSGRhiRenderableTexture * offscreenTexture
QRhiShaderResourceBindings * backgroundSrb
void resetForFrame() final
Type passType() const final
QSSGRhiShaderPipelinePtr pipeline
QSSGRhiGraphicsPipelineState ps
QRhiRenderPassDescriptor * rpDesc
void resetForFrame() final
Type passType() const final
QRhiRenderPassDescriptor * rpDesc
QSSGRhiShaderPipelinePtr skyBoxCubeShader
QSSGRhiGraphicsPipelineState ps
void resetForFrame() final
Type passType() const final
void resetForFrame() final
QRhiRenderPassDescriptor * rpDesc
Type passType() const final
QSSGRhiGraphicsPipelineState ps
static void prep(const QSSGRenderContextInterface &ctx, QSSGLayerRenderData &data, QSSGPassKey passKey, QSSGRhiGraphicsPipelineState &ps, QSSGShaderFeatures shaderFeatures, QRhiRenderPassDescriptor *rpDesc, const QSSGRenderableObjectList &sortedTransparentObjects, bool oit=false)
QSSGRenderableObjectList sortedTransparentObjects
static void render(const QSSGRenderContextInterface &ctx, const QSSGRhiGraphicsPipelineState &ps, const QSSGRenderableObjectList &sortedTransparentObjects)
QSSGShaderFeatures shaderFeatures
QSSGRhiGraphicsPipelineState ps
void resetForFrame() final
Type passType() const final
Type passType() const final
QList< QSSGRenderExtension * > extensions
void resetForFrame() final
void resetForFrame() final
static constexpr size_t MAX_SUBPASS_DEPTH
QList< QSSGRenderUserPass * > userPasses
std::vector< UserPassData > userPassData
Type passType() const final
std::set< QSSGResourceId > visitedPasses
void resetForFrame() final
QSSGRenderableObjectList renderedOpaqueDepthPrepassObjects
Type passType() const final
QSSGRhiGraphicsPipelineState ps
QSSGRenderableObjectList renderedDepthWriteObjects
QSSGRenderResult::Key toInternalRenderResultKey(QSSGFrameData::RenderResult id)
@ SkyMaterialBackgroundTexture
Combined button and popup list for selecting options.
QSSGLayerRenderPreparationResultFlag
@ RequiresSkyMaterialPass
@ RequiresMotionVectorPass
@ MaterialHasCustomBlendMode
@ RequiresMipmapsForScreenTexture
static const char * effect_fragment_main_with_tonemapping
static const char * effect_vertex_main_post
static const char * effect_vertex_main_pre
static const char * effect_vertex_main_position
static const char * effect_fragment_main
QVector< QSSGRenderableObjectHandle > renderables
QSSGBakedLightingModel(const QSSGRenderModel *model, const QVector< QSSGRenderableObjectHandle > &renderables)
const QSSGRenderModel * model
QSSGDefaultMaterialPreparationResult(QSSGShaderDefaultMaterialKey inMaterialKey)
QSSGRenderableImage * firstImage
QSSGRenderableObjectFlags renderableFlags
QSSGShaderDefaultMaterialKey materialKey
bool requiresDepthTextureMS() const
void setRequiresSsaoPass(bool inValue)
void setRequiresMotionVectorPass(bool inValue)
void setRequiresScreenTexture(bool inValue)
bool wasLayerDataDirty() const
void setRequiresDepthTextureMS(bool inValue)
bool requiresDepthTexture() const
void setLayerDataDirty(bool inValue)
void setWasDirty(bool inValue)
bool requiresMipmapsForScreenTexture() const
void setRequiresSkyMaterialPass(bool inValue)
bool requiresScreenTexture() const
bool hasCustomBlendMode() const
void setRequiresNormalTexture(bool inValue)
bool requiresMotionVectorPass() const
bool requiresShadowMapPass() const
void setRequiresMipmapsForScreenTexture(bool inValue)
void setRequiresDepthTexture(bool inValue)
bool requiresSsaoPass() const
void setRequiresShadowMapPass(bool inValue)
bool requiresSkyMaterialPass() const
void setHasCustomBlendMode(bool inValue)
bool requiresNormalTexture() const
QRhiBuffer * counterBuffer
QRhiTextureRenderTarget * oitRenderTarget
QRhiTexture * copyTexture
QRhiRenderPassDescriptor * renderPassDescriptor
QSSGRhiRenderableTextureV2Ptr renderableTexture
std::optional< SkyboxCubeMapPass > skyboxCubeMapPass
std::vector< UserPassData > subPassData
QSSGRhiGraphicsPipelineState ps
QSSGShaderDefineList shaderDefines
QRhiDepthStencilClearValue depthStencilClearValue
QSSGRenderableObjectList renderables
std::optional< SkyboxPass > skyboxPass
std::optional< Item2DPass > item2DPass