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
qquick3dcomputepass_p.h
Go to the documentation of this file.
1// Copyright (C) 2026 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 QQUICK3DCOMPUTEPASS_P_H
7#define QQUICK3DCOMPUTEPASS_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 <QtQuick3D/qtquick3dglobal.h>
21#include <QtQuick3D/private/qquick3dobject_p.h>
22#include <QtQuick3D/private/qquick3dshaderutils_p.h>
23
25
26class Q_QUICK3D_EXPORT QQuick3DComputePass : public QQuick3DObject, public QQuick3DPropertyChangedTracker
27{
28 Q_OBJECT
29 Q_PROPERTY(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> commands READ commands FINAL)
30 Q_PROPERTY(QUrl computeShader READ computeShader WRITE setComputeShader NOTIFY computeShaderChanged FINAL)
31 Q_PROPERTY(ExecutionMode executionMode READ executionMode WRITE setExecutionMode NOTIFY executionModeChanged FINAL)
32 Q_PROPERTY(ExecutionStage executionStage READ executionStage WRITE setExecutionStage NOTIFY executionStageChanged FINAL)
33 QML_NAMED_ELEMENT(ComputePass)
34 QML_ADDED_IN_VERSION(6, 13)
35public:
36 enum ExecutionMode {
37 EveryFrame,
38 OnRequest
39 };
40 Q_ENUM(ExecutionMode)
41
42 enum ExecutionStage {
43 StartOfFrame,
44 PreColor
45 };
46 Q_ENUM(ExecutionStage)
47
48 explicit QQuick3DComputePass(QQuick3DObject *parent = nullptr);
49
50 QQmlListProperty<QQuick3DShaderUtilsRenderCommand> commands();
51
52 QUrl computeShader() const;
53 ExecutionMode executionMode() const;
54 ExecutionStage executionStage() const;
55
56 Q_INVOKABLE void requestExecution();
57
58public Q_SLOTS:
59 void setComputeShader(const QUrl &computeShader);
60 void setExecutionMode(ExecutionMode executionMode);
61 void setExecutionStage(ExecutionStage executionStage);
62
63Q_SIGNALS:
64 void computeShaderChanged();
65 void executionModeChanged();
66 void executionStageChanged();
67
68private Q_SLOTS:
69 void onShaderResourceDirty();
70
71protected:
72 void markAllDirty() override { m_dirtyAttributes = AllDirty; }
73 QSSGRenderGraphObject *updateSpatialNode(QSSGRenderGraphObject *node) override;
74 void itemChange(QQuick3DObject::ItemChange, const QQuick3DObject::ItemChangeData &) override;
75 void markTrackedPropertyDirty(QMetaProperty property, QQuick3DPropertyChangedTracker::DirtyPropertyHint hint) override;
76
77private:
78 static void qmlAppendCommand(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list, QQuick3DShaderUtilsRenderCommand *command);
79 static QQuick3DShaderUtilsRenderCommand *qmlCommandAt(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list, qsizetype index);
80 static qsizetype qmlCommandCount(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list);
81 static void qmlCommandClear(QQmlListProperty<QQuick3DShaderUtilsRenderCommand> *list);
82
83 void onCommandChanged();
84 void markResourcesDirty();
85
86 enum Dirty {
87 ResourceDirty = 0x1,
88 PropertyDirty = 0x2,
89 CommandsDirty = 0x4,
90 ComputeShaderDirty = 0x8,
91 StateDirty = 0x10,
92 };
93
94 using DirtyT = std::underlying_type_t<Dirty>;
95 static constexpr DirtyT AllDirty { std::numeric_limits<DirtyT>::max() };
96
97 void markDirty(QQuick3DComputePass::DirtyT type, bool requestSecondaryUpdate = false);
98 void clearDirty(QQuick3DComputePass::DirtyT type);
99
100 quint32 m_dirtyAttributes = AllDirty;
101 QVector<QQuick3DShaderUtilsRenderCommand *> m_commands;
102 QUrl m_computeShader;
103 ExecutionMode m_executionMode = EveryFrame;
104 ExecutionStage m_executionStage = PreColor;
105 quint64 m_executionSerial = 1;
106 QQuick3DShaderResourceTracker m_shaderResources { this, [this]() { markResourcesDirty(); } };
107};
108
109QT_END_NAMESPACE
110
111#endif // QQUICK3DCOMPUTEPASS_P_H
void setViewport(const QRectF &viewport)
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...
PickResultList syncPick(const QSSGRenderRay &ray)
QQuick3DSceneRenderer(const std::shared_ptr< QSSGRenderContextInterface > &rci)
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)
PickResultList syncPickAll(const QSSGRenderRay &ray)
void setGlobalPickingEnabled(bool isEnabled)
QQuick3DRenderStats * renderStats()
QList< const QSSGRenderNode * > syncPickInFrustum(const QSSGFrustum &frustum)
QQuick3DSceneRenderer * renderer
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.
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 QSSGRenderUserPassBase::ExecutionStage declaredExecutionStage(const QQuick3DObject *pass)
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)