7#include <PhosphorRendering/phosphorrendering_export.h>
85 Q_PROPERTY(qreal iTime READ iTime WRITE setITime NOTIFY iTimeChanged FINAL)
86 Q_PROPERTY(qreal iTimeDelta READ iTimeDelta WRITE setITimeDelta NOTIFY iTimeDeltaChanged FINAL)
87 Q_PROPERTY(
int iFrame READ iFrame WRITE setIFrame NOTIFY iFrameChanged FINAL)
88 Q_PROPERTY(QSizeF iResolution READ iResolution WRITE setIResolution NOTIFY iResolutionChanged FINAL)
89 Q_PROPERTY(QPointF iMouse READ iMouse WRITE setIMouse NOTIFY iMouseChanged FINAL)
90 Q_PROPERTY(
bool isReversed READ isReversed WRITE setIsReversed NOTIFY isReversedChanged FINAL)
108 Q_PROPERTY(
bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged FINAL)
111 Q_PROPERTY(QUrl shaderSource READ shaderSource WRITE setShaderSource NOTIFY shaderSourceChanged FINAL)
112 Q_PROPERTY(QUrl vertexShaderUrl READ vertexShaderUrl WRITE setVertexShaderUrl NOTIFY vertexShaderUrlChanged FINAL)
113 Q_PROPERTY(QVariantMap shaderParams READ shaderParams WRITE setShaderParams NOTIFY shaderParamsChanged)
114 Q_PROPERTY(QString paramPreamble READ paramPreamble WRITE setParamPreamble NOTIFY paramPreambleChanged)
115 Q_PROPERTY(QQuickItem* sourceItem READ sourceItem WRITE setSourceItem NOTIFY sourceItemChanged FINAL)
119 QString bufferShaderPath READ bufferShaderPath WRITE setBufferShaderPath NOTIFY bufferShaderPathChanged FINAL)
120 Q_PROPERTY(QStringList bufferShaderPaths READ bufferShaderPaths WRITE setBufferShaderPaths NOTIFY
121 bufferShaderPathsChanged FINAL)
122 Q_PROPERTY(
bool bufferFeedback READ bufferFeedback WRITE setBufferFeedback NOTIFY bufferFeedbackChanged FINAL)
123 Q_PROPERTY(qreal bufferScale READ bufferScale WRITE setBufferScale NOTIFY bufferScaleChanged FINAL)
125 bool halfFloatBuffers READ halfFloatBuffers WRITE setHalfFloatBuffers NOTIFY halfFloatBuffersChanged FINAL)
126 Q_PROPERTY(QString bufferWrap READ bufferWrap WRITE setBufferWrap NOTIFY bufferWrapChanged FINAL)
127 Q_PROPERTY(QStringList bufferWraps READ bufferWraps WRITE setBufferWraps NOTIFY bufferWrapsChanged FINAL)
128 Q_PROPERTY(QString bufferFilter READ bufferFilter WRITE setBufferFilter NOTIFY bufferFilterChanged FINAL)
129 Q_PROPERTY(QStringList bufferFilters READ bufferFilters WRITE setBufferFilters NOTIFY bufferFiltersChanged FINAL)
132 Q_PROPERTY(QVector4D customParams1 READ customParams1 WRITE setCustomParams1 NOTIFY customParamsChanged FINAL)
133 Q_PROPERTY(QVector4D customParams2 READ customParams2 WRITE setCustomParams2 NOTIFY customParamsChanged FINAL)
134 Q_PROPERTY(QVector4D customParams3 READ customParams3 WRITE setCustomParams3 NOTIFY customParamsChanged FINAL)
135 Q_PROPERTY(QVector4D customParams4 READ customParams4 WRITE setCustomParams4 NOTIFY customParamsChanged FINAL)
136 Q_PROPERTY(QVector4D customParams5 READ customParams5 WRITE setCustomParams5 NOTIFY customParamsChanged FINAL)
137 Q_PROPERTY(QVector4D customParams6 READ customParams6 WRITE setCustomParams6 NOTIFY customParamsChanged FINAL)
138 Q_PROPERTY(QVector4D customParams7 READ customParams7 WRITE setCustomParams7 NOTIFY customParamsChanged FINAL)
139 Q_PROPERTY(QVector4D customParams8 READ customParams8 WRITE setCustomParams8 NOTIFY customParamsChanged FINAL)
142 Q_PROPERTY(QColor customColor1 READ customColor1 WRITE setCustomColor1 NOTIFY customColorsChanged FINAL)
143 Q_PROPERTY(QColor customColor2 READ customColor2 WRITE setCustomColor2 NOTIFY customColorsChanged FINAL)
144 Q_PROPERTY(QColor customColor3 READ customColor3 WRITE setCustomColor3 NOTIFY customColorsChanged FINAL)
145 Q_PROPERTY(QColor customColor4 READ customColor4 WRITE setCustomColor4 NOTIFY customColorsChanged FINAL)
146 Q_PROPERTY(QColor customColor5 READ customColor5 WRITE setCustomColor5 NOTIFY customColorsChanged FINAL)
147 Q_PROPERTY(QColor customColor6 READ customColor6 WRITE setCustomColor6 NOTIFY customColorsChanged FINAL)
148 Q_PROPERTY(QColor customColor7 READ customColor7 WRITE setCustomColor7 NOTIFY customColorsChanged FINAL)
149 Q_PROPERTY(QColor customColor8 READ customColor8 WRITE setCustomColor8 NOTIFY customColorsChanged FINAL)
150 Q_PROPERTY(QColor customColor9 READ customColor9 WRITE setCustomColor9 NOTIFY customColorsChanged FINAL)
151 Q_PROPERTY(QColor customColor10 READ customColor10 WRITE setCustomColor10 NOTIFY customColorsChanged FINAL)
152 Q_PROPERTY(QColor customColor11 READ customColor11 WRITE setCustomColor11 NOTIFY customColorsChanged FINAL)
153 Q_PROPERTY(QColor customColor12 READ customColor12 WRITE setCustomColor12 NOTIFY customColorsChanged FINAL)
154 Q_PROPERTY(QColor customColor13 READ customColor13 WRITE setCustomColor13 NOTIFY customColorsChanged FINAL)
155 Q_PROPERTY(QColor customColor14 READ customColor14 WRITE setCustomColor14 NOTIFY customColorsChanged FINAL)
156 Q_PROPERTY(QColor customColor15 READ customColor15 WRITE setCustomColor15 NOTIFY customColorsChanged FINAL)
157 Q_PROPERTY(QColor customColor16 READ customColor16 WRITE setCustomColor16 NOTIFY customColorsChanged FINAL)
160 Q_PROPERTY(QVariant audioSpectrum READ audioSpectrumVariant WRITE setAudioSpectrumVariant NOTIFY
161 audioSpectrumChanged FINAL)
162 Q_PROPERTY(QVariant wallpaperTexture READ wallpaperTextureVariant WRITE setWallpaperTextureVariant NOTIFY
163 wallpaperTextureChanged FINAL)
164 Q_PROPERTY(
bool useWallpaper READ useWallpaper WRITE setUseWallpaper NOTIFY useWallpaperChanged FINAL)
165 Q_PROPERTY(
bool useDepthBuffer READ useDepthBuffer WRITE setUseDepthBuffer NOTIFY useDepthBufferChanged FINAL)
168 Q_PROPERTY(
Status status READ status NOTIFY statusChanged FINAL)
169 Q_PROPERTY(QString errorLog READ errorLog NOTIFY errorLogChanged FINAL)
189 static constexpr
int kMaxSvgDimension = 2048;
194 static constexpr
int kMinSvgDimension = 64;
202 static constexpr qint64 kMaxSvgPixelBytes = 16LL * 1024 * 1024;
218 virtual
void setUniformExtension(std::shared_ptr<
PhosphorShaders::IUniformExtension> extension);
259 return m_iResolution;
273 return m_shaderSource;
279 return m_vertexShaderUrl;
285 return m_shaderParams;
377 return m_sourceItem.data();
385 return m_bufferShaderPath;
391 return m_bufferShaderPaths;
397 return m_bufferFeedback;
403 return m_bufferScale;
409 return m_halfFloatBuffers;
421 return m_bufferWraps;
427 return m_bufferFilter;
433 return m_bufferFilters;
441 return m_customParams[0];
446 return m_customParams[1];
451 return m_customParams[2];
456 return m_customParams[3];
461 return m_customParams[4];
466 return m_customParams[5];
471 return m_customParams[6];
476 return m_customParams[7];
484 return m_customColors[0];
489 return m_customColors[1];
494 return m_customColors[2];
499 return m_customColors[3];
504 return m_customColors[4];
509 return m_customColors[5];
514 return m_customColors[6];
519 return m_customColors[7];
524 return m_customColors[8];
529 return m_customColors[9];
534 return m_customColors[10];
539 return m_customColors[11];
544 return m_customColors[12];
549 return m_customColors[13];
554 return m_customColors[14];
559 return m_customColors[15];
663 return m_useWallpaper;
669 return m_useDepthBuffer;
679 return m_shaderIncludePaths;
692 return m_paramPreamble;
702 void setEntryScaffold(
const QString& prologue,
const QList<PhosphorShaders::EntryCandidate>& candidates);
708 return m_status.load(std::memory_order_acquire);
712 QMutexLocker lock(&m_errorLogMutex);
792 void geometryChange(
const QRectF& newGeometry,
const QRectF& oldGeometry)
override;
794 void itemChange(ItemChange change,
const ItemChangeData& value)
override;
836 return m_shaderDirty.exchange(
false);
879 void updatePlayingConnection();
882 void onPlayingTick();
908 void updateScaleConnections();
915 qreal m_iTimeDelta = 0.0;
916 qreal m_playingLastFrameSeconds = 0.0;
917 QSizeF m_iResolution;
920 bool m_isReversed =
false;
921 bool m_playing =
false;
922 QMetaObject::Connection m_playingConnection;
925 QMetaObject::Connection m_scaleConnection;
932 QMetaObject::Connection m_screenDprConnection;
936 QUrl m_vertexShaderUrl;
937 QVariantMap m_shaderParams;
938 QStringList m_shaderIncludePaths;
939 QString m_paramPreamble;
940 QString m_entryPrologue;
941 QList<PhosphorShaders::EntryCandidate> m_entryCandidates;
947 QPointer<QQuickItem> m_sourceItem;
951 bool m_warnedSelfSourceItem =
false;
954 QString m_bufferShaderPath;
955 QStringList m_bufferShaderPaths;
956 bool m_bufferFeedback =
false;
957 qreal m_bufferScale = 1.0;
958 bool m_halfFloatBuffers =
true;
959 QString m_bufferWrap = QStringLiteral(
"clamp");
960 QStringList m_bufferWraps;
961 QString m_bufferFilter = QStringLiteral(
"linear");
962 QStringList m_bufferFilters;
965 std::array<QVector4D, 8> m_customParams = {{
966 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
967 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
968 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
969 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
970 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
971 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
972 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
973 QVector4D(-1.0f, -1.0f, -1.0f, -1.0f),
977 std::array<QColor, 16> m_customColors = {{
978 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
979 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
980 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
981 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
982 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
983 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
984 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
985 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
986 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
987 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
988 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
989 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
990 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
991 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
992 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
993 QColor::fromRgbF(0.0f, 0.0f, 0.0f, 0.0f),
997 QVector<float> m_audioSpectrum;
998 std::array<QImage, kMaxUserTextureSlots> m_userTextureImages;
1003 std::array<QString, kMaxUserTextureSlots> m_userTextureWraps = {QStringLiteral(
"clamp"), QStringLiteral(
"clamp"),
1004 QStringLiteral(
"clamp"), QStringLiteral(
"clamp")};
1010 std::array<QString, kMaxUserTextureSlots> m_userTexturePaths;
1020 std::array<int, kMaxUserTextureSlots> m_userTextureSvgSizes{};
1030 bool m_userTexturesDirectlyOverridden =
false;
1031 QImage m_wallpaperTexture;
1032 mutable QMutex m_wallpaperTextureMutex;
1033 bool m_useWallpaper =
false;
1034 bool m_useDepthBuffer =
false;
1037 std::shared_ptr<PhosphorShaders::IUniformExtension> m_uniformExtension;
1047 std::atomic<Status> m_status{Status::Null};
1055 mutable QMutex m_errorLogMutex;
1070 std::shared_ptr<ShaderNodeLiveness> m_renderNodeLink;
1075 mutable std::mutex m_renderNodeMutex;
1079 std::shared_ptr<ShaderNodeLiveness> trackedNodeLink()
const;
1083 void withTrackedNode(
const std::function<
void(ShaderNodeRhi*)>& fn)
const;
1086 QPointer<QQuickWindow> m_connectedWindow;
1102 ShaderEffect* effect =
nullptr;
1104 std::shared_ptr<SelfToken> m_selfToken = std::make_shared<SelfToken>();
1109 void notifyOnGuiThread(
void (ShaderEffect::*signal)());
1112 std::atomic<bool> m_shaderDirty{
false};
QQuickItem that renders a fullscreen fragment shader via Qt RHI.
Definition ShaderEffect.h:81
void reloadShader()
Force reload of shader from source (callable from QML).
qreal effectiveResolutionScale() const
The factor the GPU-bound iResolution is multiplied by.
QColor customColor4() const
Definition ShaderEffect.h:497
QVariant wallpaperTextureVariant() const
QML-facing form of wallpaperTexture, and the reason the Q_PROPERTY is a QVariant rather than a QImage...
void setCustomParams4(const QVector4D ¶ms)
void setCustomParams6(const QVector4D ¶ms)
QVariant audioSpectrumVariant() const
void setUserTexture(int slot, const QImage &image)
Set a user texture (slots 0-3, bindings 7-10) directly from a QImage, bypassing the path-driven loade...
void bufferFiltersChanged()
void setITime(qreal time)
void setUserTextureWrap(int slot, const QString &wrap)
Set user texture wrap mode (slots 0-3).
void setShaderSource(const QUrl &source)
void setIResolution(const QSizeF &resolution)
QColor customColorAt(int index) const
Read a customColor slot by index.
void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override
QVariantMap shaderParams() const
Definition ShaderEffect.h:283
void wallpaperTextureChanged()
QString paramPreamble() const
Definition ShaderEffect.h:690
void setCustomColor3(const QColor &color)
void releaseIdleGraphicsResources()
Release the render node's RHI resources (buffer FBOs, pipelines, uploaded textures) while the item si...
bool useDepthBuffer() const
Definition ShaderEffect.h:667
void setBufferShaderPath(const QString &path)
void setCustomColor7(const QColor &color)
QVector4D customParams7() const
Definition ShaderEffect.h:469
QVector4D customParams4() const
Definition ShaderEffect.h:454
void setBufferFilters(const QStringList &filters)
QPointF iMouse() const
Definition ShaderEffect.h:263
void setCustomColor2(const QColor &color)
void setBufferFeedback(bool enable)
void setCustomColor11(const QColor &color)
QColor customColor15() const
Definition ShaderEffect.h:552
void setCustomColor10(const QColor &color)
void statusChanged()
Emitted when status() transitions.
qreal bufferScale() const
Definition ShaderEffect.h:401
bool isReversed() const
Definition ShaderEffect.h:247
void shaderParamsChanged()
QUrl shaderSource() const
Definition ShaderEffect.h:271
QColor customColor1() const
Definition ShaderEffect.h:482
void setStatus(Status newStatus)
void setAudioSpectrumVariant(const QVariant &spectrum)
bool halfFloatBuffers() const
Definition ShaderEffect.h:407
void setCustomColor15(const QColor &color)
void setIFrame(int frame)
void bufferShaderPathsChanged()
bool useWallpaper() const
Definition ShaderEffect.h:661
void halfFloatBuffersChanged()
void shaderSourceChanged()
void setCustomColorAt(int index, const QColor &color)
Write a customColor slot by index.
QColor customColor16() const
Definition ShaderEffect.h:557
void setUseWallpaper(bool use)
void setBufferShaderPaths(const QStringList &paths)
void setPlaying(bool playing)
QImage wallpaperTexture() const
void setBufferWrap(const QString &wrap)
QUrl vertexShaderUrl() const
Definition ShaderEffect.h:277
void errorLogChanged()
Emitted from setError().
void setCustomParams2(const QVector4D ¶ms)
void setCustomColor9(const QColor &color)
void paramPreambleChanged()
QColor customColor13() const
Definition ShaderEffect.h:542
QVector4D customParams3() const
Definition ShaderEffect.h:449
void setCustomParams7(const QVector4D ¶ms)
QVector4D customParams1() const
Definition ShaderEffect.h:439
void setCustomColor4(const QColor &color)
QColor customColor14() const
Definition ShaderEffect.h:547
void setParamPreamble(const QString &preamble)
Set the generated named-parameter preamble spliced after #version into the fragment source at load ti...
QColor customColor7() const
Definition ShaderEffect.h:512
void setBufferFilter(const QString &filter)
void registerRenderNode(ShaderNodeRhi *node)
Register the live render node for base-class teardown coverage.
QSGNode * updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data) override
QVector4D customParamAt(int index) const
Read a customParams slot by index.
void iResolutionChanged()
void setIMouse(const QPointF &mouse)
void setCustomParamAt(int index, const QVector4D ¶ms)
Write a customParams slot by index.
QVector4D customParams8() const
Definition ShaderEffect.h:474
void audioSpectrumChanged()
QStringList bufferFilters() const
Definition ShaderEffect.h:431
void setCustomColor6(const QColor &color)
void setCustomColor13(const QColor &color)
void setCustomParams5(const QVector4D ¶ms)
void componentComplete() override
bool bufferFeedback() const
Definition ShaderEffect.h:395
QString bufferWrap() const
Definition ShaderEffect.h:413
void setCustomParams3(const QVector4D ¶ms)
bool isPlaying() const
Definition ShaderEffect.h:241
void syncBasePropertiesToNode(ShaderNodeRhi *node)
Sync base properties (time, params, colors, audio, multipass, depth, wallpaper, user textures,...
void setBufferWraps(const QStringList &wraps)
QVector4D customParams5() const
Definition ShaderEffect.h:459
QColor customColor3() const
Definition ShaderEffect.h:492
QString bufferFilter() const
Definition ShaderEffect.h:425
void customParamsChanged()
void customColorsChanged()
Status status() const
Definition ShaderEffect.h:706
QColor customColor2() const
Definition ShaderEffect.h:487
virtual ShaderNodeRhi * createShaderNode()
Factory hook for the render node updatePaintNode() will create.
QStringList bufferWraps() const
Definition ShaderEffect.h:419
void bufferShaderPathChanged()
void setCustomColor8(const QColor &color)
QColor customColor8() const
Definition ShaderEffect.h:517
QVector4D customParams2() const
Definition ShaderEffect.h:444
QColor customColor11() const
Definition ShaderEffect.h:532
Status
Auto-tick mode.
Definition ShaderEffect.h:175
void bufferScaleChanged()
QStringList bufferShaderPaths() const
Definition ShaderEffect.h:389
void setCustomColor5(const QColor &color)
int iFrame() const
Definition ShaderEffect.h:235
QVector4D customParams6() const
Definition ShaderEffect.h:464
void setShaderIncludePaths(const QStringList &paths)
Set directories to search for #include directives in shaders.
void itemChange(ItemChange change, const ItemChangeData &value) override
void setUseDepthBuffer(bool use)
void setAudioSpectrum(const QVector< float > &spectrum)
Direct setter from C++ avoiding QVariantList round-trip.
void setCustomColor16(const QColor &color)
void setHalfFloatBuffers(bool enable)
QString errorLog() const
Definition ShaderEffect.h:710
void setCustomColor1(const QColor &color)
void setCustomColor14(const QColor &color)
void bufferWrapsChanged()
void setWallpaperTexture(const QImage &image)
void setCustomParams8(const QVector4D ¶ms)
QSizeF iResolution() const
Definition ShaderEffect.h:257
void setEntryScaffold(const QString &prologue, const QList< PhosphorShaders::EntryCandidate > &candidates)
Install the entry-point scaffold forwarded to the render node: when the fragment source defines no ma...
void bufferFilterChanged()
void setITimeDelta(qreal delta)
QColor customColor5() const
Definition ShaderEffect.h:502
QColor customColor6() const
Definition ShaderEffect.h:507
void setIsReversed(bool reverse)
Direction signal forwarded to ShaderNodeRhi → BaseUniforms::iIsReversed.
virtual void setShaderParams(const QVariantMap ¶ms)
Push a parameter map onto the shader.
void setSourceItem(QQuickItem *item)
void setCustomColor12(const QColor &color)
static QImage loadUserTextureFile(const QString &path, int svgMaxDim)
Static helper that loads a user-texture file (PNG/JPG/etc.
QColor customColor12() const
Definition ShaderEffect.h:537
void setError(const QString &error)
void setBufferScale(qreal scale)
void setCustomParams1(const QVector4D ¶ms)
QStringList shaderIncludePaths() const
Definition ShaderEffect.h:677
QColor customColor10() const
Definition ShaderEffect.h:527
QString bufferShaderPath() const
Definition ShaderEffect.h:383
void vertexShaderUrlChanged()
void setVertexShaderUrl(const QUrl &source)
void setWallpaperTextureVariant(const QVariant &texture)
Accepts a QImage, a null, an undefined, an absent key, or an invalid QVariant — a host with nothing b...
qreal iTimeDelta() const
Definition ShaderEffect.h:229
void useDepthBufferChanged()
QQuickItem * sourceItem() const
Live texture-provider source bound to SRB binding 7 (uTexture0).
Definition ShaderEffect.h:375
void bufferFeedbackChanged()
void useWallpaperChanged()
QColor customColor9() const
Definition ShaderEffect.h:522
bool consumeShaderDirty()
Atomically read-and-clear the shader-dirty flag.
Definition ShaderEffect.h:834
QSGRenderNode for fullscreen-quad shader rendering via Qt RHI (Vulkan / OpenGL)
Definition ShaderNodeRhi.h:126
Definition ShaderCompiler.h:15
PHOSPHORRENDERING_EXPORT QVariant peelQmlVariant(const QVariant &value)
Peel the QML delivery wrappers off a property value and return the inner QVariant.
constexpr int kMaxUserTextureSlots
Public mirror of ShaderNodeRhi::kMaxUserTextures (4 user-texture slots at SRB bindings 7....
Definition ShaderEffect.h:46
constexpr int kDefaultUserTextureSvgSize
Default per-axis rasterisation size for an SVG user texture, used until a slot's shader param overrid...
Definition ShaderEffect.h:50
Definition ShaderEffect.h:33