Static utility for GLSL → SPIR-V compilation with include resolution and caching.
More...
#include <phosphor-rendering/include/PhosphorRendering/ShaderCompiler.h>
|
| 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 Result | compileFromFile (const QString &path, const QStringList &includePaths) |
| | Load shader from file, expand #include directives, then compile.
|
| |
| 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 void | clearCache () |
| | Clear the in-memory compilation cache (e.g.
|
| |
| static const QList< QShaderBaker::GeneratedShader > & | bakeTargets () |
| | Bake target list: SPIR-V 1.0, GLSL 330, GLSL ES 300/310/320.
|
| |
Static utility for GLSL → SPIR-V compilation with include resolution and caching.
Compilation results are cached by source hash to avoid redundant QShaderBaker invocations. The cache is in-memory only — cleared on process restart.
- Thread-safety
- All methods are safe to call from any thread. Cache reads are lock-free for already-baked sources. Cache misses serialize on an internal bake mutex — QShaderBaker (glslang) is not reentrant, and concurrent bake() calls crash inside QSpirvCompiler::compileToSpirv(), so the mutex is load-bearing and must not be removed. loadAndExpand() is pure I/O and runs concurrently.
◆ bakeTargets()
| static const QList< QShaderBaker::GeneratedShader > & PhosphorRendering::ShaderCompiler::bakeTargets |
( |
| ) |
|
|
static |
Bake target list: SPIR-V 1.0, GLSL 330, GLSL ES 300/310/320.
◆ clearCache()
| static void PhosphorRendering::ShaderCompiler::clearCache |
( |
| ) |
|
|
static |
Clear the in-memory compilation cache (e.g.
on shader hot-reload).
Clears both the source-hash BakeCache AND the filename+mtime cache in the node core — after this call, the next prepare() will re-read and re-compile shader files from disk. Both caches share clearCache() so consumers can call one function to fully invalidate.
◆ compile()
| static Result PhosphorRendering::ShaderCompiler::compile |
( |
const QByteArray & |
source, |
|
|
QShader::Stage |
stage |
|
) |
| |
|
static |
Compile GLSL source to QShader (SPIR-V 1.0 + GLSL 330 + ES 300/310/320).
Cached by source hash; second call with same source returns immediately.
◆ compileFromFile()
| static Result PhosphorRendering::ShaderCompiler::compileFromFile |
( |
const QString & |
path, |
|
|
const QStringList & |
includePaths |
|
) |
| |
|
static |
Load shader from file, expand #include directives, then compile.
- Parameters
-
| path | Path to .frag or .vert file |
| includePaths | Directories to search for #include directives |
◆ loadAndExpand()
| static QString PhosphorRendering::ShaderCompiler::loadAndExpand |
( |
const QString & |
path, |
|
|
const QStringList & |
includePaths, |
|
|
QString * |
outError = nullptr, |
|
|
QStringList * |
outIncludedPaths = nullptr |
|
) |
| |
|
static |
Load a shader file and expand #include directives without compiling.
- Parameters
-
| path | Path to .frag or .vert file |
| includePaths | Directories to search for #include directives |
| outError | If non-null, set on error |
| outIncludedPaths | If non-null, appended with the canonical absolute path of every transitively-included header. Lets callers fingerprint includes so cache-invalidation responds to header edits, not just edits to the top-level file. |
- Returns
- Expanded GLSL source, or empty string on error
The documentation for this class was generated from the following file: