vcl/source/opengl/OpenGLContext.cxx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-)
New commits: commit 7d84e3e08bdd06474cb7d9ef681492be5999d345 Author: Tor Lillqvist <t...@collabora.com> Date: Mon Oct 19 09:55:57 2015 +0300 Speed up in-process caching of OpenGL shader programs It seems to be fairly CPU intensive to calculate the MD5 digest of shader program source code. But we don't need to use that to look up a corrresponding program in the run-time in-process cache anyway. The shader names are unique, so it is enough to use that as key. Change-Id: I8fd9f5f875be14a82cd53daf8a2ca72bfd23beb6 diff --git a/vcl/source/opengl/OpenGLContext.cxx b/vcl/source/opengl/OpenGLContext.cxx index c44b95b..f389f88 100644 --- a/vcl/source/opengl/OpenGLContext.cxx +++ b/vcl/source/opengl/OpenGLContext.cxx @@ -1651,20 +1651,28 @@ OpenGLProgram* OpenGLContext::GetProgram( const OUString& rVertexShader, const O { OpenGLZone aZone; - rtl::OString aKey = OpenGLHelper::GetDigest( rVertexShader, rFragmentShader, preamble ); - - if( !aKey.isEmpty() ) - { - ProgramCollection::iterator it = maPrograms.find( aKey ); + // We cache the shader programs in a per-process run-time cache + // based on only the names and the preamble. We don't expect + // shader source files to change during the lifetime of a + // LibreOffice process. + rtl::OString aNameBasedKey = OUStringToOString(rVertexShader + "+" + rFragmentShader, RTL_TEXTENCODING_UTF8) + "+" + preamble; + if( !aNameBasedKey.isEmpty() ) + { + ProgramCollection::iterator it = maPrograms.find( aNameBasedKey ); if( it != maPrograms.end() ) return it->second.get(); } + // Binary shader programs are cached persistently (between + // LibreOffice process instances) based on a hash of their source + // code, as the source code can and will change between + // LibreOffice versions even if the shader names don't change. + rtl::OString aPersistentKey = OpenGLHelper::GetDigest( rVertexShader, rFragmentShader, preamble ); std::shared_ptr<OpenGLProgram> pProgram = std::make_shared<OpenGLProgram>(); - if( !pProgram->Load( rVertexShader, rFragmentShader, preamble, aKey ) ) + if( !pProgram->Load( rVertexShader, rFragmentShader, preamble, aPersistentKey ) ) return NULL; - maPrograms.insert(std::make_pair(aKey, pProgram)); + maPrograms.insert(std::make_pair(aNameBasedKey, pProgram)); return pProgram.get(); } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits