#include "gpu/command_buffer/service/program_cache.h"
#include <stddef.h>
#include <memory>
#include <string>
#include "base/containers/contains.h"
#include "base/containers/heap_array.h"
#include "base/containers/span_writer.h"
#include "base/hash/hash.h"
#include "base/metrics/histogram_macros.h"
#include "gpu/command_buffer/service/shader_manager.h"
#include "third_party/angle/src/common/angle_version_info.h"
namespace gpu {
namespace gles2 {
ProgramCache::ScopedCacheUse::ScopedCacheUse(ProgramCache* cache,
CacheProgramCallback callback)
: … { … }
ProgramCache::ScopedCacheUse::~ScopedCacheUse() { … }
ProgramCache::ProgramCache(size_t max_cache_size_bytes)
: … { … }
ProgramCache::~ProgramCache() = default;
void ProgramCache::Clear() { … }
bool ProgramCache::HasSuccessfullyCompiledShader(
const std::string& shader_signature) const { … }
ProgramCache::LinkedProgramStatus ProgramCache::GetLinkedProgramStatus(
const std::string& shader_signature_a,
const std::string& shader_signature_b,
const std::map<std::string, GLint>* bind_attrib_location_map,
const std::vector<std::string>& transform_feedback_varyings,
GLenum transform_feedback_buffer_mode) const { … }
void ProgramCache::LinkedProgramCacheSuccess(
const std::string& shader_signature_a,
const std::string& shader_signature_b,
const LocationMap* bind_attrib_location_map,
const std::vector<std::string>& transform_feedback_varyings,
GLenum transform_feedback_buffer_mode) { … }
void ProgramCache::LinkedProgramCacheSuccess(const Hash& program_hash) { … }
void ProgramCache::CompiledShaderCacheSuccess(const Hash& shader_hash) { … }
void ProgramCache::ComputeShaderHash(std::string_view str, Hash& result) const { … }
void ProgramCache::Evict(const Hash& program_hash,
const Hash& shader_0_hash,
const Hash& shader_1_hash) { … }
namespace {
size_t CalculateMapSize(const std::map<std::string, GLint>* map) { … }
size_t CalculateVaryingsSize(const std::vector<std::string>& varyings) { … }
}
void ProgramCache::ComputeProgramHash(
HashView hashed_shader_0,
HashView hashed_shader_1,
const std::map<std::string, GLint>* bind_attrib_location_map,
const std::vector<std::string>& transform_feedback_varyings,
GLenum transform_feedback_buffer_mode,
Hash& result) const { … }
void ProgramCache::HandleMemoryPressure(
base::MemoryPressureListener::MemoryPressureLevel memory_pressure_level) { … }
size_t ProgramCache::HashHasher::operator()(const Hash& hash) const { … }
}
}