|
Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
|
Shader manager maintains a structure of shader compilations. More...
#include <foray_shadermanager.hpp>
Classes | |
| struct | IncludeFile |
| Represents a file included (nested) in a shader compilation, but not compiled by itself. More... | |
| struct | ShaderCompilation |
| Represents a unique shader compilation (input source path + config => Spirv file) More... | |
Public Member Functions | |
| ShaderManager (core::Context *context=nullptr) | |
| uint64_t | CompileShader (osi::Utf8Path sourceFilePath, ShaderModule &shaderModule, const ShaderCompilerConfig &config={}, core::Context *context=nullptr) |
| Accesses sourceFilePath, scans for dependencies, compiles if necessary, loads into shaderModule. | |
| uint64_t | CompileShader (osi::Utf8Path sourceFilePath, ShaderModule *shaderModule, const ShaderCompilerConfig &config={}, core::Context *context=nullptr) |
| Accesses sourceFilePath, scans for dependencies, compiles if necessary, loads into shaderModule. | |
| virtual bool | CheckAndUpdateShaders (std::unordered_set< uint64_t > &out_recompiled) |
| Checks and updates shader compilations for source code changes. | |
| ShaderManager ()=default | |
| virtual bool | CallGlslCompiler (std::string_view args) |
| Calls glslc in path on linux, glslc.exe (derived from VULKAN_SDK environment variable) on windows. | |
Protected Types | |
| enum class | ECompileCheckResult { UpToDate , MissingInput , NeedsRecompile } |
| using | WriteTimeLookup = std::unordered_map< osi::Utf8Path, std::filesystem::file_time_type > |
| maps files to last write times | |
Protected Member Functions | |
| virtual uint64_t | MakeHash (std::string_view absoluteUniqueSourceFilePath, const ShaderCompilerConfig &config) |
| Calculates a unique hash based on source file path and config. | |
| void | DiscoverIncludes (ShaderCompilation *compilation) |
| Discover and register all includes for a shader compilation. | |
| IncludeFile * | RecursivelyProcessInclude (const osi::Utf8Path &path, const std::vector< osi::Utf8Path > &extraIncludeDirs) |
| Create or return an include file. Recursively processes #include directives to resolve nested includes. | |
Static Protected Member Functions | |
| static std::filesystem::file_time_type | GetWriteTime (const osi::Utf8Path &path, WriteTimeLookup &writeTimeLookup) |
| Get last write time. | |
Protected Attributes | |
| core::Context * | mContext = nullptr |
| Context used for initialization of shader modules. | |
| std::unordered_map< uint64_t, std::unique_ptr< ShaderCompilation > > | mTrackedCompilations |
| Map of shader compilation keys to tracked compilations. | |
| std::unordered_map< osi::Utf8Path, std::unique_ptr< IncludeFile > > | mTrackedIncludeFiles |
| Map of include file paths to include file structs. | |
Shader manager maintains a structure of shader compilations.
When registering a shader file compilation via CompileShader(..):
|
protected |
maps files to last write times
|
strongprotected |
|
inlineexplicit |
| context | If set, is used as fallback for CompileShader() context argument |
|
default |
|
virtual |
Calls glslc in path on linux, glslc.exe (derived from VULKAN_SDK environment variable) on windows.
| args | Arguments are passed as follows: GLSLC_EXECUTABLE –target-spv=spv1.5 OPTIMIZE ARGS (OPTIMIZE = -O0 for DEBUG, -O for RELEASE CMake targets) |
|
virtual |
Checks and updates shader compilations for source code changes.
Will check all tracked shader files for modifications and recompile the shader compilations accordingly
| out_recompiled | Output set for shader compilation keys which have been recompiled |
| uint64_t foray::core::ShaderManager::CompileShader | ( | osi::Utf8Path | sourceFilePath, |
| ShaderModule & | shaderModule, | ||
| const ShaderCompilerConfig & | config = {}, |
||
| core::Context * | context = nullptr |
||
| ) |
Accesses sourceFilePath, scans for dependencies, compiles if necessary, loads into shaderModule.
| sourceFilePath | Path to the shader source file |
| shaderModule | Output shadermodule to initialize |
| config | Configure compilation parameters |
| context | Context for initialization of ShaderModule. If set to nullptr, will use ShaderManager context |
| uint64_t foray::core::ShaderManager::CompileShader | ( | osi::Utf8Path | sourceFilePath, |
| ShaderModule * | shaderModule, | ||
| const ShaderCompilerConfig & | config = {}, |
||
| core::Context * | context = nullptr |
||
| ) |
Accesses sourceFilePath, scans for dependencies, compiles if necessary, loads into shaderModule.
| sourceFilePath | Path to the shader source file |
| shaderModule | Output shadermodule to initialize |
| config | Configure compilation parameters |
| context | Context for initialization of ShaderModule. If set to nullptr, will use ShaderManager context |
|
protected |
Discover and register all includes for a shader compilation.
|
staticprotected |
Get last write time.
| path | File path |
| writeTimeLookup | Lookup |
|
protectedvirtual |
Calculates a unique hash based on source file path and config.
|
protected |
Create or return an include file. Recursively processes #include directives to resolve nested includes.
| path | Absolute file path |
| extraIncludeDirs | Additional include dirs |
|
protected |
Context used for initialization of shader modules.
|
protected |
Map of shader compilation keys to tracked compilations.
|
protected |
Map of include file paths to include file structs.