diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h')
-rw-r--r-- | gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h b/gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h new file mode 100644 index 0000000000..464201d4c7 --- /dev/null +++ b/gfx/angle/checkout/src/libANGLE/MemoryShaderCache.h @@ -0,0 +1,60 @@ +// +// Copyright 2022 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. +// +// MemoryShaderCache: Stores compiled shaders 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. + +#ifndef LIBANGLE_MEMORY_SHADER_CACHE_H_ +#define LIBANGLE_MEMORY_SHADER_CACHE_H_ + +#include <array> + +#include "GLSLANG/ShaderLang.h" +#include "common/MemoryBuffer.h" +#include "libANGLE/BlobCache.h" +#include "libANGLE/Error.h" + +namespace gl +{ +class Context; +class Shader; +class ShaderState; +class ShCompilerInstance; + +class MemoryShaderCache final : angle::NonCopyable +{ + public: + explicit MemoryShaderCache(egl::BlobCache &blobCache); + ~MemoryShaderCache(); + + // Helper method that serializes a shader. + angle::Result putShader(const Context *context, + const egl::BlobCache::Key &shaderHash, + const Shader *shader); + + // Check the cache, and deserialize and load the shader if found. Evict existing hash if load + // fails. + angle::Result getShader(const Context *context, + Shader *shader, + const ShCompileOptions &compileOptions, + const ShCompilerInstance &compilerInstance, + egl::BlobCache::Key *hashOut); + + // Empty the cache. + void clear(); + + // Returns the maximum cache size in bytes. + size_t maxSize() const; + + private: + egl::BlobCache &mBlobCache; + + std::mutex mHistogramMutex; +}; + +} // namespace gl + +#endif // LIBANGLE_MEMORY_SHADER_CACHE_H_ |