Container for the full on-disk shader cache file. More...
Public Member Functions | |
| bool | load (const std::string &path) |
| Deserialise the shader cache from a binary file. | |
| bool | save (const std::string &path) const |
| Serialise the entire shader cache to a binary file. | |
Public Attributes | |
| bool | dual_mode = false |
| std::vector< ShaderCacheEntry > | entries |
| std::string | gl_renderer |
| std::string | gl_version |
Static Public Attributes | |
| static constexpr uint32_t | CACHE_MAGIC = 0x53484452 |
| File magic: "SHDR". | |
| static constexpr uint32_t | CACHE_VERSION = 4 |
| Current format version. | |
Container for the full on-disk shader cache file.
The binary file format is: [MAGIC][VERSION][gl_renderer][gl_version][dual_mode][count][entries...]
If the GL renderer or driver version changes, the cache is invalidated.
Definition at line 2595 of file ACMX2/acmx.cpp.
|
inline |
Deserialise the shader cache from a binary file.
Validates the magic number and version before reading. If either does not match (e.g. cache was written by an older version or a different application) the method returns false and leaves the object in an indeterminate state—callers should discard it.
The layout mirrors save(): magic, version, renderer string, GL version string, dual_mode flag, entry count, then each entry.
| path | Filesystem path of the cache file to read. |
Definition at line 2693 of file ACMX2/acmx.cpp.
References CACHE_MAGIC, CACHE_VERSION, ComputeUnavailable, dual_mode, entries, gl_renderer, and gl_version.
Referenced by ShaderLibrary::loadFromCache().
|
inline |
Serialise the entire shader cache to a binary file.
File layout (all values little-endian, no padding):
| Offset | Field |
|---|---|
| 0 | uint32 CACHE_MAGIC |
| 4 | uint32 CACHE_VERSION |
| 8 | string gl_renderer |
| string gl_version | |
| bool dual_mode | |
| uint32 entry_count | |
| entries… |
Each string is written as a uint32 length followed by raw bytes. Each entry contains: shader_name (string), kind (uint8), failed (uint8), source_hash (uint64), format_2d (GLenum), binary_2d (uint32 size + raw bytes), format_3d (GLenum), binary_3d (uint32 size + raw bytes).
| path | Filesystem path for the output file (e.g. library/.shader_cache). |
Definition at line 2626 of file ACMX2/acmx.cpp.
References CACHE_MAGIC, CACHE_VERSION, dual_mode, entries, gl_renderer, and gl_version.
Referenced by ShaderLibrary::buildShaderCache(), and ShaderLibrary::loadFromCache().
|
staticconstexpr |
File magic: "SHDR".
Definition at line 2596 of file ACMX2/acmx.cpp.
|
staticconstexpr |
Current format version.
Definition at line 2597 of file ACMX2/acmx.cpp.
| bool ShaderCache::dual_mode = false |
Definition at line 2600 of file ACMX2/acmx.cpp.
Referenced by ShaderLibrary::buildShaderCache(), load(), ShaderLibrary::loadFromCache(), and save().
| std::vector<ShaderCacheEntry> ShaderCache::entries |
Definition at line 2601 of file ACMX2/acmx.cpp.
Referenced by ShaderLibrary::buildShaderCache(), load(), ShaderLibrary::loadFromCache(), and save().
| std::string ShaderCache::gl_renderer |
Definition at line 2598 of file ACMX2/acmx.cpp.
Referenced by ShaderLibrary::buildShaderCache(), load(), ShaderLibrary::loadFromCache(), and save().
| std::string ShaderCache::gl_version |
Definition at line 2599 of file ACMX2/acmx.cpp.
Referenced by ShaderLibrary::buildShaderCache(), load(), ShaderLibrary::loadFromCache(), and save().