Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
CustomParamsKey.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 fuddlesworth
2// SPDX-License-Identifier: LGPL-2.1-or-later
3
4#pragma once
5
6#include <QLatin1Char>
7#include <QString>
8
9namespace PhosphorShaders {
10
37namespace CustomParams {
38
40inline constexpr int kVecCount = 8;
41
46inline constexpr int kFlatSlotCount = 4 * kVecCount;
47
53inline QString slotKey(int vec, char comp)
54{
55 return QStringLiteral("customParams") + QString::number(vec + 1) + QLatin1Char('_') + QLatin1Char(comp);
56}
57
69inline QString slotKey(int slot)
70{
71 if (slot < 0 || slot >= kFlatSlotCount) {
72 return {};
73 }
74 static constexpr char kComponents[4] = {'x', 'y', 'z', 'w'};
75 return slotKey(slot / 4, kComponents[slot & 3]);
76}
77
78} // namespace CustomParams
79
107namespace CustomColors {
108
110inline constexpr int kColorCount = 16;
111
116inline QString colorKey(int slot)
117{
118 if (slot < 0 || slot >= kColorCount) {
119 return {};
120 }
121 return QStringLiteral("customColor") + QString::number(slot + 1);
122}
123
124} // namespace CustomColors
125
126} // namespace PhosphorShaders
QString colorKey(int slot)
Format a customColor key from a 0-based slot index.
Definition CustomParamsKey.h:116
constexpr int kColorCount
Number of color slots in BaseUniforms::customColors[16].
Definition CustomParamsKey.h:110
QString slotKey(int vec, char comp)
Format a customParams slot key from explicit (vec, comp) pair.
Definition CustomParamsKey.h:53
constexpr int kVecCount
Number of vec4 slots in BaseUniforms::customParams[8].
Definition CustomParamsKey.h:40
constexpr int kFlatSlotCount
Number of float sub-slots across all vec4s (4 × kVecCount).
Definition CustomParamsKey.h:46
Definition ShaderEffect.h:28