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
16
28class PHOSPHORRENDERING_EXPORT ShaderCompiler
29{
30public:
31 struct Result
32 {
33 QShader shader;
34 bool success = false;
35 QString error;
36 };
37
40 static Result compile(const QByteArray& source, QShader::Stage stage);
41
45 static Result compileFromFile(const QString& path, const QStringList& includePaths);
46
57 static QString loadAndExpand(const QString& path, const QStringList& includePaths, QString* outError = nullptr,
58 QStringList* outIncludedPaths = nullptr);
59
66 static void clearCache();
67
69 static const QList<QShaderBaker::GeneratedShader>& bakeTargets();
70};
71
72} // namespace PhosphorRendering
Static utility for GLSL → SPIR-V compilation with include resolution and caching.
Definition ShaderCompiler.h:29
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 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 ShaderCompiler.h:15
Definition ShaderCompiler.h:32
QString error
Definition ShaderCompiler.h:35
QShader shader
Definition ShaderCompiler.h:33