Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ShaderParamPreamble.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 <PhosphorShaders/phosphorshaders_export.h>
7
8#include <QList>
9#include <QString>
10
11namespace PhosphorShaders {
12
18inline constexpr int kMaxImageSlots = 4;
19
26{
34 enum class Pool {
38 };
39
40 QString id;
42
48 int explicitSlot = -1;
49};
50
64PHOSPHORSHADERS_EXPORT QString buildParamPreamble(const QList<PreambleParam>& params);
65
70PHOSPHORSHADERS_EXPORT bool isValidParamId(const QString& id);
71
87PHOSPHORSHADERS_EXPORT bool isReservedAnimationParamId(const QString& id);
88
110PHOSPHORSHADERS_EXPORT QString spliceAfterVersion(const QString& source, const QString& block);
111
142PHOSPHORSHADERS_EXPORT int versionDirectiveEnd(const QString& source);
143
171PHOSPHORSHADERS_EXPORT QString kwinDefineBlock(const QString& eol = QStringLiteral("\n"));
172
179
212PHOSPHORSHADERS_EXPORT QString stripVaryingLocations(const QString& source, ShaderStage stage);
213
222PHOSPHORSHADERS_EXPORT QString kwinGlesDialect(const QString& source);
223
229PHOSPHORSHADERS_EXPORT QString kwinDesktopDialect(const QString& source);
230
237PHOSPHORSHADERS_EXPORT QString kwinTopDownTexcoordsDefine(const QString& eol = QStringLiteral("\n"));
238
252PHOSPHORSHADERS_EXPORT QString kwinCompositorSource(const QString& source, ShaderStage stage,
253 const QString& extraDefines = {},
254 bool* synthesizedVersion = nullptr);
255
274PHOSPHORSHADERS_EXPORT QString lineDirective(int line, int sourceString, const QString& eol = QStringLiteral("\n"));
275
276} // namespace PhosphorShaders
Definition ShaderProfile.h:21
constexpr int kMaxImageSlots
Image-pool budget: overlay/zone image params bind to uTexture0..3.
Definition ShaderParamPreamble.h:18
PHOSPHORSHADERS_EXPORT int versionDirectiveEnd(const QString &source)
Locate the first REAL #version directive of source: the first line whose first non-whitespace token i...
PHOSPHORSHADERS_EXPORT QString buildParamPreamble(const QList< PreambleParam > &params)
Build the generated #define p_<id> <glsl-accessor> preamble for a shader's declared parameters.
PHOSPHORSHADERS_EXPORT QString kwinTopDownTexcoordsDefine(const QString &eol=QStringLiteral("\n"))
The #define KWin 6.8's per-window animation path and the decoration present shader splice beside kwin...
PHOSPHORSHADERS_EXPORT QString lineDirective(int line, int sourceString, const QString &eol=QStringLiteral("\n"))
A #line re-anchor that numbers the NEXT line line of source string sourceString under every GLSL dial...
PHOSPHORSHADERS_EXPORT QString kwinDefineBlock(const QString &eol=QStringLiteral("\n"))
The preprocessor block that selects the COMPOSITOR branch of a pack's source, newline-terminated with...
PHOSPHORSHADERS_EXPORT QString stripVaryingLocations(const QString &source, ShaderStage stage)
Remove the layout(location = N) qualifier from every varying of source: the out declarations of a ver...
PHOSPHORSHADERS_EXPORT QString kwinGlesDialect(const QString &source)
source as KWin 6.8 hands it to the driver: every line that starts with #version blanked (its newline ...
ShaderStage
The pipeline stage a source is compiled for, as stripVaryingLocations needs to tell a varying from a ...
Definition ShaderParamPreamble.h:175
@ Fragment
Definition ShaderParamPreamble.h:177
@ Vertex
Definition ShaderParamPreamble.h:176
PHOSPHORSHADERS_EXPORT QString kwinCompositorSource(const QString &source, ShaderStage stage, const QString &extraDefines={}, bool *synthesizedVersion=nullptr)
The compositor branch of source exactly as the effect hands it to KWin: kwinDefineBlock and extraDefi...
PHOSPHORSHADERS_EXPORT QString spliceAfterVersion(const QString &source, const QString &block)
Splice block into source immediately after its #version line, then emit a lineDirective re-anchoring ...
PHOSPHORSHADERS_EXPORT bool isValidParamId(const QString &id)
True if id is a valid GLSL identifier body ([A-Za-z0-9_], non-empty) — the p_ prefix supplies the lea...
PHOSPHORSHADERS_EXPORT bool isReservedAnimationParamId(const QString &id)
True if p_<id> would COLLIDE with a #define p_... a shared family header already owns.
PHOSPHORSHADERS_EXPORT QString kwinDesktopDialect(const QString &source)
source as KWin 6.7 hands it to the driver on a desktop GL context: every line that starts with #versi...
One declared shader parameter, in metadata declaration order, as fed to buildParamPreamble.
Definition ShaderParamPreamble.h:26
Pool
Which UBO region the parameter occupies.
Definition ShaderParamPreamble.h:34
@ Image
Definition ShaderParamPreamble.h:37
@ Color
Definition ShaderParamPreamble.h:36
@ Scalar
Definition ShaderParamPreamble.h:35
int explicitSlot
Explicit slot from metadata, or -1 to auto-assign by declaration order within the parameter's pool.
Definition ShaderParamPreamble.h:48
QString id
Definition ShaderParamPreamble.h:40
Pool pool
Definition ShaderParamPreamble.h:41