Phosphor
Qt6 / Wayland library suite for window-management tools
Loading...
Searching...
No Matches
ShaderCompiler.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 <PhosphorRendering/phosphorrendering_export.h>
7
8#include <QList>
9#include <QString>
10#include <QStringList>
11
12#include <rhi/qshader.h>
13#include <rhi/qshaderbaker.h>
14
15namespace PhosphorRendering {
16
36class PHOSPHORRENDERING_EXPORT ShaderCompiler
37{
38public:
39 struct Result
40 {
41 QShader shader;
42 bool success = false;
43 QString error;
44 };
45
48 static Result compile(const QByteArray& source, QShader::Stage stage);
49
53 static Result compileFromFile(const QString& path, const QStringList& includePaths);
54
65 static QString loadAndExpand(const QString& path, const QStringList& includePaths, QString* outError = nullptr,
66 QStringList* outIncludedPaths = nullptr);
67
83 static QString expandSource(const QString& source, const QString& currentFileDir, const QStringList& includePaths,
84 QString* outError = nullptr, QStringList* outIncludedPaths = nullptr);
85
94 static void clearCache();
95
97 static const QList<QShaderBaker::GeneratedShader>& bakeTargets();
98};
99
100} // namespace PhosphorRendering
Static utility for GLSL → SPIR-V compilation with include resolution and caching.
Definition ShaderCompiler.h:37
static const QList< QShaderBaker::GeneratedShader > & bakeTargets()
Bake target list: SPIR-V 1.0, GLSL 330, GLSL ES 300/310/320.
static QString loadAndExpand(const QString &path, const QStringList &includePaths, QString *outError=nullptr, QStringList *outIncludedPaths=nullptr)
Load a shader file and expand include directives without compiling.
static Result compileFromFile(const QString &path, const QStringList &includePaths)
Load shader from file, expand include directives, then compile.
static QString expandSource(const QString &source, const QString &currentFileDir, const QStringList &includePaths, QString *outError=nullptr, QStringList *outIncludedPaths=nullptr)
Expand include directives in already-read source, without touching the filesystem for the top-level t...
static Result compile(const QByteArray &source, QShader::Stage stage)
Compile GLSL source to QShader (SPIR-V 1.0 + GLSL 330 + ES 300/310/320).
static void clearCache()
Clear the in-memory compilation cache (e.g.
Definition AnimationShaderItemConfig.h:10
Definition ShaderCompiler.h:40
QString error
Definition ShaderCompiler.h:43
bool success
Definition ShaderCompiler.h:42
QShader shader
Definition ShaderCompiler.h:41