Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorRendering::ShaderNodeRhi Class Reference

QSGRenderNode for fullscreen-quad shader rendering via Qt RHI (Vulkan / OpenGL). More...

#include <PhosphorRendering/ShaderNodeRhi.h>

Inheritance diagram for PhosphorRendering::ShaderNodeRhi:
[legend]

Public Member Functions

 ShaderNodeRhi (QQuickItem *item, std::unique_ptr< PhosphorShaders::IUboProfile > profile=nullptr)
 ~ShaderNodeRhi () override
void invalidateItem ()
 Notify the render node that its owning item is being destroyed.
bool hasValidItem () const
 Whether this node still holds a usable back-pointer to its item.
const std::shared_ptr< ShaderNodeLiveness > & liveness () const
 The liveness block to hand to ShaderEffect::registerRenderNode.
QSGRenderNode::StateFlags changedStates () const override
QSGRenderNode::RenderingFlags flags () const override
QRectF rect () const override
void prepare () override
void render (const RenderState *state) override
void releaseResources () override
void preprocess () override
 Stock-parity dependency pull (mirrors QSGRhiShaderEffectNode): bring the source provider's layer texture current before this node renders.
void setUniformExtension (std::shared_ptr< PhosphorShaders::IUniformExtension > extension)
std::shared_ptr< PhosphorShaders::IUniformExtension > uniformExtension () const
 Access the currently-installed uniform extension (may be nullptr).
void setTime (double time)
void setTimeDelta (float delta)
void setFrame (int frame)
void setResolution (float width, float height)
void setMousePosition (const QPointF &pos)
void setIsReversed (bool reverse)
 Direction signal for asymmetric leg rendering.
void setCustomParams (int index, const QVector4D &params)
void setCustomColor (int index, const QColor &color)
void setSurfaceOpacity (float opacity)
 Per-surface inputs consumed by a SurfaceUniformProfile.
void setSurfaceScale (float scale)
void setSurfaceFocused (bool focused)
void setSurfaceSize (float width, float height)
void setBackdropRect (float x, float y, float w, float h)
 The slice of the bound backdrop this surface samples, normalized texture coords (xy = min, zw = size).
void setSurfaceFrameTopLeft (float x, float y)
void setSurfaceFrameSize (float width, float height)
void setAppField0 (int value)
 Write the consumer's two int slots inside BaseUniforms (offsets 88, 92).
void setAppField1 (int value)
bool setExtraBinding (int binding, QRhiTexture *texture, QRhiSampler *sampler)
 Bind a consumer-owned texture/sampler at the given binding number.
bool removeExtraBinding (int binding)
void setGridSubdivisions (int subdivisions)
 Tessellate the IMAGE pass into an n×n cell grid (0 = the default two-triangle fullscreen quad).
void setAudioSpectrum (const QVector< float > &spectrum)
void setUserTexture (int slot, const QImage &image)
void setUserTextureWrap (int slot, const QString &wrap)
 Set per-slot sampler address mode.
void setWallpaperTexture (const QImage &image)
void setUseWallpaper (bool use)
void setUseDepthBuffer (bool use)
void setSourceTextureProvider (QSGTextureProvider *provider)
 Live texture-provider override for user-texture slot 0 (SRB binding 11 / uTexture0).
QSGTextureProvider * sourceTextureProvider () const
void setBufferShaderPath (const QString &path)
void setBufferShaderPaths (const QStringList &paths)
void invalidateBufferShaders ()
 Force every buffer pass to re-read its source and re-bake, with the path list unchanged.
void setBufferFeedback (bool enable)
void setBufferScale (qreal scale)
 The single-value scale, and the seed for every per-pass slot: this writes scale into ALL of them.
void setBufferScales (const QList< qreal > &scales)
 Per-pass scales aligned with the buffer paths; a slot past the list's end follows the single-value scale.
void setBufferScales (const QVariantList &scales)
 Overload for the QVariantList the item already holds, so a per-frame sync does not materialise a QList<qreal> just to read it once.
void setHalfFloatBuffers (bool enable)
 Buffer-pass texel format: RGBA16F when true (the default — safe for HDR, signed-data, and feedback buffers), RGBA8 when a pack's metadata declares its buffers hold plain clamped colour ("halfFloatBuffers": false).
void setBufferWrap (const QString &wrap)
void setBufferWraps (const QStringList &wraps)
void setBufferFilter (const QString &filter)
void setBufferFilters (const QStringList &filters)
bool loadVertexShader (const QString &path)
bool loadFragmentShader (const QString &path)
void setVertexShaderSource (const QString &source)
void setFragmentShaderSource (const QString &source)
bool isShaderReady () const
QString shaderError () const
void invalidateShader ()
void clearBakedShader ()
 Drop the resident bake, its error, and any pending rebake together.
void invalidateUniforms ()
void setShaderIncludePaths (const QStringList &paths)
void setParamPreamble (const QString &preamble)
 Set the generated named-parameter preamble that is spliced after the fragment shader's #version line at load time (via PhosphorShaders::spliceAfterVersion), so authors read a parameter by name instead of hand-decoding a customParams[N].xyzw lane.
void setEntryScaffold (const QString &prologue, const QList< PhosphorShaders::EntryCandidate > &candidates)
 Install the entry-point scaffold for the fragment stage.

Static Public Member Functions

static QString normalizeWrapMode (const QString &wrap)
 Normalize wrap mode string to "clamp", "repeat", or "mirror" (static helper, safe to call from any thread — operates on its arguments only).
static QString normalizeFilterMode (const QString &filter)
 Normalize filter mode string to "nearest", "linear", or "mipmap".
static QRhiSampler::AddressMode wrapModeToRhiAddress (const QString &wrap)
 Map a normalized wrap-mode string to QRhiSampler::AddressMode.

Static Public Attributes

static constexpr int kMaxGridSubdivisions = 255
 Grid-density ceiling: (255+1)² vertices is the most a quint16 index buffer can address.

Protected Member Functions

QRhi * safeRhi () const
 Thread-safe QRhi accessor.
void retractLiveness () noexcept
 Retract this node from its liveness block.
void requestAnotherFrame () const
 Schedule another frame from the render thread (QQuickWindow::update() is documented thread-safe), with safeRhi()'s liveness locking.

Detailed Description

QSGRenderNode for fullscreen-quad shader rendering via Qt RHI (Vulkan / OpenGL).

Generalized render node extracted from Phosphor's ZoneShaderNodeRhi. Manages a Shadertoy-compatible UBO (a profile-supplied layout, BaseUniforms by default), multipass buffer system, texture bindings (audio, user, wallpaper, depth), and shader baking.

Application-specific UBO data is appended via IUniformExtension. Application-specific texture bindings use setExtraBinding() / removeExtraBinding().

Uses QRhi and QShaderBaker (runtime SPIR-V + GLSL 330 bake). The APIs it needs (commandBuffer(), renderTarget()) arrived in Qt 6.6; the project builds against QT_MIN_VERSION, which is 6.10.

Threading contract
A GUI-THREAD caller of the setters on this class (ShaderNodeRhi — setTime, setResolution, setCustomParams, setExtraBinding, etc.) must go through QQuickItem::updatePaintNode() during the scene graph sync phase, where the GUI thread is blocked and the render thread is idle; reaching them from the GUI thread outside it is a data race with prepare()/render(). The RENDER THREAD may call them from prepare() BEFORE the frame's bindings are built, and does: uploadLabelsTexture calls setExtraBinding there. That covers DATA RACES ONLY. A mutator that drops an SRB, pipeline, buffer target or the UBO — mechanically, any one that calls resetAllBindingsAndPipelines() or resetBufferTargets(), or resets a QRhi member itself — must NOT be reached from render(), nor from prepare() once its passes are recorded, on ANY thread. That predicate is grep-checkable; a name list here rots. Only invalidateItem() is safe to call from the GUI thread outside the sync phase: it is the only entry point built for it, with its flag atomic AND m_itemMutex serialising the dereference against the render thread. (Not "the only flag exposed as std::atomic", which this said before and which is simply untrue — the cached geometry below is atomic too. Those are private and reached only through rect(), which the scene graph calls on the render thread, so the rule itself is unaffected.)

Two sanctioned routes reach releaseResources() on the render thread OUTSIDE the sync phase, and a consumer deciding what may call it needs both: the QQuickWindow::NoStage render job posted by ShaderEffect::releaseIdleGraphicsResources, and the Qt::DirectConnection to QQuickWindow::sceneGraphAboutToStop, whose lambda calls it as well. The render job certainly runs while the GUI thread is NOT blocked, and the same safety argument covers both either way: no GUI-thread path mutates node members directly, because every ShaderEffect setter stages into the item's own members and defers the node push to the next sync, so neither route can race a concurrent member write.

(Setters on the sibling ShaderEffect class are a different story — those run on the GUI thread and stage their changes into ShaderEffect's own members, to be pushed down to this node during the next sync phase.)

Extra binding lifetime (CRITICAL)
The consumer-owned QRhiTexture/QRhiSampler pointers passed to setExtraBinding() are stored as raw pointers and re-bound on every prepare() until removeExtraBinding() is called. If the consumer drops the texture/sampler (e.g. by calling unique_ptr::reset() or letting it fall out of scope) without first calling removeExtraBinding(), the next prepare() will dereference a dangling pointer — undefined behaviour, typically a crash inside the RHI backend. ALWAYS call removeExtraBinding(binding) before destroying the underlying QRhiTexture/QRhiSampler. No automatic lifetime tracking exists — callers are solely responsible for the remove-before-destroy contract.

Constructor & Destructor Documentation

◆ ShaderNodeRhi()

PhosphorRendering::ShaderNodeRhi::ShaderNodeRhi ( QQuickItem * item,
std::unique_ptr< PhosphorShaders::IUboProfile > profile = nullptr )
explicit
Parameters
itemOwning QQuickItem (must outlive the node until invalidateItem() is called).
profilePluggable UBO profile. The default (nullptr) installs a BaseUniformProfile so every existing caller — including ZoneShaderNodeRhi's ShaderNodeRhi(item) forward — keeps the legacy overlay/animation UBO (BaseUniforms, currently 672 bytes) unchanged. The surface-decoration runtime passes a SurfaceUniformProfile here to reuse the engine with the DISTINCT surface UBO — a different 672-byte layout, not a smaller one. Both static_assert to the same size, and past the shared qt_Matrix / qt_Opacity lead (and iTextureResolution, also at 592 in both) the members do not line up. UBO size is always profile-defined (m_uboProfile->baseSize()), never hard-coded.

◆ ~ShaderNodeRhi()

PhosphorRendering::ShaderNodeRhi::~ShaderNodeRhi ( )
override

Member Function Documentation

◆ changedStates()

QSGRenderNode::StateFlags PhosphorRendering::ShaderNodeRhi::changedStates ( ) const
override

◆ clearBakedShader()

void PhosphorRendering::ShaderNodeRhi::clearBakedShader ( )

Drop the resident bake, its error, and any pending rebake together.

For the "source is gone" arms of the owning item's sync (a failed load, or a deliberately cleared source): a resident previous bake would otherwise keep isShaderReady() true and let the item's status block promote a just-reported Error/Null back to Ready in the same sync, and the pending m_shaderDirty would make the next prepare() manufacture an "empty source" error for a deliberate clear. render() bails on the cleared readiness; the next real source set re-arms the bake through the setters.

◆ flags()

QSGRenderNode::RenderingFlags PhosphorRendering::ShaderNodeRhi::flags ( ) const
override

◆ hasValidItem()

bool PhosphorRendering::ShaderNodeRhi::hasValidItem ( ) const
inline

Whether this node still holds a usable back-pointer to its item.

False once invalidateItem() has run. This is the node's central threading invariant — every m_item dereference is gated on it — so it is exposed for callers that need to assert the teardown contract held (chiefly: that the item severed the back-pointer before it was freed). Thread-safe, but only a snapshot: do not use it to gate a dereference the node does not own.

◆ invalidateBufferShaders()

void PhosphorRendering::ShaderNodeRhi::invalidateBufferShaders ( )

Force every buffer pass to re-read its source and re-bake, with the path list unchanged.

setBufferShaderPaths is the only other thing that arms those flags and it returns early when the list matches, which is exactly the case an in-place edit of a pass's source presents. Without this, a reload re-baked the main fragment and vertex stages from disk and left every buffer pass on the bake it already had.

Only re-arms the flags and drops the cached sources. The re-read itself happens lazily in bakeBufferShaders during prepare(), for the reason setBufferShaderPaths gives: this can be called from the sync phase, which under the threaded render loop runs on the render thread with the GUI thread blocked, and disk I/O does not belong there.

◆ invalidateItem()

void PhosphorRendering::ShaderNodeRhi::invalidateItem ( )

Notify the render node that its owning item is being destroyed.

Called from the owning QQuickItem destructor on the GUI thread. After this call, the render node will no longer dereference m_item. Thread-safe: an atomic flag plus m_itemMutex, which serialises every dereference.

◆ invalidateShader()

void PhosphorRendering::ShaderNodeRhi::invalidateShader ( )

◆ invalidateUniforms()

void PhosphorRendering::ShaderNodeRhi::invalidateUniforms ( )

◆ isShaderReady()

bool PhosphorRendering::ShaderNodeRhi::isShaderReady ( ) const

◆ liveness()

const std::shared_ptr< ShaderNodeLiveness > & PhosphorRendering::ShaderNodeRhi::liveness ( ) const
inline

The liveness block to hand to ShaderEffect::registerRenderNode.

Valid for the node's whole lifetime and beyond — the block itself outlives the node, which nulls its own pointer inside it on destruction. See ShaderNodeLiveness.

◆ loadFragmentShader()

bool PhosphorRendering::ShaderNodeRhi::loadFragmentShader ( const QString & path)

◆ loadVertexShader()

bool PhosphorRendering::ShaderNodeRhi::loadVertexShader ( const QString & path)

◆ normalizeFilterMode()

QString PhosphorRendering::ShaderNodeRhi::normalizeFilterMode ( const QString & filter)
static

Normalize filter mode string to "nearest", "linear", or "mipmap".

◆ normalizeWrapMode()

QString PhosphorRendering::ShaderNodeRhi::normalizeWrapMode ( const QString & wrap)
static

Normalize wrap mode string to "clamp", "repeat", or "mirror" (static helper, safe to call from any thread — operates on its arguments only).

Unknown / empty inputs fall back to "clamp" — that fallback is load-bearing for legacy callers that pass an empty string when no wrap is configured.

◆ prepare()

void PhosphorRendering::ShaderNodeRhi::prepare ( )
override

◆ preprocess()

void PhosphorRendering::ShaderNodeRhi::preprocess ( )
override

Stock-parity dependency pull (mirrors QSGRhiShaderEffectNode): bring the source provider's layer texture current before this node renders.

Without it, a ShaderEffectSource this node samples only re-grabs when its OWN subtree is dirtied — a dependency the scene graph cannot see through a raw provider pointer — so a node captured into an enclosing layer (SurfaceAnimator's transition capture) can freeze on an empty first grab for a whole animation leg. Enabled via UsePreprocess in the constructor.

◆ rect()

QRectF PhosphorRendering::ShaderNodeRhi::rect ( ) const
override

◆ releaseResources()

void PhosphorRendering::ShaderNodeRhi::releaseResources ( )
override

◆ removeExtraBinding()

bool PhosphorRendering::ShaderNodeRhi::removeExtraBinding ( int binding)
Returns
true if a binding existed at that slot and was removed.

◆ render()

void PhosphorRendering::ShaderNodeRhi::render ( const RenderState * state)
override

◆ requestAnotherFrame()

void PhosphorRendering::ShaderNodeRhi::requestAnotherFrame ( ) const
protected

Schedule another frame from the render thread (QQuickWindow::update() is documented thread-safe), with safeRhi()'s liveness locking.

For prepare()-side conditions that leave work pending — an upload that got no resource-update batch — where a STATIC item (no clock, no property churn) would otherwise never be prepared again and render()'s pending-skip would leave it blank indefinitely.

PROTECTED rather than private because ZoneShaderNodeRhi's labels upload has the same shape and needs it. Moving a NON-VIRTUAL member between access sections changes no member offset and no vtable, so this is ABI-safe under the append-only rule, for the same reason the note on requestDepthCreateRetry gives.

◆ retractLiveness()

void PhosphorRendering::ShaderNodeRhi::retractLiveness ( )
protectednoexcept

Retract this node from its liveness block.

MUST be the first statement of EVERY subclass destructor, not just this class's. The most-derived destructor body and its member teardown run before ~ShaderNodeRhi, so a retract that happened only in the base would leave ShaderEffect::withTrackedNode able to dispatch a virtual call into a node whose derived half is already destroyed.

Idempotent (nulling an already-null pointer under the same mutex), so the base destructor's own call after a subclass has already retracted costs one uncontended lock and nothing else. Takes ShaderNodeLiveness::mutex, so it must not be called with m_itemMutex held. See ShaderNodeLiveness for the full ordering.

◆ safeRhi()

QRhi * PhosphorRendering::ShaderNodeRhi::safeRhi ( ) const
protected

Thread-safe QRhi accessor.

Returns
The active QRhi for the owning window, or nullptr when the item has been invalidated or has no window. Subclasses that override prepare() should route through this helper rather than commandBuffer()->rhi() so the post-invalidateItem() guard stays uniform.

◆ setAppField0()

void PhosphorRendering::ShaderNodeRhi::setAppField0 ( int value)

Write the consumer's two int slots inside BaseUniforms (offsets 88, 92).

See PhosphorShaders::BaseUniforms for the full escape-hatch rationale. Updating these fields is cheap: the library uploads only the 8-byte K_APP_FIELDS region rather than the full scene header.

◆ setAppField1()

void PhosphorRendering::ShaderNodeRhi::setAppField1 ( int value)

◆ setAudioSpectrum()

void PhosphorRendering::ShaderNodeRhi::setAudioSpectrum ( const QVector< float > & spectrum)

◆ setBackdropRect()

void PhosphorRendering::ShaderNodeRhi::setBackdropRect ( float x,
float y,
float w,
float h )

The slice of the bound backdrop this surface samples, normalized texture coords (xy = min, zw = size).

Defaults to the whole texture.

Only a host that binds ONE shared image across many surfaces needs this — a daemon or preview host handing every surface the same desktop wallpaper. The compositor's capture already covers the window's own canvas, so it leaves the default alone.

◆ setBufferFeedback()

void PhosphorRendering::ShaderNodeRhi::setBufferFeedback ( bool enable)

◆ setBufferFilter()

void PhosphorRendering::ShaderNodeRhi::setBufferFilter ( const QString & filter)

◆ setBufferFilters()

void PhosphorRendering::ShaderNodeRhi::setBufferFilters ( const QStringList & filters)

◆ setBufferScale()

void PhosphorRendering::ShaderNodeRhi::setBufferScale ( qreal scale)

The single-value scale, and the seed for every per-pass slot: this writes scale into ALL of them.

ORDER MATTERS between this and setBufferScales, and it is not symmetric. Call this one FIRST and setBufferScales second. The reverse order discards the per-pass list entirely, because this setter overwrites every slot it just filled. ShaderEffect::syncBasePropertiesToNode pushes them in that order for exactly this reason.

◆ setBufferScales() [1/2]

void PhosphorRendering::ShaderNodeRhi::setBufferScales ( const QList< qreal > & scales)

Per-pass scales aligned with the buffer paths; a slot past the list's end follows the single-value scale.

Empty means "every pass on the single-value scale".

Must be pushed AFTER setBufferScale — see its note.

◆ setBufferScales() [2/2]

void PhosphorRendering::ShaderNodeRhi::setBufferScales ( const QVariantList & scales)

Overload for the QVariantList the item already holds, so a per-frame sync does not materialise a QList<qreal> just to read it once.

Same clamping and the same ordering contract as the overload above.

◆ setBufferShaderPath()

void PhosphorRendering::ShaderNodeRhi::setBufferShaderPath ( const QString & path)

◆ setBufferShaderPaths()

void PhosphorRendering::ShaderNodeRhi::setBufferShaderPaths ( const QStringList & paths)

◆ setBufferWrap()

void PhosphorRendering::ShaderNodeRhi::setBufferWrap ( const QString & wrap)

◆ setBufferWraps()

void PhosphorRendering::ShaderNodeRhi::setBufferWraps ( const QStringList & wraps)

◆ setCustomColor()

void PhosphorRendering::ShaderNodeRhi::setCustomColor ( int index,
const QColor & color )

◆ setCustomParams()

void PhosphorRendering::ShaderNodeRhi::setCustomParams ( int index,
const QVector4D & params )

◆ setEntryScaffold()

void PhosphorRendering::ShaderNodeRhi::setEntryScaffold ( const QString & prologue,
const QList< PhosphorShaders::EntryCandidate > & candidates )

Install the entry-point scaffold for the fragment stage.

When set and the loaded fragment source does NOT define main(), loadFragmentShader assembles prologue + source and appends the generated main() of the first candidates entry function the source defines (via PhosphorShaders::composeEntryPoint), BEFORE include expansion — so the prologue's #include is resolved. A source that defines its own main() is left untouched (every bundled pack today). The scaffold is folded into the bake-cache key, and MUST match what the warm-bake applies for the same shader. Empty prologue + empty candidates (the default, e.g. the animation path) disables assembly entirely — a strict no-op.

◆ setExtraBinding()

bool PhosphorRendering::ShaderNodeRhi::setExtraBinding ( int binding,
QRhiTexture * texture,
QRhiSampler * sampler )

Bind a consumer-owned texture/sampler at the given binding number.

Warning
The texture and sampler are stored as raw pointers and reused across frames. The consumer MUST call removeExtraBinding(binding) before destroying the underlying QRhiTexture/QRhiSampler — failing to do so leaves a dangling pointer that will be dereferenced inside the RHI on the next prepare() (UB, typically a crash).
Returns
true on success; false if binding collides with a library- managed slot (0, 2-16, the range this header spells out above) or falls outside the supported range. A true return for an identical (binding, texture, sampler) triple is a no-op — the SRB/pipeline is NOT rebuilt when nothing actually changed.

◆ setFragmentShaderSource()

void PhosphorRendering::ShaderNodeRhi::setFragmentShaderSource ( const QString & source)

◆ setFrame()

void PhosphorRendering::ShaderNodeRhi::setFrame ( int frame)

◆ setGridSubdivisions()

void PhosphorRendering::ShaderNodeRhi::setGridSubdivisions ( int subdivisions)

Tessellate the IMAGE pass into an n×n cell grid (0 = the default two-triangle fullscreen quad).

Vertex-displacing animation packs (the geometryGrid metadata key) deform per vertex, which a 4-vertex quad can only shear linearly — the kwin path emits a window-quad grid for them, and this is the Qt-RHI analogue. Positions stay clip-space, texCoords 0..1, so the same vertex sources run unchanged; only the mesh density changes. Buffer passes keep the plain quad: they are image-space passes and never displace. Clamped to [0, kMaxGridSubdivisions] (index-buffer width); the pack metadata clamp (kMaxGeometryGridSubdivisions = 128) is tighter. Drops the grid buffers and the pipeline, so the class-level resource rule applies.

◆ setHalfFloatBuffers()

void PhosphorRendering::ShaderNodeRhi::setHalfFloatBuffers ( bool enable)

Buffer-pass texel format: RGBA16F when true (the default — safe for HDR, signed-data, and feedback buffers), RGBA8 when a pack's metadata declares its buffers hold plain clamped colour ("halfFloatBuffers": false).

◆ setIsReversed()

void PhosphorRendering::ShaderNodeRhi::setIsReversed ( bool reverse)

Direction signal for asymmetric leg rendering.

Forward through to BaseUniforms::iIsReversed at offset 660. SurfaceAnimator pushes this from the leg's isShowLeg flag (false = reverse = hide leg); kwin-effect parity is handled directly via setUniform on the kwin path.

◆ setMousePosition()

void PhosphorRendering::ShaderNodeRhi::setMousePosition ( const QPointF & pos)

◆ setParamPreamble()

void PhosphorRendering::ShaderNodeRhi::setParamPreamble ( const QString & preamble)

Set the generated named-parameter preamble that is spliced after the fragment shader's #version line at load time (via PhosphorShaders::spliceAfterVersion), so authors read a parameter by name instead of hand-decoding a customParams[N].xyzw lane.

The empty default is a no-op splice, so non-adopting shaders bake byte-identically to before. The preamble is folded into the bake-cache key, so two effects sharing a .frag but differing in generated defines never collide, and a metadata param edit (which changes the preamble without touching the .frag mtime) still invalidates the cache.

◆ setResolution()

void PhosphorRendering::ShaderNodeRhi::setResolution ( float width,
float height )

◆ setShaderIncludePaths()

void PhosphorRendering::ShaderNodeRhi::setShaderIncludePaths ( const QStringList & paths)

◆ setSourceTextureProvider()

void PhosphorRendering::ShaderNodeRhi::setSourceTextureProvider ( QSGTextureProvider * provider)

Live texture-provider override for user-texture slot 0 (SRB binding 11 / uTexture0).

When set, every SRB rebuild reads provider->texture()->rhiTexture() and binds that — superseding whatever QImage was uploaded via setUserTexture(0, ...). The provider must outlive the node OR be cleared with nullptr before destruction; we hold a QPointer so a torn-down provider nulls out cleanly. Designed for QQuickItem::textureProvider() returns from layer-enabled items, where the underlying QSGTexture identity changes when the FBO is recreated (resize, device-loss); the SRB-rebuild detection in prepare() notices that change and refreshes the binding without the consumer having to re-call this setter every frame.

◆ setSurfaceFocused()

void PhosphorRendering::ShaderNodeRhi::setSurfaceFocused ( bool focused)

◆ setSurfaceFrameSize()

void PhosphorRendering::ShaderNodeRhi::setSurfaceFrameSize ( float width,
float height )

◆ setSurfaceFrameTopLeft()

void PhosphorRendering::ShaderNodeRhi::setSurfaceFrameTopLeft ( float x,
float y )

◆ setSurfaceOpacity()

void PhosphorRendering::ShaderNodeRhi::setSurfaceOpacity ( float opacity)

Per-surface inputs consumed by a SurfaceUniformProfile.

These feed the surface-only fields of UboFrameState that a surface UBO profile reads (opacity, logical→device scale, focus, surface/frame geometry in device px). A BaseUniformProfile ignores them, so the overlay/animation path is unaffected — the members default to the same values as UboFrameState. A border or rounded-corner pack needs the real surface/frame geometry to know where its edges are, so the host (SurfaceShaderItem) must push these each frame from updatePaintNode.

The opacity set here is the host's explicit factor only. The uploaded qt_Opacity is that factor times QSGRenderNode::inheritedOpacity(), read in prepare(), because a render node is responsible for applying the scene graph's opacity itself. Inside a layer or ShaderEffectSource capture the renderer stops that walk at the captured item's root node, which sits below the captured item's own opacity node, so the node reads only the opacities between itself and that item. What happens to the captured item's own opacity depends on the capture: an item layer (layer.enabled) forwards it to the layer's composite, so it applies once; a hide-source ShaderEffectSource (a decoration tap, SurfaceAnimator's capture) drops it, and only the opacity of the consumer that draws the captured texture applies.

◆ setSurfaceScale()

void PhosphorRendering::ShaderNodeRhi::setSurfaceScale ( float scale)

◆ setSurfaceSize()

void PhosphorRendering::ShaderNodeRhi::setSurfaceSize ( float width,
float height )

◆ setTime()

void PhosphorRendering::ShaderNodeRhi::setTime ( double time)

◆ setTimeDelta()

void PhosphorRendering::ShaderNodeRhi::setTimeDelta ( float delta)

◆ setUniformExtension()

void PhosphorRendering::ShaderNodeRhi::setUniformExtension ( std::shared_ptr< PhosphorShaders::IUniformExtension > extension)

◆ setUseDepthBuffer()

void PhosphorRendering::ShaderNodeRhi::setUseDepthBuffer ( bool use)

◆ setUserTexture()

void PhosphorRendering::ShaderNodeRhi::setUserTexture ( int slot,
const QImage & image )

◆ setUserTextureWrap()

void PhosphorRendering::ShaderNodeRhi::setUserTextureWrap ( int slot,
const QString & wrap )

Set per-slot sampler address mode.

Accepts "clamp", "repeat", or "mirror" (case-sensitive); other values fall back to "clamp" via normalizeWrapMode.

◆ setUseWallpaper()

void PhosphorRendering::ShaderNodeRhi::setUseWallpaper ( bool use)

◆ setVertexShaderSource()

void PhosphorRendering::ShaderNodeRhi::setVertexShaderSource ( const QString & source)

◆ setWallpaperTexture()

void PhosphorRendering::ShaderNodeRhi::setWallpaperTexture ( const QImage & image)

◆ shaderError()

QString PhosphorRendering::ShaderNodeRhi::shaderError ( ) const

◆ sourceTextureProvider()

QSGTextureProvider * PhosphorRendering::ShaderNodeRhi::sourceTextureProvider ( ) const
inline

◆ uniformExtension()

std::shared_ptr< PhosphorShaders::IUniformExtension > PhosphorRendering::ShaderNodeRhi::uniformExtension ( ) const
inline

Access the currently-installed uniform extension (may be nullptr).

◆ wrapModeToRhiAddress()

QRhiSampler::AddressMode PhosphorRendering::ShaderNodeRhi::wrapModeToRhiAddress ( const QString & wrap)
static

Map a normalized wrap-mode string to QRhiSampler::AddressMode.

Single source of truth for sampler address-mode selection so callers can't drift on the "mirror" / "repeat" / "clamp" mapping.

Member Data Documentation

◆ kMaxGridSubdivisions

int PhosphorRendering::ShaderNodeRhi::kMaxGridSubdivisions = 255
staticconstexpr

Grid-density ceiling: (255+1)² vertices is the most a quint16 index buffer can address.

Shared by ShaderEffect's property clamp and the node setter so the two can never disagree — the item↔node equality short-circuits rely on both sides clamping identically.


The documentation for this class was generated from the following file: