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).
 

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).

Three concrete consumers of this format today:

PhosphorShaders::ShaderRegistry::ParameterInfo::uniformName() — overlay-shader encoder (uses an internal lookup-table form; identical output) • PhosphorAnimationShaders::AnimationShaderRegistry::translateAnimationParams — animation-shader encoder • PhosphorRendering::ShaderEffect::setShaderParams — decoder for both runtime paths (overlay and animation)

Plus the kwin-effect's per-transition pack at compositor-side. All four call sites consume the format produced here. If the format ever changes — even just the leading "customParams" prefix or the underscore separator — the change has to land here so every site stays in sync.

Function Documentation

◆ 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

constexpr 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

constexpr int PhosphorShaders::CustomParams::kVecCount = 8
inlineconstexpr

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