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
85inline QString glslAccessor(int slot)
86{
87 if (slot < 0 || slot >= kFlatSlotCount) {
88 return {};
89 }
90 static constexpr char kComponents[4] = {'x', 'y', 'z', 'w'};
91 return QStringLiteral("customParams[") + QString::number(slot / 4) + QStringLiteral("].")
92 + QLatin1Char(kComponents[slot & 3]);
93}
94
95} // namespace CustomParams
96
124namespace CustomColors {
125
127inline constexpr int kColorCount = 16;
128
133inline QString colorKey(int slot)
134{
135 if (slot < 0 || slot >= kColorCount) {
136 return {};
137 }
138 return QStringLiteral("customColor") + QString::number(slot + 1);
139}
140
146inline QString glslAccessor(int slot)
147{
148 if (slot < 0 || slot >= kColorCount) {
149 return {};
150 }
151 return QStringLiteral("customColors[") + QString::number(slot) + QLatin1Char(']');
152}
153
154} // namespace CustomColors
155
156} // namespace PhosphorShaders
QString colorKey(int slot)
Format a customColor key from a 0-based slot index.
Definition CustomParamsKey.h:133
QString glslAccessor(int slot)
GLSL author-facing accessor for a color slot — the form a shader author reads in fragment source,...
Definition CustomParamsKey.h:146
constexpr int kColorCount
Number of color slots in BaseUniforms::customColors[16].
Definition CustomParamsKey.h:127
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
QString glslAccessor(int slot)
GLSL author-facing accessor for a flat scalar sub-slot — the form a shader author reads in fragment s...
Definition CustomParamsKey.h:85
Definition ShaderEffect.h:30