Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
PhosphorShaders::CustomParams Namespace Reference

Canonical key format for the customParams[N]. More...

Functions

QString slotKey (int vec, char comp)
 Format a customParams slot key from explicit (vec, comp) pair.
QString slotKey (int slot)
 Format a customParams slot key from a flat sub-slot index in [0, kFlatSlotCount).
QString glslAccessor (int slot)
 GLSL author-facing accessor for a flat scalar sub-slot — the form a shader author reads in fragment source, as opposed to slotKey()'s QVariantMap serialisation form.

Variables

constexpr int kVecCount = 8
 Number of vec4 slots in BaseUniforms::customParams[8].
constexpr int kFlatSlotCount = 4 * kVecCount
 Number of float sub-slots across all vec4s (4 × kVecCount).

Detailed Description

Canonical key format for the customParams[N].

<x|y|z|w> sub-slots in BaseUniforms. Used as the cross-runtime serialisation of per-effect declared parameter values when those values travel through a QVariantMap between encoder (a registry's translate* method) and decoder (a render path that writes them into the UBO).

Produces strings of the form "customParams<N>_<x|y|z|w>" where N is 1-based (matching what GLSL authors write in their #define direction customParams[0].x macros, plus one for the daemon's UBO key parser).

EVERY family encodes through this format and BOTH runtimes decode through it. That is the property worth stating; the count that used to stand here said three in one sentence and four in the next, and both were out of date.

• Encoders. The overlay registry's ParameterInfo::uniformName() builds the same strings from an internal lookup table. Animation, surface and pointer each reach this function through their own contract header's paramKey forwarder. • Decoders. The daemon decodes in PhosphorRendering::ShaderEffect::setShaderParams, for every family. The compositor decodes in its own per-family pack code.

If the format ever changes, even just the leading "customParams" prefix or the underscore separator, the change lands here and every site follows.

Function Documentation

◆ glslAccessor()

QString PhosphorShaders::CustomParams::glslAccessor ( int slot)
inline

GLSL author-facing accessor for a flat scalar sub-slot — the form a shader author reads in fragment source, as opposed to slotKey()'s QVariantMap serialisation form.

Slot 0 → "customParams[0].x", slot 5 → "customParams[1].y". The vec index is rendered 0-based here to match GLSL array indexing (slotKey() is 1-based for the uniform-key wire format). Out-of-range values return an empty QString — same graceful-degradation contract as slotKey(int).

◆ slotKey() [1/2]

QString PhosphorShaders::CustomParams::slotKey ( int slot)
inline

Format a customParams slot key from a flat sub-slot index in [0, kFlatSlotCount).

Slot 0 → "customParams1_x", slot 4 → "customParams2_x", etc.

Out-of-range values return an empty QString rather than wrapping around — wrap-around would silently collide with a valid in-range key (e.g. slot = -1 would otherwise produce the same string as slot = 3 in two's-complement modulo arithmetic, corrupting the decoder's UBO upload). The empty-string behaviour is graceful-degradation: no decoder ever matches the empty key, so the value drops cleanly rather than overflowing into an adjacent slot.

◆ slotKey() [2/2]

QString PhosphorShaders::CustomParams::slotKey ( int vec,
char comp )
inline

Format a customParams slot key from explicit (vec, comp) pair.

vec is the 0..7 index into customParams[8] (the array slot); comp is 'x', 'y', 'z', or 'w' (the float sub-slot inside the vec4). The vec index is rendered 1-based in the output to match the GLSL-author convention.

Variable Documentation

◆ kFlatSlotCount

int PhosphorShaders::CustomParams::kFlatSlotCount = 4 * kVecCount
inlineconstexpr

Number of float sub-slots across all vec4s (4 × kVecCount).

Caps the flat-index space used by slotKey(int slot) and the per-effect parameter budget enforced by AnimationShaderContract::kMaxParameterSlots (which forwards to this constant).

◆ kVecCount

int PhosphorShaders::CustomParams::kVecCount = 8
inlineconstexpr

Number of vec4 slots in BaseUniforms::customParams[8].