Developer Documentation
|
Cache for shaders. More...
#include <ACG/GL/ShaderCache.hh>
Classes | |
struct | CacheEntry |
Public Member Functions | |
virtual | ~ShaderCache () |
Destructor. | |
GLSL::Program * | getProgram (const ShaderGenDesc *_desc, const std::vector< unsigned int > &_mods) |
Query a dynamically generated program from cache. More... | |
GLSL::Program * | getProgram (const ShaderGenDesc *_desc, const std::vector< unsigned int > *_mods) |
Query a dynamically generated program from cache. More... | |
GLSL::Program * | getProgram (const ShaderGenDesc *_desc) |
Query a dynamically generated program from cache. More... | |
GLSL::Program * | getProgram (const char *_vertexShaderFile, const char *_tessControlShaderFile, const char *_tessEvalShaderFile, const char *_geometryShaderFile, const char *_fragmentShaderFile, QStringList *_macros=0, bool _verbose=true) |
Query a static shader program from cache. More... | |
GLSL::Program * | getProgram (const char *_vertexShaderFile, const char *_fragmentShaderFile, QStringList *_macros=0, bool _verbose=true) |
Query a static shader program from cache. More... | |
GLSL::Program * | getComputeProgram (const char *_computeShaderFile, QStringList *_macros=0, bool _verbose=true) |
Query a static compute shader program from cache. More... | |
void | clearCache () |
Delete all cached shaders. | |
void | setTimeCheck (bool _on) |
enable or disable checking of the time step of each file More... | |
bool | getTimeCheck () |
void | setDebugOutputDir (const char *_outputDir) |
Enable debug output of generated shaders to specified directory. | |
Static Public Member Functions | |
static ShaderCache * | getInstance () |
Return instance of the ShaderCache singleton. More... | |
Protected Types | |
typedef std::list< std::pair < CacheEntry, GLSL::Program * > > | CacheList |
Protected Member Functions | |
bool | compareTimeStamp (const CacheEntry *_a, const CacheEntry *_b) |
Returns true, if the shaders have the timestamp. | |
int | compareShaderGenDescs (const CacheEntry *_a, const CacheEntry *_b) |
Returns true, if the shaders are not equal. | |
Protected Attributes | |
CacheList | cache_ |
cache containing dynamic shaders from ShaderProgGenerator | |
CacheList | cacheStatic_ |
cache containing static shaders loaded from files (separate from dynamic cache to reduce access time) | |
CacheList | cacheComputeShaders_ |
cache for static compute shaders | |
bool | timeCheck_ |
QString | dbgOutputDir_ |
output directory for shaders in dynamic cache | |
Cache for shaders.
This class provides a cache for shaders. You can query a GLSL::Program via getProgram by specifying a ShaderGenDesc. If the program has already been compiled, it is returned from the cache. Otherwise it will be compiled and linked, added to the cache and returned. This ensures, that the shader is not compiled and linked every time, it is used.
Definition at line 79 of file ShaderCache.hh.
GLSL::Program * ACG::ShaderCache::getComputeProgram | ( | const char * | _computeShaderFile, |
QStringList * | _macros = 0 , |
||
bool | _verbose = true |
||
) |
Query a static compute shader program from cache.
Can be used to load a shader and have external changes automatically applied by the timestamp watchdog. However, the program should be queried every time before using the program as it may have been deleted and recompiled in the meantime.
_computeShaderFile | relative (from shader directory) or absolute filename of vertex shader |
_macros | optional list of glsl preprocessor macros, which are added directly after the #version directive (example: "#define USE_METHOD 1", "#define METHOD_PARAM 0"...) |
_verbose | log or suppress error output |
Definition at line 447 of file ShaderCache.cc.
|
static |
Return instance of the ShaderCache singleton.
Definition at line 90 of file ShaderCache.cc.
GLSL::Program * ACG::ShaderCache::getProgram | ( | const ShaderGenDesc * | _desc, |
const std::vector< unsigned int > & | _mods | ||
) |
Query a dynamically generated program from cache.
_desc | Shader description |
_mods | Combination of active shader modifier ids |
Definition at line 108 of file ShaderCache.cc.
|
inline |
Query a dynamically generated program from cache.
_desc | Shader description |
_mods | Combination of active shader modifier ids |
Definition at line 107 of file ShaderCache.hh.
GLSL::Program * ACG::ShaderCache::getProgram | ( | const ShaderGenDesc * | _desc | ) |
Query a dynamically generated program from cache.
_desc | Shader description |
_mods | Combination of active shader modifier ids |
Definition at line 97 of file ShaderCache.cc.
GLSL::Program * ACG::ShaderCache::getProgram | ( | const char * | _vertexShaderFile, |
const char * | _tessControlShaderFile, | ||
const char * | _tessEvalShaderFile, | ||
const char * | _geometryShaderFile, | ||
const char * | _fragmentShaderFile, | ||
QStringList * | _macros = 0 , |
||
bool | _verbose = true |
||
) |
Query a static shader program from cache.
Can be used to load a shader and have external changes automatically applied by the timestamp watchdog. However, the program should be queried every time before using the program as it may have been deleted and recompiled in the meantime.
_vertexShaderFile | relative (from shader directory) or absolute filename of vertex shader |
_tessControlShaderFile | relative (from shader directory) or absolute filename of tessellation control shader, null accepted |
_tessEvalShaderFile | relative (from shader directory) or absolute filename of tessellation eval shader, null accepted |
_geometryShaderFile | relative (from shader directory) or absolute filename of geometry shader, null accepted |
_fragmentShaderFile | relative (from shader directory) or absolute filename of fragment shader |
_macros | optional list of glsl preprocessor macros, which are added directly after the #version directive (example: "#define USE_METHOD 1", "#define METHOD_PARAM 0"...) |
_verbose | log or suppress error output |
Definition at line 288 of file ShaderCache.cc.
GLSL::Program * ACG::ShaderCache::getProgram | ( | const char * | _vertexShaderFile, |
const char * | _fragmentShaderFile, | ||
QStringList * | _macros = 0 , |
||
bool | _verbose = true |
||
) |
Query a static shader program from cache.
Can be used to load a shader and have external changes automatically applied by the timestamp watchdog. However, the program should be queried every time before using the program as it may have been deleted and recompiled in the meantime.
_vertexShaderFile | relative (from shader directory) or absolute filename of vertex shader |
_fragmentShaderFile | relative (from shader directory) or absolute filename of fragment shader |
_macros | optional list of glsl preprocessor macros, which are added directly after the #version directive (example: "#define USE_METHOD 1", "#define METHOD_PARAM 0"...) |
_verbose | log or suppress error output |
Definition at line 442 of file ShaderCache.cc.
|
inline |
enable or disable checking of the time step of each file
Definition at line 177 of file ShaderCache.hh.