// // Copyright 2017 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // MemoryProgramCache: Stores compiled and linked programs in memory so they don't // always have to be re-compiled. Can be used in conjunction with the platform // layer to warm up the cache from disk.
// Include zlib first, otherwise FAR gets defined elsewhere. #define USE_SYSTEM_ZLIB #include"compression_utils_portable.h"
void MemoryProgramCache::ComputeHash(const Context *context, const Program *program,
egl::BlobCache::Key *hashOut)
{ // Compute the program hash. Start with the shader hashes and resource strings.
HashStream hashStream; for (ShaderType shaderType : AllShaderTypes())
{
hashStream << program->getAttachedShader(shaderType);
}
// Add some ANGLE metadata and Context properties, such as version and back-end.
hashStream << angle::GetANGLECommitHash() << context->getClientMajorVersion()
<< context->getClientMinorVersion() << context->getString(GL_RENDERER);
// Include the status of FrameCapture, which adds source strings to the binary
hashStream << context->getShareGroup()->getFrameCaptureShared()->enabled();
case egl::BlobCache::GetAndDecompressResult::DecompressFailure:
ANGLE_PERF_WARNING(context->getState().getDebug(), GL_DEBUG_SEVERITY_LOW, "Error decompressing program binary data fetched from cache."); return angle::Result::Incomplete;
case egl::BlobCache::GetAndDecompressResult::GetSuccess:
angle::Result result =
program->loadBinary(context, GL_PROGRAM_BINARY_ANGLE, uncompressedData.data(), static_cast<int>(uncompressedData.size()));
ANGLE_TRY(result);
if (result == angle::Result::Continue) return angle::Result::Continue;
// Cache load failed, evict
ANGLE_PERF_WARNING(context->getState().getDebug(), GL_DEBUG_SEVERITY_LOW, "Failed to load program binary from cache.");
remove(*hashOut);
{
std::scoped_lock<std::mutex> lock(mBlobCache.getMutex()); // TODO: http://anglebug.com/7568 // This was a workaround for Chrome until it added support for EGL_ANDROID_blob_cache, // tracked by http://anglebug.com/2516. This issue has since been closed, but removing this // still causes a test failure. auto *platform = ANGLEPlatformCurrent();
platform->cacheProgram(platform, programHash, compressedData.size(), compressedData.data());
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.