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
qssglayerrenderdata_p.h
Go to the documentation of this file.
1// Copyright (C) 2008-2012 NVIDIA Corporation.
2// Copyright (C) 2022 The Qt Company Ltd.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
4// Qt-Security score:significant reason:default
5
6
7#ifndef QSSG_LAYER_RENDER_DATA_H
8#define QSSG_LAYER_RENDER_DATA_H
9
10
11//
12// W A R N I N G
13// -------------
14//
15// This file is not part of the Qt API. It exists purely as an
16// implementation detail. This header file may change from version to
17// version without notice, or even be removed.
18//
19// We mean it.
20//
21
22#include <QtQuick3DRuntimeRender/private/qssgrenderitem2d_p.h>
23#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
24#include <QtQuick3DRuntimeRender/private/qssgrendershadercache_p.h>
25#include <QtQuick3DRuntimeRender/private/qssgrenderableobjects_p.h>
26#include <QtQuick3DRuntimeRender/private/qssgrendershadowmap_p.h>
27#include <QtQuick3DRuntimeRender/private/qssgrendereffect_p.h>
28#include <QtQuick3DRuntimeRender/private/qssgrenderresourceloader_p.h>
29#include <QtQuick3DRuntimeRender/private/qssgrenderreflectionmap_p.h>
30#include <QtQuick3DRuntimeRender/private/qssgrenderskymaterialmanager_p.h>
31#include <QtQuick3DRuntimeRender/private/qssgrendercamera_p.h>
32#include <QtQuick3DRuntimeRender/private/qssgrhicontext_p.h>
33#include <QtQuick3DRuntimeRender/private/qssgperframeallocator_p.h>
34#include <QtQuick3DRuntimeRender/private/qssgshadermapkey_p.h>
35#include <QtQuick3DRuntimeRender/private/qssglightmapbaker_p.h>
36#include <QtQuick3DRuntimeRender/private/qssguserrenderpassmanager_p.h>
37#include <ssg/qssgrenderextensions.h>
38
39#include <QtQuick3DUtils/private/qssgrenderbasetypes_p.h>
40
41#include <optional>
42#include <unordered_map>
43
46
48
50
51class QSGRenderer;
52
54{
55
74
75inline QSSGRenderResult::Key toInternalRenderResultKey(QSSGFrameData::RenderResult id)
76{
77 switch (id) {
78 case QSSGFrameData::RenderResult::AoTexture:
80 case QSSGFrameData::RenderResult::DepthTexture:
82 case QSSGFrameData::RenderResult::ScreenTexture:
84 case QSSGFrameData::RenderResult::NormalTexture:
86 case QSSGFrameData::RenderResult::MotionVectorTexture:
88 }
89
90 if (size_t(QSSGRenderResult::Key::CounterImage) > size_t(id))
91 return static_cast<QSSGRenderResult::Key>(size_t(id));
92
94}
95
96} // namespace QSSGRenderResult
97
99{
100 // Was the data in this layer dirty (meaning re-render to texture, possibly)
102
103 // Was the data in this layer dirty *or* this layer *or* any effect dirty.
104 WasDirty = 1 << 1,
105
107
108 // SSAO should be done in a separate pass
109 // Note that having an AO pass necessitates a DepthTexture so this flag should
110 // never be set without the RequiresDepthTexture flag as well.
112
113 // if some light cause shadow
114 // we need a separate per light shadow map pass
116
118
119 // set together with RequiresScreenTexture when SCREEN_MIP_TEXTURE is used
121
122 // Set when material has custom blend mode(not SourceOver)
124
125 // Set when multisampled depth texture is required
127
129
131
133};
134
136{
137 bool wasLayerDataDirty() const
138 {
140 }
141 void setLayerDataDirty(bool inValue)
142 {
144 }
145
146 bool wasDirty() const { return this->operator&(QSSGLayerRenderPreparationResultFlag::WasDirty); }
147 void setWasDirty(bool inValue) { setFlag(QSSGLayerRenderPreparationResultFlag::WasDirty, inValue); }
148
150 {
152 }
153 void setRequiresDepthTexture(bool inValue)
154 {
156 }
157
166
168 void setRequiresSsaoPass(bool inValue)
169 {
171 }
172
174 {
176 }
181
183 {
185 }
190
199
208
210 {
212 }
217
226
235};
236
238{
239public:
240 enum class State : quint8
241 {
242 Null = 0,
245 };
246
248 QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer);
249
250 void setState(State state) { m_state = state; }
251 State getState() const { return m_state; }
252 bool isNull() const { return !layer && m_state == State::Null; }
253 bool isLayerVisible() const;
254 QSize textureDimensions() const;
255 QRectF getViewport() const { return viewport; }
256 const QSSGLayerRenderPreparationResultFlags &getFlags() const { return flags; }
257 QSSGRenderLayer *getLayer() const { return layer; }
258
259private:
261 friend class QSSGFrameData;
262
264 QRectF viewport;
265 QSSGRenderLayer *layer = nullptr;
266 State m_state = State::Null;
267};
268
279
281{
282 QSSGBakedLightingModel(const QSSGRenderModel *model, const QVector<QSSGRenderableObjectHandle> &renderables)
283 : model(model),
285 { }
286
289};
290
292{
294 QRhiRenderPassDescriptor *renderPassDescriptor = nullptr;
295 QRhiTexture *colorTexture = nullptr;
296 QRhiTexture *copyTexture = nullptr;
297 QRhiBuffer *aBuffer = nullptr;
303 void reset()
304 {
305 delete oitRenderTarget;
307 delete colorTexture;
308 delete copyTexture;
309 delete aBuffer;
310 delete auxBuffer;
311 delete counterBuffer;
312 for (const auto *result : std::as_const(completedResults))
313 delete result;
314 completedResults.clear();
315 if (rub) {
316 rub->release();
317 rub = nullptr;
318 delete pendingResult;
319 } else if (pendingResult) {
320 // Still in flight: QRhi writes to it later, so the completion callback takes ownership.
321 pendingResult->completed = [result = pendingResult] { delete result; };
322 }
323 oitRenderTarget = nullptr;
324 renderPassDescriptor = nullptr;
325 colorTexture = nullptr;
326 copyTexture = nullptr;
327 aBuffer = nullptr;
328 auxBuffer = nullptr;
329 counterBuffer = nullptr;
330 pendingResult = nullptr;
331 }
332};
333
335{
340 // Current frame
341 int dirLights = 0;
342 int spotLights = 0;
343 int pointLights = 0;
345 void reset()
346 {
347 delete lightBuffer;
348 delete dirLightBuffer;
349 lightBuffer = nullptr;
350 dirLightBuffer = nullptr;
351 dirLights = 0;
352 spotLights = 0;
353 pointLights = 0;
354 lightData.clear();
355 dirLightData.clear();
356 }
357};
358
359class Q_QUICK3DRUNTIMERENDER_EXPORT QSSGLayerRenderData
360{
361public:
362 enum Enum {
363 MAX_AA_LEVELS = 8,
364 MAX_TEMPORAL_AA_LEVELS = 2,
365 };
366
367 enum RenderPassOrigin
368 {
369 WindowOrigin,
370 FramebufferOrigin,
371 };
372
373 RenderPassOrigin m_currentOrigin = WindowOrigin;
374 QVector2D m_viewportOrigin;
375
376 using InstanceTransforms = QSSGGlobalRenderNodeData::InstanceTransforms;
377 using ModelViewProjections = QSSGRenderModelData::ModelViewProjections;
378
379 using QSSGModelsView = QSSGDataView<QSSGRenderModel *>;
380 using QSSGParticlesView = QSSGDataView<QSSGRenderParticles *>;
381 using QSSGItem2DsView = QSSGDataView<QSSGRenderItem2D *>;
382 using QSSGCamerasView = QSSGDataView<QSSGRenderCamera *>;
383 using QSSGLightsView = QSSGDataView<QSSGRenderLight *>;
384 using QSSGReflectionProbesView = QSSGDataView<QSSGRenderReflectionProbe *>;
385 using QSSGNonCategorizedView = QSSGDataView<QSSGRenderNode *>;
386
387 using RenderableFilter = std::function<bool(QSSGModelContext *)>;
388
389 QSSGLayerRenderData(QSSGRenderLayer &inLayer, QSSGRenderer &inRenderer);
390 ~QSSGLayerRenderData();
391
392 typedef QVector<QSSGModelContext *> TModelContextPtrList;
393 using RenderableNodeEntries = QVector<QSSGRenderableNodeEntry>;
394 using RenderableItem2DEntries = QVector<QSSGRenderItem2D *>;
395
396 void prepareImageForRender(QSSGRenderImage &inImage,
397 QSSGRenderableImage::Type inMapType,
398 QSSGRenderableImage *&ioFirstImage,
399 QSSGRenderableImage *&ioNextImage,
400 QSSGRenderableObjectFlags &ioFlags,
401 QSSGShaderDefaultMaterialKey &ioGeneratedShaderKey,
402 quint32 inImageIndex, QSSGRenderDefaultMaterial *inMaterial = nullptr);
403
404 void setVertexInputPresence(const QSSGRenderableObjectFlags &renderableFlags,
405 QSSGShaderDefaultMaterialKey &key);
406
407 static void prepareModelBoneTextures(const QSSGRenderContextInterface &contextInterface,
408 const RenderableNodeEntries &renderableModels);
409
410 // Helper functions used during PrepareForRender and PrepareAndRender
411 // Updates lights with model receivesShadows. Do not pass globalLights.
412 bool prepareModelsForRender(QSSGRenderContextInterface &ctx,
413 const RenderableNodeEntries &renderableModels,
414 QSSGLayerRenderPreparationResultFlags &ioFlags,
415 const QSSGRenderCameraList &allCameras,
416 const QSSGRenderCameraDataList &allCameraData,
417 TModelContextPtrList &modelContexts,
418 QSSGRenderableObjectList &opaqueObjects,
419 QSSGRenderableObjectList &transparentObjects,
420 QSSGRenderableObjectList &screenTextureObjects,
421 float lodThreshold = 0.0f);
422 bool prepareParticlesForRender(const RenderableNodeEntries &renderableParticles, const QSSGRenderCameraData &cameraData, QSSGLayerRenderPreparationResultFlags &ioFlags);
423
424 void prepareResourceLoaders();
425
426 void prepareForRender();
427 // Helper function used during prepareForRender
428 void prepareReflectionProbesForRender();
429
430 [[nodiscard]] static qsizetype frustumCullingInline(const QSSGClippingFrustum &clipFrustum, QSSGRenderableObjectList &renderables);
431
432 [[nodiscard]] static qsizetype filterLayerMaskInline(quint32 layerMask, QSSGRenderableObjectList &renderables);
433
434
435 // Per-frame cache of renderable objects post-sort (for the MAIN rendering camera, i.e., don't use these lists for rendering from a different camera).
436 const QSSGRenderableObjectList &getSortedOpaqueRenderableObjects(const QSSGRenderCamera &camera, size_t index = 0, quint32 layerMask = 0xFFFFFFFF);
437 // If layer depth test is false, this may also contain opaque objects.
438 const QSSGRenderableObjectList &getSortedTransparentRenderableObjects(const QSSGRenderCamera &camera, size_t index = 0, quint32 layerMask = 0xFFFFFFFF);
439 const QSSGRenderableObjectList &getSortedScreenTextureRenderableObjects(const QSSGRenderCamera &camera, size_t index = 0);
440 const QVector<QSSGBakedLightingModel> &getSortedBakedLightingModels();
441 const RenderableItem2DEntries &getRenderableItem2Ds();
442 const QSSGRenderableObjectList &getSortedRenderedDepthWriteObjects(const QSSGRenderCamera &camera, size_t index = 0);
443 const QSSGRenderableObjectList &getSortedrenderedOpaqueDepthPrepassObjects(const QSSGRenderCamera &camera, size_t index = 0);
444 void getShadowCastingObjects(const QSSGRenderCamera &camera,
445 QSSGRenderableObjectList &outObjects,
446 QSSGBounds3 &outBoundsCasting,
447 QSSGBounds3 &outBoundsReceiving);
448
449 void resetForFrame();
450
451 QSSGFrameData &getFrameData();
452
453 ShadowMapPass shadowMapPass;
454 ReflectionMapPass reflectionMapPass;
455 ZPrePassPass zPrePassPass;
456 SSAOMapPass ssaoMapPass;
457 DepthMapPass depthMapPass;
458 DepthMapPass depthMapPassMS;
459 SkyMaterialPass skyMaterialPass;
460 ScreenMapPass screenMapPass;
461 ScreenReflectionPass reflectionPass;
462 Item2DPass item2DPass;
463 SkyboxPass skyboxPass;
464 SkyMaterialBackgroundPass skyMaterialBackgroundPass;
465 SkyboxCubeMapPass skyboxCubeMapPass;
466 UserPassBase earlyUserPasses;
467 UserPassBase userRenderPasses;
468 static constexpr size_t USERPASSES = 3; // See QSSGRenderLayer::RenderExtensionMode::Count
469 UserExtensionPass userPasses[USERPASSES];
470 OpaquePass opaquePass;
471 TransparentPass transparentPass;
472 OITRenderPass oitRenderPass;
473 OITCompositePass oitCompositePass;
474 InfiniteGridPass infiniteGridPass;
475 DebugDrawPass debugDrawPass;
476 NormalPass normalPass;
477 MotionVectorMapPass motionVectorMapPass;
478
479 // Built-in passes
480 QVarLengthArray<QSSGRenderPass *, 16> activePasses;
481
482 QSSGRenderLayer &layer;
483 QSSGRenderer *renderer = nullptr;
484 // List of nodes we can render, not all may be active. Found by doing a depth-first
485 // search through m_FirstChild if length is zero.
486
487 using LayerNodes = std::vector<QSSGRenderNode *>;
488 QSSGGlobalRenderNodeData::LayerNodeView layerNodes;
489
490 // renderableNodes have all lights, but properties configured for specific node
491 RenderableNodeEntries renderableModels;
492 RenderableNodeEntries renderableParticles;
493
494 // Views into the collected nodes (unsorted)
495 class NodeCollection
496 {
497 Q_DISABLE_COPY(NodeCollection)
498 public:
499 NodeCollection() = default;
500
501 QSSGModelsView modelsView;
502 QSSGParticlesView particlesView;
503 QSSGItem2DsView item2DsView;
504 QSSGCamerasView camerasView;
505 QSSGLightsView lightsView;
506 QSSGReflectionProbesView reflectionProbesView;
507 QSSGNonCategorizedView nonCategorizedView;
508 LayerNodes layerNodesCategorized;
509 };
510 NodeCollection nodeCollection;
511 // FIXME: Convenience for now
512 QSSGModelsView &modelsView = nodeCollection.modelsView;
513 QSSGParticlesView &particlesView = nodeCollection.particlesView;
514 QSSGItem2DsView &item2DsView = nodeCollection.item2DsView;
515 QSSGCamerasView &camerasView = nodeCollection.camerasView;
516 QSSGLightsView &lightsView = nodeCollection.lightsView;
517 QSSGReflectionProbesView &reflectionProbesView = nodeCollection.reflectionProbesView;
518 QSSGNonCategorizedView &nonCategorizedView = nodeCollection.nonCategorizedView;
519
520 // Results of prepare for render.
521 QSSGRenderCameraList renderedCameras; // multiple items with multiview, one otherwise (or zero if no cameras at all)
522 QSSGShaderLightList globalLights; // All non-scoped lights
523
524 QVector<QSSGBakedLightingModel> bakedLightingModels;
525 // Sorted lists of the rendered objects. There may be other transforms applied so
526 // it is simplest to duplicate the lists.
527 QVector<QSSGBakedLightingModel> renderedBakedLightingModels;
528 RenderableItem2DEntries renderedItem2Ds;
529
530 QSSGLayerRenderPreparationResult layerPrepResult;
531 std::optional<QSSGRenderCameraDataList> renderedCameraData;
532
533 TModelContextPtrList modelContexts;
534
535 QQsbCollection::EntryMap m_particleShaderEntries;
536
537 enum class OneShotWarning : quint16 {
538 NonExplicitCameraWithLayerMask = 0x0001,
539 TooManyLights = 0x0002,
540 TooManyDirectionalLights = 0x0004,
541 OitUnsupported = 0x0008,
542 OitInvalidBlendMode = 0x0010,
543 ComputeUnsupported = 0x0020,
544 MissingPosition = 0x0040,
545 IndirectDrawUnsupported = 0x0080,
546 IndirectBufferUsage = 0x0100,
547 IndirectBufferSize = 0x0200,
548 BakedLightingWithoutVertexData = 0x0400,
549 BufferlessInstancingUnsupported = 0x0800,
550 BufferlessInstancingLod = 0x1000,
551 };
552 Q_DECLARE_FLAGS(OneShotWarnings, OneShotWarning)
553
554 [[nodiscard]] bool warnOnce(OneShotWarning warning)
555 {
556 if (shownWarnings.testFlag(warning))
557 return false;
558 shownWarnings |= warning;
559 return true;
560 }
561
562 bool orderIndependentTransparencyEnabled = false;
563 bool disableMainPasses = true;
564 bool computeLightsUpdated = false;
565
566 std::unique_ptr<QSSGLightmapBaker> lightmapBaker = nullptr;
567
568 QSSGShaderFeatures getShaderFeatures() const { return features; }
569 QSSGRhiGraphicsPipelineState getPipelineState() const { return ps; }
570
571 void initializeLightmapBaking(QSSGLightmapBaker::Context &ctx);
572 void maybeProcessLightmapBaking();
573
574 [[nodiscard]] QSSGRenderGraphObject *getCamera(QSSGCameraId id) const;
575 [[nodiscard]] QSSGRenderCamera *activeCamera() const { return !renderedCameras.isEmpty() ? renderedCameras[0] : nullptr; }
576
577 [[nodiscard]] QSSGRenderCameraData getCameraRenderData(const QSSGRenderCamera *camera);
578 [[nodiscard]] QSSGRenderCameraData getCameraRenderData(const QSSGRenderCamera *camera) const;
579
580 void setLightmapTexture(const QSSGModelContext &modelContext, QRhiTexture *lightmapTexture);
581 [[nodiscard]] QRhiTexture *getLightmapTexture(const QSSGModelContext &modelContext) const;
582
583 void setBonemapTexture(const QSSGModelContext &modelContext, QRhiTexture *bonemapTexture);
584 [[nodiscard]] QRhiTexture *getBonemapTexture(const QSSGModelContext &modelContext) const;
585
586 [[nodiscard]] QSSGRenderContextInterface *contextInterface() const;
587 // Note: temp. API to report the state of the z-prepass step
588 [[nodiscard]] bool isZPrePassActive() const { return zPrePassActive; }
589 void setZPrePassPrepResult(bool res) { zPrePassActive = res; }
590
591 // Exposed as const, as we often need to use this to look-up values from a specific key.
592 [[nodiscard]] const QSSGShaderDefaultMaterialKeyProperties &getDefaultMaterialPropertyTable() const
593 {
594 return defaultMaterialShaderKeyProperties;
595 }
596 [[nodiscard]] const QSSGShaderParticleMaterialKeyProperties &getParticleMaterialPropertyTable() const
597 {
598 return particleMaterialShaderKeyProperties;
599 }
600
601 struct GlobalRenderProperties
602 {
603 bool isYUpInFramebuffer = true;
604 bool isYUpInNDC = true;
605 bool isClipDepthZeroToOne = true;
606 };
607
608 [[nodiscard]] static GlobalRenderProperties globalRenderProperties(const QSSGRenderContextInterface &ctx);
609
610 // Temp. API. Ideally there shouldn't be a reason for anyone to hold onto these,
611 // but we follow the existing pattern for now.
612 const QSSGRenderShadowMapPtr &requestShadowMapManager();
613 const QSSGRenderReflectionMapPtr &requestReflectionMapManager();
614 const QSSGRenderSkyMaterialManagerPtr &requestSkyMaterialManager();
615 const QSSGUserRenderPassManagerPtr &requestUserRenderPassManager();
616 const QSSGRenderMotionVectorMapPtr &requestMotionVectorMapManager();
617 const QSSGRenderShadowMapPtr &getShadowMapManager() const { return shadowMapManager; }
618 const QSSGRenderReflectionMapPtr &getReflectionMapManager() const { return reflectionMapManager; }
619 const QSSGRenderSkyMaterialManagerPtr &getSkyMaterialManager() const { return skyMaterialManager; }
620 const QSSGUserRenderPassManagerPtr &getUserRenderPassManager() const { return userRenderPassManager; }
621 const QSSGRenderMotionVectorMapPtr &getMotionvectorMapManager() const { return motionVectorMapManager; }
622
623 QSSGOITRenderContext &getOitRenderContext() { return oitRenderContext; }
624 const QSSGOITRenderContext &getOitRenderContextConst() const { return oitRenderContext; }
625 QSSGComputeLightContext &getComputeLightContext() { return computeLightContext; }
626 const QSSGComputeLightContext &getComputeLightContextConst() const { return computeLightContext; }
627
628 static bool prepareInstancing(QSSGRhiContext *rhiCtx,
629 QSSGSubsetRenderable *renderable,
630 const QVector3D &cameraDirection,
631 const QVector3D &cameraPosition,
632 float minThreshold,
633 float maxThreshold,
634 const QSSGLayerRenderData &layerData);
635
636 // Distributes the instances into the levels of the automatic per-instance LOD, for the
637 // camera of layerData. Call after prepareInstancing().
638 static void prepareAutoLodInstancing(QSSGRhiContext *rhiCtx,
639 QSSGSubsetRenderable *renderable,
640 const QSSGLayerRenderData &layerData);
641
642 [[nodiscard]] QSSGRhiRenderableTexture *getRenderResult(QSSGRenderResult::Key id) { return &renderResults[size_t(id)]; }
643 [[nodiscard]] const QSSGRhiRenderableTexture *getRenderResult(QSSGRenderResult::Key id) const { return &renderResults[size_t(id)]; }
644
645 QSSGRenderImageTexture skyMaterialTexture; // Always a cubemap, might be IBL
646 void resolveLayerIblTexture(QSSGPassKey passKey);
647
648 [[nodiscard]] static inline const std::unique_ptr<QSSGPerFrameAllocator> &perFrameAllocator(QSSGRenderContextInterface &ctx);
649 [[nodiscard]] static inline QSSGLayerRenderData *getCurrent(const QSSGRenderer &renderer) { return renderer.m_currentLayer; }
650 void saveRenderState(const QSSGRenderer &renderer);
651 void restoreRenderState(QSSGRenderer &renderer);
652
653 static void setTonemapFeatures(QSSGShaderFeatures &features, QSSGRenderLayer::TonemapMode tonemapMode)
654 {
655 features.set(QSSGShaderFeatures::Feature::LinearTonemapping,
656 tonemapMode == QSSGRenderLayer::TonemapMode::Linear);
657 features.set(QSSGShaderFeatures::Feature::AcesTonemapping,
658 tonemapMode == QSSGRenderLayer::TonemapMode::Aces);
659 features.set(QSSGShaderFeatures::Feature::HejlDawsonTonemapping,
660 tonemapMode == QSSGRenderLayer::TonemapMode::HejlDawson);
661 features.set(QSSGShaderFeatures::Feature::FilmicTonemapping,
662 tonemapMode == QSSGRenderLayer::TonemapMode::Filmic);
663 features.set(QSSGShaderFeatures::Feature::ForceIblExposure,
664 tonemapMode == QSSGRenderLayer::TonemapMode::Custom);
665 }
666
667 QSSGPrepContextId getOrCreateExtensionContext(const QSSGRenderExtension &ext,
668 QSSGRenderCamera *camera = nullptr,
669 quint32 slot = 0);
670
671 // Model API
672 QSSGRenderablesId createRenderables(QSSGPrepContextId prepId, const QSSGNodeIdList &nodes, QSSGRenderHelpers::CreateFlags createFlags);
673 void setGlobalTransform(QSSGRenderablesId renderablesId, const QSSGRenderModel &model, const QMatrix4x4 &mvp);
674 QMatrix4x4 getGlobalTransform(QSSGPrepContextId prepId, const QSSGRenderModel &model);
675 void setGlobalOpacity(QSSGRenderablesId renderablesId, const QSSGRenderModel &model, float opacity);
676 float getGlobalOpacity(QSSGPrepContextId prepId, const QSSGRenderModel &model);
677 [[nodiscard]] QMatrix4x4 getModelMvps(QSSGPrepContextId prepId, const QSSGRenderModel &model) const;
678 void setModelMaterials(QSSGRenderablesId renderablesId, const QSSGRenderModel &model, const QList<QSSGResourceId> &materials);
679 void setModelMaterials(const QSSGRenderablesId renderablesId, const QList<QSSGResourceId> &materials);
680 [[nodiscard]] QSSGPrepResultId prepareModelsForRender(QSSGRenderContextInterface &contextInterface,
681 QSSGPrepContextId prepId,
682 QSSGRenderablesId renderablesId,
683 float lodThreshold);
684
685 // Convenience wrappers for getting values from the node, model store.
686 [[nodiscard]] QMatrix4x4 getGlobalTransform(QSSGRenderNodeHandle h, const QMatrix4x4 &defaultValue) const
687 {
688 return nodeData->getGlobalTransform(h, defaultValue);
689 }
690 [[nodiscard]] QMatrix4x4 getGlobalTransform(QSSGRenderNodeHandle h) const
691 {
692 return nodeData->getGlobalTransform(h, QMatrix4x4());
693 }
694 [[nodiscard]] QMatrix4x4 getGlobalTransform(const QSSGRenderNode &node) const
695 {
696 return nodeData->getGlobalTransform(node.h, node.localTransform);
697 }
698 [[nodiscard]] QMatrix3x3 getNormalMatrix(QSSGRenderNodeHandle h) const
699 {
700 return modelData->getNormalMatrix(h, QMatrix3x3(Qt::Uninitialized));
701 }
702 [[nodiscard]] QMatrix3x3 getNormalMatrix(const QSSGRenderModel &model) const
703 {
704 return modelData->getNormalMatrix(model);
705 }
706 [[nodiscard]] ModelViewProjections getModelMvps(QSSGRenderNodeHandle h) const
707 {
708 return modelData->getModelViewProjection(h);
709 }
710 [[nodiscard]] ModelViewProjections getModelMvps(const QSSGRenderModel &model) const
711 {
712 return modelData->getModelViewProjection(model);
713 }
714 [[nodiscard]] InstanceTransforms getInstanceTransforms(QSSGRenderNodeHandle h) const
715 {
716 return nodeData->getInstanceTransforms(h);
717 }
718 [[nodiscard]] InstanceTransforms getInstanceTransforms(const QSSGRenderNode &node) const
719 {
720 return nodeData->getInstanceTransforms(node.h);
721 }
722 [[nodiscard]] float getGlobalOpacity(QSSGRenderNodeHandle h, float defaultValue = 1.0f) const
723 {
724 return nodeData->getGlobalOpacity(h, defaultValue);
725 }
726 [[nodiscard]] float getGlobalOpacity(const QSSGRenderNode &node) const
727 {
728 return nodeData->getGlobalOpacity(node.h);
729 }
730
731 //
732 [[nodiscard]] QSSGRenderItem2DData::Item2DRenderer getItem2DRenderer(const QSSGRenderItem2D &item) const
733 {
734 return item2DData->getItem2DRenderer(item);
735 }
736
737 [[nodiscard]] ModelViewProjections getItem2DMvps(QSSGRenderNodeHandle h) const
738 {
739 return item2DData->getModelViewProjection(h);
740 }
741
742 [[nodiscard]] ModelViewProjections getItem2DMvps(const QSSGRenderItem2D &item) const
743 {
744 return item2DData->getModelViewProjection(item);
745 }
746
747
748 //
749 void prepareRenderables(QSSGRenderContextInterface &ctx,
750 QSSGPrepResultId prepId,
751 QRhiRenderPassDescriptor *renderPassDescriptor,
752 const QSSGRhiGraphicsPipelineState &ps,
753 QSSGRenderablesFilters filter);
754 void renderRenderables(QSSGRenderContextInterface &ctx,
755 QSSGPrepResultId prepId);
756
757 static bool calculateGlobalVariables(QSSGRenderNode &node,
758 std::vector<QMatrix4x4> &globalTransforms,
759 std::vector<float> &globalOpacities);
760
761 QSSGRenderCameraData getCameraDataImpl(const QSSGRenderCamera *camera) const;
762
763 static QSSGNodeIdList filter(const QSSGGlobalRenderNodeData::LayerNodeView &layerNodes,
764 quint32 layerMask,
765 quint32 typeMask);
766
767 [[nodiscard]] static QSSGLayerRenderData *getCurrent(const QSSGFrameData &data) { return data.getCurrent(); }
768
769 QSSGDefaultMaterialPreparationResult prepareDefaultMaterialForRender(QSSGRenderDefaultMaterial &inMaterial,
770 QSSGRenderableObjectFlags &inExistingFlags,
771 float inOpacity,
772 bool hasAnyLights,
773 bool anyLightHasShadows,
774 QSSGLayerRenderPreparationResultFlags &ioFlags);
775
776 QSSGDefaultMaterialPreparationResult prepareCustomMaterialForRender(QSSGRenderCustomMaterial &inMaterial,
777 QSSGRenderableObjectFlags &inExistingFlags,
778 float inOpacity, bool alreadyDirty,
779 bool hasAnyLights,
780 bool anyLightHasShadows,
781 QSSGLayerRenderPreparationResultFlags &ioFlags);
782
783 static void categorizeAndFilterNodes(const QSSGGlobalRenderNodeData::LayerNodeView &layerNodes,
784 QSSGLayerRenderData::NodeCollection &nodeCollection,
785 quint32 layerMask);
786 void updateFilteredLayerNodes(quint32 layerMask);
787private:
788 friend class QSSGRenderer;
789 friend class QSSGRendererPrivate;
790 friend class QSSGFrameData;
791 friend class QSSGModelHelpers;
792 friend class QSSGRenderHelpers;
793 friend class QSSGParticleRenderer;
794
795 OneShotWarnings shownWarnings;
796
797 class ExtensionContext
798 {
799 public:
800 explicit ExtensionContext() = default;
801 explicit ExtensionContext(const QSSGRenderExtension &ownerExt, QSSGRenderCamera *cam, size_t idx, quint32 slot)
802 : owner(&ownerExt), camera(cam), ps{}, filter{0}, index(idx), slot(slot)
803 { }
804 const QSSGRenderExtension *owner = nullptr;
805 QSSGRenderCamera *camera = nullptr;
806 QSSGRhiGraphicsPipelineState ps[3] {};
807 QSSGRenderablesFilters filter { 0 };
808 size_t index = 0; // index into the model store
809 quint32 slot = 0;
810 };
811
812 std::vector<ExtensionContext> extContexts { ExtensionContext{ /* 0 - Always available */ } };
813 std::vector<RenderableNodeEntries> renderableModelStore { RenderableNodeEntries{ /* 0 - Always available */ } };
814 std::vector<TModelContextPtrList> modelContextStore { TModelContextPtrList{ /* 0 - Always available */ }};
815 std::vector<QSSGRenderableObjectList> renderableObjectStore { QSSGRenderableObjectList{ /* 0 - Always available */ }};
816 std::vector<QSSGRenderableObjectList> opaqueObjectStore { QSSGRenderableObjectList{ /* 0 - Always available */ }};
817 std::vector<QSSGRenderableObjectList> transparentObjectStore { QSSGRenderableObjectList{ /* 0 - Always available */ }};
818 std::vector<QSSGRenderableObjectList> screenTextureObjectStore { QSSGRenderableObjectList{ /* 0 - Always available */ }};
819
820 std::shared_ptr<QSSGGlobalRenderNodeData> nodeData;
821 std::unique_ptr<QSSGRenderModelData> modelData;
822 std::unique_ptr<QSSGRenderItem2DData> item2DData;
823
824 // Soreted cache (per camera and extension)
825 using CameraKey = std::pair<const QSSGRenderCamera*, uint32_t>;
826
827 struct CameraKeyHash {
828 std::size_t operator()(const CameraKey& k) const noexcept {
829 // Hash combine: pointer hash ^ (uint hash shifted)
830 return std::hash<const QSSGRenderCamera*>()(k.first) ^
831 (std::hash<uint32_t>()(k.second) << 1);
832 }
833 };
834
835 struct CameraKeyEq {
836 bool operator()(const CameraKey& a, const CameraKey& b) const noexcept {
837 return a.first == b.first && a.second == b.second;
838 }
839 };
840
841 using PerCameraCache = std::unordered_map<CameraKey, QSSGRenderableObjectList, CameraKeyHash, CameraKeyEq>;
842 std::vector<PerCameraCache> sortedOpaqueObjectCache { PerCameraCache{ /* 0 - Always available */ } };
843 std::vector<PerCameraCache> sortedTransparentObjectCache { PerCameraCache{ /* 0 - Always available */ } };
844 std::vector<PerCameraCache> sortedScreenTextureObjectCache { PerCameraCache{ /* 0 - Always available */ } };
845 std::vector<PerCameraCache> sortedOpaqueDepthPrepassCache { PerCameraCache{ /* 0 - Always available */ } };
846 std::vector<PerCameraCache> sortedDepthWriteCache { PerCameraCache{ /* 0 - Always available */ } };
847
848 [[nodiscard]] const QSSGRenderCameraDataList &getCachedCameraDatas();
849 void ensureCachedCameraDatas();
850 void updateSortedDepthObjectsListImp(const QSSGRenderCamera &camera, size_t index);
851
852 static void prepareModelMaterials(RenderableNodeEntries &renderableModels, bool cullUnrenderables);
853 static void prepareModelMaterials(const RenderableNodeEntries::ConstIterator &begin,
854 const RenderableNodeEntries::ConstIterator &end);
855
856 // Persistent data
857 QHash<QSSGShaderMapKey, QSSGRhiShaderPipelinePtr> shaderMap;
858 QHash<QSSGParticleShaderMapKey, QSSGRhiShaderPipelinePtr> particleShaderMap;
859
860 // Cached buffer.
861 QByteArray generatedShaderString;
862
863 // Saved render state (for sublayers)
864 struct SavedRenderState
865 {
866 QRect viewport;
867 QRect scissorRect;
868 float dpr = 1.0;
869 // The main pass state on the shared rhi context. A sublayer can contain a
870 // nested 3D scene, e.g. a View3D inside an Item2D, which renders to its own
871 // target and leaves its own state behind on the context. The passes of this
872 // layer that come after would otherwise build their graphics pipelines for
873 // that target's render pass and sample count instead of their own.
874 QRhiRenderPassDescriptor *mainRenderPassDescriptor = nullptr;
875 QRhiRenderTarget *renderTarget = nullptr;
876 QRhiCommandBuffer *commandBuffer = nullptr;
877 int mainPassSampleCount = 1;
878 int mainPassViewCount = 1;
879 };
880
881 std::optional<SavedRenderState> savedRenderState;
882
883 // Note: Re-used to avoid expensive initialization.
884 // - Should be revisit, as we can do better.
885 QSSGShaderDefaultMaterialKeyProperties defaultMaterialShaderKeyProperties;
886 QSSGShaderParticleMaterialKeyProperties particleMaterialShaderKeyProperties;
887 QSSGFrameData frameData;
888 QSSGRhiGraphicsPipelineState ps; // Base pipleline state
889 QSSGShaderFeatures features; // Base feature set
890 QSSGRenderNodeVersionType version = 0;
891 QSSGRenderNodeVersionType stateGeneration = 0; // Last seen QSSGGlobalRenderNodeData::stateGeneration()
892 bool particlesEnabled = true;
893 bool hasDepthWriteObjects = false;
894 bool zPrePassActive = false;
895 // NOTE: For the time being we need to keep track of extensions modifying the renderables
896 // because then we need to reset the lists.
897 // FIXME: This should be revisited, as we can do better (hence the verbose name).
898 bool renderablesModifiedByExtension = false;
899 enum class DepthPrepassObject : quint8
900 {
901 None = 0x0,
902 ScreenTexture = 0x1,
903 Transparent = 0x2,
904 Opaque = 0x4
905 };
906 using DepthPrepassObjectStateT = std::underlying_type_t<DepthPrepassObject>;
907 DepthPrepassObjectStateT depthPrepassObjectsState { DepthPrepassObjectStateT(DepthPrepassObject::None) };
908 QSSGRenderShadowMapPtr shadowMapManager;
909 QSSGRenderReflectionMapPtr reflectionMapManager;
910 QSSGRenderSkyMaterialManagerPtr skyMaterialManager;
911 QSSGUserRenderPassManagerPtr userRenderPassManager;
912 QSSGRenderMotionVectorMapPtr motionVectorMapManager;
913 QHash<const QSSGModelContext *, QRhiTexture *> lightmapTextures;
914 QHash<const QSSGModelContext *, QRhiTexture *> bonemapTextures;
915 QSSGRhiRenderableTexture renderResults[size_t(QSSGRenderResult::Key::RenderResultCount)] {};
916 QSSGOITRenderContext oitRenderContext;
917 QSSGComputeLightContext computeLightContext;
918};
919
920QT_END_NAMESPACE
921
922#endif // QSSG_LAYER_RENDER_DATA_H
QRect viewport() const
Returns the viewport rectangle.
void drawLine(const QVector3D &startPoint, const QVector3D &endPoint, const QColor &color, bool isPersistent=false)
void recordRenderDebugObjects(QSSGRhiContext *rhiCtx, QSSGRhiGraphicsPipelineState *ps, QRhiShaderResourceBindings *srb, QRhiRenderPassDescriptor *rpDesc)
void drawPoint(const QVector3D &vertex, const QColor &color, bool isPersistent=false)
void prepareGeometry(QSSGRhiContext *rhiCtx, QRhiResourceUpdateBatch *rub)
static QColor levelOfDetailColor(quint32 lod)
void drawBounds(const QSSGBounds3 &bounds, const QColor &color, bool isPersistent=false)
QSSGLayerRenderPreparationResult(const QRectF &inViewport, QSSGRenderLayer &inLayer)
const QSSGLayerRenderPreparationResultFlags & getFlags() const
QSSGRenderableObjectFlags renderableFlags
friend class QSSGParticleRenderer
void releaseItem2DData(const QSSGRenderItem2D &item2D)
const std::unique_ptr< QSSGRhiQuadRenderer > & rhiQuadRenderer() const
quint32 frameDepth() const
float dpr() 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 setDpr(float dpr)
void setScissorRect(QRect inScissorRect)
void endSubLayerRender(QSSGLayerRenderData &inLayer)
QSSGRenderContextInterface * contextInterface() const
QSSGRenderResult::Key toInternalRenderResultKey(QSSGFrameData::RenderResult id)
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)
bool setupDrawInputs(QSSGRhiContext *rhiCtx, QRhiGraphicsPipeline *ps, const QSSGSubsetRenderable &renderable, QRhiBuffer *instanceIndexBuffer, QRhiCommandBuffer::VertexInput *vertexBuffers, int &vertexBufferCount, quint32 &instances)
void rhiRenderUserAugmentedPass(QSSGRhiContext *rhiCtx, QSSGRenderableObjectList &inObjects)
quint32 rhiCalculateABufferSize(int nodeCount)
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 anyAutoLodInstances(const QSSGSubsetRenderable &renderable)
bool bindInstanceIndices(QRhiGraphicsPipeline *ps, QRhiBuffer *instanceIndexBuffer, QRhiCommandBuffer::VertexInput *vertexBuffers, int *vertexBufferCount)
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)
void rhiRenderReflectionMap(const QSSGRenderContextInterface &context, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRhiGraphicsPipelineState *ps, QSSGRenderReflectionMap &reflectionMapManager, const std::vector< QSSGRenderReflectionProbe * > &reflectionProbes, const QSSGRenderableObjectList &reflectionPassObjects, QSSGRenderer &renderer)
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 rhiDrawNonIndexed(QSSGRhiContext *rhiCtx, QRhiCommandBuffer *cb, const QSSGSubsetRenderable &renderable, quint32 instances)
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 rhiDrawAutoLodInstanced(QSSGRhiContext *rhiCtx, QRhiCommandBuffer *cb, QRhiCommandBuffer::VertexInput *vertexBuffers, int vertexBufferCount, QRhiBuffer *indexBuffer, const QSSGSubsetRenderable &renderable)
Q_AUTOTEST_EXPORT 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)
void addDebugFrustum(const QSSGBoxPoints &frustumPoints, const QColor &color, QSSGDebugDrawSystem *debugDrawSystem)
void addDebugBox(const QSSGBoxPoints &boxUnsorted, const QColor &color, QSSGDebugDrawSystem *debugDrawSystem)
void addDirectionalLightDebugBox(const QSSGBoxPoints &box, QSSGDebugDrawSystem *debugDrawSystem)
#define M_PI_2
Definition qmath.h:205
#define M_PI
Definition qmath.h:201
QSSGLayerRenderPreparationResultFlag
QVarLengthArray< QSSGShaderLight, 16 > QSSGShaderLightList
static void setupCubeShadowCameras(const QSSGLayerRenderData &inData, const QSSGRenderLight *inLight, float shadowMapFar, QSSGRenderCamera inCameras[6])
static void updateUniformsForDefaultMaterial(QSSGRhiShaderPipeline &shaderPipeline, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, char *ubufData, QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGRenderCameraList &cameras, const QVector2D *depthAdjust, const QMatrix4x4 *alteredModelViewProjection, const QSSGRenderGraphObject *materialOverride=nullptr)
static QSSGRhiShaderPipelinePtr shadersForParticleMaterial(QSSGRhiGraphicsPipelineState *ps, QSSGParticlesRenderable &particleRenderable, const QSSGShaderFeatures &featureSet)
static QSSGRhiShaderPipelinePtr shadersForDefaultMaterial(QSSGRhiGraphicsPipelineState *ps, QSSGSubsetRenderable &subsetRenderable, const QSSGShaderFeatures &featureSet, const QSSGUserShaderAugmentation &shaderAugmentation={})
static std::unique_ptr< QSSGRenderCamera > computeShadowCameraFromFrustum(const QMatrix4x4 &lightMatrix, const QMatrix4x4 &lightMatrixInverted, const QVector3D &lightPivot, const QVector3D &lightForward, const QVector3D &lightUp, const float shadowMapResolution, const float pcfRadius, const QSSGBoxPoints &frustumPoints, float frustumStartT, float frustumEndT, float frustumRadius, bool lockShadowmapTexels, const QSSGBounds3 &castingBox, const QSSGBounds3 &receivingBox, QSSGDebugDrawSystem *debugDrawSystem, const bool drawCascades, const bool drawSceneCascadeIntersection)
static QRhiViewport calculateAtlasViewport(QSize atlasPixelSize, const QSSGShadowMapEntry::AtlasEntry &atlasEntry, bool yIsUp)
static QSSGBoxPoints sliceFrustum(const QSSGBoxPoints &frustumPoints, float t0, float t1)
static void rhiPrepareSkyBox_helper(const QSSGRenderContextInterface &context, QSSGPassKey passKey, QSSGRenderLayer &layer, QSSGRenderCameraList &cameras, QSSGRenderer &renderer, QSSGReflectionMapEntry *entry=nullptr, QSSGRenderTextureCubeFace cubeFace=QSSGRenderTextureCubeFaceNone, uint tonemapMode=0)
static QT_BEGIN_NAMESPACE constexpr float QSSG_PI
static void rhiPrepareResourcesForReflectionMap(const QSSGRenderContextInterface &context, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGReflectionMapEntry *pEntry, QSSGRhiGraphicsPipelineState *ps, const QSSGRenderableObjectList &sortedOpaqueObjects, QSSGRenderCamera &inCamera, QSSGRenderer &renderer, QSSGRenderTextureCubeFace cubeFace)
static void rhiPrepareResourcesForShadowMap(QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, QSSGPassKey passKey, QSSGShadowMapEntry *pEntry, QSSGRhiGraphicsPipelineState *ps, const QVector2D *depthAdjust, const QSSGRenderableObjectList &sortedOpaqueObjects, QSSGRenderCamera &inCamera, bool orthographic, QSSGRenderTextureCubeFace cubeFace, quint32 cascadeIndex)
static void addOpaqueDepthPrePassBindings(QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRenderableImage *renderableImage, QSSGRhiShaderResourceBindingList &bindings, bool isCustomMaterialMeshSubset=false)
static QSSGBoxPoints computeFrustumBounds(const QMatrix4x4 &projection)
static void addNormalTextureBindings(QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings)
static const QRhiShaderResourceBinding::StageFlags RENDERER_VISIBILITY_ALL
static QRhiShaderResourceBindings * drawCallDataSrb(QSSGRhiContextPrivate *rhiCtxD, QSSGRhiDrawCallData &dcd, const QSSGRhiShaderResourceBindingList &bindings)
static constexpr float QSSG_HALFPI
static int setupInstancing(QSSGSubsetRenderable *renderable, QSSGRhiGraphicsPipelineState *ps, QSSGRhiContext *rhiCtx, const QSSGLayerRenderData &inData, const QVector3D &cameraDirection, const QVector3D &cameraPosition, InstanceLevels instanceLevels, const QSSGRhiShaderPipeline &shaders)
void rhiPrepareRenderableImp(QSSGRhiContext *rhiCtx, QSSGPassKey passKey, const QSSGLayerRenderData &inData, QSSGRenderableObject &inObject, QRhiRenderPassDescriptor *renderPassDescriptor, QSSGRhiGraphicsPipelineState *ps, QSSGShaderFeatures featureSet, int samples, int viewCount, bool screenMapPass, QSSGRenderCamera *alteredCamera, QMatrix4x4 *alteredModelViewProjection, QSSGRenderTextureCubeFace cubeFace, QSSGReflectionMapEntry *entry, bool oit)
static void setupCubeReflectionCameras(const QSSGLayerRenderData &inData, const QSSGRenderReflectionProbe *inProbe, QSSGRenderCamera inCameras[6])
static void fillTargetBlend(QRhiGraphicsPipeline::TargetBlend *targetBlend, QSSGRenderDefaultMaterial::MaterialBlendMode materialBlend)
static void addDepthTextureBindings(QSSGRhiContext *rhiCtx, QSSGRhiShaderPipeline *shaderPipeline, QSSGRhiShaderResourceBindingList &bindings, QBitArray *specifiedBindings=nullptr)
static QVarLengthArray< std::unique_ptr< QSSGRenderCamera >, 4 > setupCascadingCamerasForShadowMap(const QSSGLayerRenderData &data, const QSSGRenderCamera &inCamera, const QSSGRenderLight *inLight, const int shadowMapResolution, const float pcfRadius, const float clipNear, const float clipFar, const QSSGBounds3 &castingObjectsBox, const QSSGBounds3 &receivingObjectsBox, bool lockShadowmapTexels, QSSGDebugDrawSystem *debugDrawSystem, bool drawCascades, bool drawSceneCascadeIntersection)
QVector< QSSGRenderableObjectHandle > renderables
QSSGBakedLightingModel(const QSSGRenderModel *model, const QVector< QSSGRenderableObjectHandle > &renderables)
const QSSGRenderModel * model
QSSGRenderLight::SoftShadowQuality maxSoftShadowQuality
QSSGDefaultMaterialPreparationResult(QSSGShaderDefaultMaterialKey inMaterialKey)
QSSGShaderDefaultMaterialKey materialKey
QRhiReadbackResult * pendingResult
QList< QRhiReadbackResult * > completedResults
QRhiTextureRenderTarget * oitRenderTarget
QRhiResourceUpdateBatch * rub
QRhiRenderPassDescriptor * renderPassDescriptor