// // Copyright 2018 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. // // BlobCache: 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.
namespace egl
{ // 160-bit SHA-1 hash key used for hasing a program. BlobCache opts in using fixed keys for // simplicity and efficiency. static constexpr size_t kBlobCacheKeyLength = angle::base::kSHA1Length; using BlobCacheKey = std::array<uint8_t, kBlobCacheKeyLength>;
} // namespace egl
class BlobCache final : angle::NonCopyable
{ public: // 160-bit SHA-1 hash key used for hasing a program. BlobCache opts in using fixed keys for // simplicity and efficiency. static constexpr size_t kKeyLength = kBlobCacheKeyLength; using Key = BlobCacheKey; class Value
{ public:
Value() : mPtr(nullptr), mSize(0) {}
Value(const uint8_t *ptr, size_t sz) : mPtr(ptr), mSize(sz) {}
// A very basic struct to hold the pointer and size together. The objects of this class // don't own the memory. const uint8_t *data() { return mPtr; }
size_t size() { return mSize; }
// Store a key-blob pair in the cache. If application callbacks are set, the application cache // will be used. Otherwise the value is cached in this object. void put(const BlobCache::Key &key, angle::MemoryBuffer &&value);
// Store a key-blob pair in the cache, but compress the blob before insertion. Returns false if // compression fails, returns true otherwise. bool compressAndPut(const BlobCache::Key &key,
angle::MemoryBuffer &&uncompressedValue,
size_t *compressedSize);
// Store a key-blob pair in the application cache, only if application callbacks are set. void putApplication(const BlobCache::Key &key, const angle::MemoryBuffer &value);
// Store a key-blob pair in the cache without making callbacks to the application. This is used // to repopulate this object's cache on startup without generating callback calls. void populate(const BlobCache::Key &key,
angle::MemoryBuffer &&value,
CacheSource source = CacheSource::Disk);
// Check if the cache contains the blob corresponding to this key. If application callbacks are // set, those will be used. Otherwise they key is looked up in this object's cache.
[[nodiscard]] bool get(angle::ScratchBuffer *scratchBuffer, const BlobCache::Key &key,
BlobCache::Value *valueOut,
size_t *bufferSizeOut);
// For querying the contents of the cache.
[[nodiscard]] bool getAt(size_t index, const BlobCache::Key **keyOut,
BlobCache::Value *valueOut);
private: // This internal cache is used only if the application is not providing caching callbacks using CacheEntry = std::pair<angle::MemoryBuffer, CacheSource>;
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.