Phosphor
Qt6 / Wayland library suite for window-management tools
 
Loading...
Searching...
No Matches
PhosphorShaders::ShaderIncludeResolver Class Reference

Resolves #include directives in GLSL shader source. More...

#include <phosphor-shaders/include/PhosphorShaders/ShaderIncludeResolver.h>

Static Public Member Functions

static QString expandIncludes (const QString &source, const QString &currentFileDir, const QStringList &includePaths, QString *outError=nullptr, QStringList *outIncludedPaths=nullptr)
 Expand #include directives in source.
 

Static Public Attributes

static constexpr int MaxIncludeDepth = 10
 

Detailed Description

Resolves #include directives in GLSL shader source.

Supports:

  • #include "path" — search relative to current file's directory, then include paths
  • #include <path> — search only in include paths (e.g. global shaders dir)

Member Function Documentation

◆ expandIncludes()

static QString PhosphorShaders::ShaderIncludeResolver::expandIncludes ( const QString &  source,
const QString &  currentFileDir,
const QStringList &  includePaths,
QString *  outError = nullptr,
QStringList *  outIncludedPaths = nullptr 
)
static

Expand #include directives in source.

Parameters
sourceRaw shader source (may contain #include "..." or #include <...>)
currentFileDirDirectory of the file that contains source
includePathsDirectories to search for includes
outErrorIf non-null, set on error (file not found, depth exceeded)
outIncludedPathsIf non-null, appended with the canonical absolute path of every successfully-resolved include file. Lets callers fingerprint transitively-included headers (e.g. for cache invalidation) — without this, a cache keyed only on the top-level shader's mtime serves stale baked SPIR-V when an included header changes.
Returns
Expanded source, or empty string on error

Member Data Documentation

◆ MaxIncludeDepth

constexpr int PhosphorShaders::ShaderIncludeResolver::MaxIncludeDepth = 10
staticconstexpr

The documentation for this class was generated from the following file: