4#ifndef QSSGSCENERENDERER_H
5#define QSSGSCENERENDERER_H
18#include <ssg/qssgrendercontextcore.h>
20#include <qsgtextureprovider.h>
21#include <qsgrendernode.h>
22#include <QSGSimpleTextureNode>
24#include <QtQuick3D/private/qquick3dviewport_p.h>
25#include <QtQuick3DRuntimeRender/private/qssgrenderlayer_p.h>
26#include <QtQuick3DRuntimeRender/private/qssgrhieffectsystem_p.h>
27#include <QtQuick3DRuntimeRender/private/qssgrenderer_p.h>
29#include <QtCore/qpointer.h>
38class QQuick3DSceneManager;
39class QQuick3DViewport;
50 if (environment.useBuiltinTonemapper())
51 return QSSGRenderLayer::TonemapMode(environment.tonemapMode());
54 return (environment.tonemapMode() != QQuick3DSceneEnvironment::QQuick3DEnvironmentTonemapModes::TonemapModeNone) ? QSSGRenderLayer::TonemapMode::Custom
55 : QSSGRenderLayer::TonemapMode::None;
62 void rhiPrepare(
const QRect &viewport, qreal displayPixelRatio);
64 void synchronize(QQuick3DViewport *view3D,
const QSize &size,
float dpr);
81 void releaseAaDependentRhiResources();
82 void updateLayerNode(QSSGRenderLayer &layerNode,
83 const QQuick3DViewport &view3D,
84 const QList<QSSGRenderGraphObject *> &resourceLoaders);
85 void addNodeToLayer(QSSGRenderNode *node);
86 void removeNodeFromLayer(QSSGRenderNode *node);
87 void maybeSetupLightmapBaking(QQuick3DViewport *view3D);
88 std::shared_ptr<QSSGRenderContextInterface> m_sgContext;
89 QSSGRenderLayer *m_layer =
nullptr;
90 QPointer<QQuick3DWindowAttachment> winAttacment;
92 SGFramebufferObjectNode *fboNode =
nullptr;
93 bool m_aaIsDirty =
true;
94 bool m_temporalIsDirty =
false;
95 bool m_timeBasedAA =
false;
98 QRhiTexture *m_texture =
nullptr;
100 QRhiTextureRenderTarget *m_textureRenderTarget =
nullptr;
101 QRhiRenderPassDescriptor *m_textureRenderPassDescriptor =
nullptr;
103 QRhiTextureRenderTarget *m_ssaaTextureToTextureRenderTarget =
nullptr;
104 QRhiRenderPassDescriptor *m_ssaaTextureToTextureRenderPassDescriptor =
nullptr;
105 QRhiRenderBuffer *m_msaaRenderBufferLegacy =
nullptr;
106 QRhiTexture *m_msaaRenderTexture =
nullptr;
107 QRhiTexture *m_msaaMultiViewRenderBuffer =
nullptr;
108 QRhiTexture *m_ssaaTexture =
nullptr;
109 QRhiTexture *m_temporalAATexture =
nullptr;
110 QRhiTexture *m_prevTempAATexture =
nullptr;
111 QRhiTextureRenderTarget *m_temporalAARenderTarget =
nullptr;
112 QRhiRenderPassDescriptor *m_temporalAARenderPassDescriptor =
nullptr;
113 QRhiRenderBuffer *m_depthStencilBuffer =
nullptr;
114 QRhiTexture *m_multiViewDepthStencilBuffer =
nullptr;
115 bool m_textureNeedsFlip =
true;
117 QColor m_userBackgroundColor =
Qt::
black;
118 QColor m_linearBackgroundColor =
Qt::
black;
119 QColor m_tonemappedBackgroundColor =
Qt::
black;
121 QSSGRhiEffectSystem *m_effectSystem =
nullptr;
123 QPointer<QQuick3DRenderStats> m_renderStats;
125 QSSGRenderNode *m_sceneRootNode =
nullptr;
126 QSSGRenderNode *m_importSceneRootNode =
nullptr;
128 bool m_prepared =
false;
130 QSSGLightmapperOptions lmOptions;
131 bool m_lightmapBakingFromCmdRequested =
false;
132 bool m_lightmapDenoisingFromCmdRequested =
false;
134 int m_requestedFramesCount = 0;
135 bool m_postProcessingStack =
false;
136 bool m_useFBO =
false;
140 friend class QQuick3DSGRenderNode;
142 friend class QQuick3DViewport;
144 friend class QQuick3DRenderLayerHelpers;
150 static void updateLayerNodeHelper(
const QQuick3DViewport &view3D,
151 const std::shared_ptr<QSSGRenderContextInterface> &rci,
152 QSSGRenderLayer &layerNode,
154 bool &temporalIsDirty);
187class QQuick3DSGRenderNode
final :
public QSGRenderNode
193 void render(
const RenderState *state)
override;
226 QQuickWindow *m_window =
nullptr;
228 bool m_isVisible =
true;
229 QRhiTexture *m_rhiTexture =
nullptr;
230 bool renderPending =
false;
~QQuick3DSGDirectRenderer()
QQuick3DSceneRenderer * renderer()
void setViewport(const QRectF &viewport)
void setVisibility(bool visible)
QQuick3DSGDirectRenderer(QQuick3DSceneRenderer *renderer, QQuickWindow *window, QQuick3DSGDirectRendererMode mode=Underlay)
void render(const RenderState *state) override
This function is called by the renderer and should paint this node with directly invoking commands vi...
void releaseResources() override
This function is called when all custom graphics resources allocated by this node have to be freed im...
RenderingFlags flags() const override
void prepare() override
Called from the frame preparation phase.
QQuick3DSceneRenderer * renderer
StateFlags changedStates() const override
This function should return a mask where each bit represents graphics states changed by the \l render...
QRhiTexture * renderToRhiTexture(QQuickWindow *qw)
PickResultList syncPick(const QSSGRenderRay &ray)
QQuick3DSceneRenderer(const std::shared_ptr< QSSGRenderContextInterface > &rci)
void invalidateFramebufferObject()
void rhiPrepare(const QRect &viewport, qreal displayPixelRatio)
PickResultList syncPickSubset(const QSSGRenderRay &ray, QVarLengthArray< QSSGRenderNode * > subset)
void synchronize(QQuick3DViewport *view3D, const QSize &size, float dpr)
std::optional< QSSGRenderRay > getRayFromViewportPos(const QPointF &pos)
QSize surfaceSize() const
PickResultList syncPickAll(const QSSGRenderRay &ray)
static QSSGRenderLayer::TonemapMode getTonemapMode(const QQuick3DSceneEnvironment &environment)
void setGlobalPickingEnabled(bool isEnabled)
QQuick3DRenderStats * renderStats()
std::optional< QSSGRenderPickResult > syncPickClosestPoint(const QVector3D ¢er, float radiusSquared, QSSGRenderNode *node)
void releaseCachedResources()
PickResultList syncPickOne(const QSSGRenderRay &ray, QSSGRenderNode *node)
friend class QSSGLayerRenderData
SGFramebufferObjectNode()
~SGFramebufferObjectNode() override
QQuick3DSceneRenderer * renderer
void handleScreenChange()
QSGTexture * texture() const override
Returns a pointer to the texture object.
void preprocess() override
Override this function to do processing on the node before it is rendered.
QQuick3DViewport * quickFbo
Combined button and popup list for selecting options.
Q_TRACE_POINT(qtcore, QCoreApplication_postEvent_exit)
Q_TRACE_POINT(qtcore, QFactoryLoader_update, const QString &fileName)
Q_TRACE_POINT(qtquick3d, QSSG_renderFrame_entry, int width, int height)
static void bfs(In *inExtension, QList< Out * > &outList)
static const QVector2D s_ProgressiveAABlendFactors[QSSGLayerRenderData::MAX_AA_LEVELS]
static QVector3D tonemapRgb(const QVector3D &c, QQuick3DSceneEnvironment::QQuick3DEnvironmentTonemapModes tonemapMode)
static bool dumpRenderTimes()
Q_TRACE_POINT(qtquick3d, QSSG_synchronize_entry, QQuick3DViewport *view3D, const QSize &size, float dpr)
static const QVector2D s_TemporalAABlendFactors
static void requestFullUpdate(QQuickWindow *window)