diff options
author | Rye Mutt <rye@alchemyviewer.org> | 2023-05-17 19:30:27 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 18:30:27 -0500 |
commit | 87bda552688bb38fe255cc7e6069c1be6ac20834 (patch) | |
tree | 0630569c338cf9c88627f0a6e10cd68bb66691cb /indra/llrender/llshadermgr.h | |
parent | 446d0cbf7f19e459b90a06f4153b3f7f9df6f09a (diff) |
Add a binary cache for compiled shaders using glProgramBinary (#216)
* Add a binary cache for compiled shaders using glProgramBinary
* Add additional sanity checking to shader binary save and load, hook up cache clear and menu option
* Fix default init of shader cache data struct and clear gl errors before glGetError calls
---------
Co-authored-by: RunitaiLinden <davep@lindenlab.com>
Diffstat (limited to 'indra/llrender/llshadermgr.h')
-rw-r--r-- | indra/llrender/llshadermgr.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index ec3455952b..4a2241a9d6 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -295,7 +295,7 @@ public: void dumpShaderSource(U32 shader_code_count, GLchar** shader_code_text); BOOL linkProgramObject(GLuint obj, BOOL suppress_errors = FALSE); BOOL validateProgramObject(GLuint obj); - GLuint loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::unordered_map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1); + GLuint loadShaderFile(const std::string& filename, S32 & shader_level, GLenum type, std::map<std::string, std::string>* defines = NULL, S32 texture_index_channels = -1); // Implemented in the application to actually point to the shader directory. virtual std::string getShaderDirPrefix(void) = 0; // Pure Virtual @@ -303,6 +303,13 @@ public: // Implemented in the application to actually update out of date uniforms for a particular shader virtual void updateShaderUniforms(LLGLSLShader * shader) = 0; // Pure Virtual + void initShaderCache(bool enabled, const LLUUID& old_cache_version, const LLUUID& current_cache_version); + void clearShaderCache(); + void persistShaderCacheMetadata(); + + bool loadCachedProgramBinary(LLGLSLShader* shader); + bool saveCachedProgramBinary(LLGLSLShader* shader); + public: // Map of shader names to compiled std::map<std::string, GLuint> mVertexShaderObjects; @@ -313,8 +320,16 @@ public: std::vector<std::string> mReservedUniforms; - //preprocessor definitions (name/value) - std::map<std::string, std::string> mDefinitions; + struct ProgramBinaryData + { + GLsizei mBinaryLength = 0; + GLenum mBinaryFormat = 0; + F32 mLastUsedTime = 0.0; + }; + std::map<LLUUID, ProgramBinaryData> mShaderBinaryCache; + bool mShaderCacheInitialized = false; + bool mShaderCacheEnabled = false; + std::string mShaderCacheDir; protected: |