nCine::BinaryShaderCache class

Caches compiled OpenGL shader programs in binary form on disk.

Stores and retrieves linked shader program binaries (via glGetProgramBinary/glProgramBinary) so that shaders compiled in a previous run can be reloaded without recompiling. Cached binaries are keyed by shader name, a version stamp and a platform hash; binaries from other platforms can be pruned.

Constructors, destructors, conversion operators

BinaryShaderCache(StringView path)
BinaryShaderCache(const BinaryShaderCache&) deleted

Public functions

auto operator=(const BinaryShaderCache&) -> BinaryShaderCache& deleted
auto IsAvailable() const -> bool
Returns whether binary shaders are supported and the cache can be used.
auto GetPlatformHash() const -> std::uint64_t
Returns the hash value that identifies the current OpenGL platform.
auto GetCachedShaderPath(const char* shaderName) -> String
Returns the on-disk path of the cached binary for the specified shader.
auto LoadFromCache(const char* shaderName, std::uint64_t shaderVersion, GLShaderProgram* program, GLShaderProgram::Introspection introspection) -> bool
Loads a binary into the program from the cache, returning true on success.
auto SaveToCache(const char* shaderName, std::uint64_t shaderVersion, GLShaderProgram* program) -> bool
Saves the program binary to the cache, returning true on success.
auto Prune() -> std::uint32_t
Deletes all binary shaders that don't belong to this platform from the cache directory.
auto Clear() -> bool
Deletes all binary shaders from the cache directory.
auto Path() -> const StringView
Returns the current cache directory for binary shaders.
auto SetPath(StringView path) -> bool
Sets a new directory as the cache for binary shaders.