#include "gpu/command_buffer/service/memory_program_cache.h"
#include <stddef.h>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/metrics/histogram_functions.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/checked_math.h"
#include "base/strings/string_number_conversions.h"
#include "base/system/sys_info.h"
#include "build/build_config.h"
#include "gpu/command_buffer/common/constants.h"
#include "gpu/command_buffer/common/shm_count.h"
#include "gpu/command_buffer/service/disk_cache_proto.pb.h"
#include "gpu/command_buffer/service/gl_utils.h"
#include "gpu/command_buffer/service/gles2_cmd_decoder.h"
#include "gpu/command_buffer/service/shader_manager.h"
#include "gpu/config/gpu_preferences.h"
#include "third_party/zlib/zlib.h"
#include "ui/gl/gl_bindings.h"
namespace gpu {
namespace gles2 {
namespace {
template <typename T, size_t N>
std::array<std::remove_const_t<T>, N> SpanToArray(base::span<T, N> s) { … }
void FillShaderVariableProto(
ShaderVariableProto* proto, const sh::ShaderVariable& variable) { … }
void FillShaderAttributeProto(
ShaderAttributeProto* proto, const sh::Attribute& attrib) { … }
void FillShaderUniformProto(
ShaderUniformProto* proto, const sh::Uniform& uniform) { … }
void FillShaderVaryingProto(
ShaderVaryingProto* proto, const sh::Varying& varying) { … }
void FillShaderOutputVariableProto(ShaderOutputVariableProto* proto,
const sh::OutputVariable& attrib) { … }
void FillShaderInterfaceBlockFieldProto(
ShaderInterfaceBlockFieldProto* proto,
const sh::InterfaceBlockField& interfaceBlockField) { … }
void FillShaderInterfaceBlockProto(ShaderInterfaceBlockProto* proto,
const sh::InterfaceBlock& interfaceBlock) { … }
void FillShaderProto(ShaderProto* proto,
ProgramCache::HashView sha,
const Shader* shader) { … }
void RetrieveShaderVariableInfo(
const ShaderVariableProto& proto, sh::ShaderVariable* variable) { … }
void RetrieveShaderAttributeInfo(
const ShaderAttributeProto& proto, AttributeMap* map) { … }
void RetrieveShaderUniformInfo(
const ShaderUniformProto& proto, UniformMap* map) { … }
void RetrieveShaderVaryingInfo(
const ShaderVaryingProto& proto, VaryingMap* map) { … }
void RetrieveShaderOutputVariableInfo(const ShaderOutputVariableProto& proto,
OutputVariableList* list) { … }
void RetrieveShaderInterfaceBlockFieldInfo(
const ShaderInterfaceBlockFieldProto& proto,
sh::InterfaceBlockField* interface_block_field) { … }
void RetrieveShaderInterfaceBlockInfo(const ShaderInterfaceBlockProto& proto,
InterfaceBlockMap* map) { … }
void RunShaderCallback(DecoderClient* client,
GpuProgramProto* proto,
ProgramCache::HashView program_sha) { … }
bool ProgramBinaryExtensionsAvailable() { … }
std::vector<uint8_t> CompressData(const std::vector<uint8_t>& data) { … }
std::vector<uint8_t> DecompressData(const std::vector<uint8_t>& data,
size_t decompressed_size,
size_t max_size_bytes) { … }
bool CompressProgramBinaries() { … }
}
MemoryProgramCache::MemoryProgramCache(
size_t max_cache_size_bytes,
bool disable_gpu_shader_disk_cache,
bool disable_program_caching_for_transform_feedback,
GpuProcessShmCount* use_shader_cache_shm_count)
: … { … }
MemoryProgramCache::~MemoryProgramCache() = default;
void MemoryProgramCache::ClearBackend() { … }
ProgramCache::ProgramLoadResult MemoryProgramCache::LoadLinkedProgram(
GLuint program,
Shader* shader_a,
Shader* shader_b,
const LocationMap* bind_attrib_location_map,
const std::vector<std::string>& transform_feedback_varyings,
GLenum transform_feedback_buffer_mode,
DecoderClient* client) { … }
void MemoryProgramCache::SaveLinkedProgram(
GLuint program,
const Shader* shader_a,
const Shader* shader_b,
const LocationMap* bind_attrib_location_map,
const std::vector<std::string>& transform_feedback_varyings,
GLenum transform_feedback_buffer_mode,
DecoderClient* client) { … }
void MemoryProgramCache::LoadProgram(const std::string& key,
const std::string& program) { … }
size_t MemoryProgramCache::Trim(size_t limit) { … }
MemoryProgramCache::ProgramCacheValue::ProgramCacheValue(
GLenum format,
std::vector<uint8_t> data,
bool is_compressed,
GLsizei decompressed_length,
HashView program_hash,
HashView shader_0_hash,
const AttributeMap& attrib_map_0,
const UniformMap& uniform_map_0,
const VaryingMap& varying_map_0,
const OutputVariableList& output_variable_list_0,
const InterfaceBlockMap& interface_block_map_0,
HashView shader_1_hash,
const AttributeMap& attrib_map_1,
const UniformMap& uniform_map_1,
const VaryingMap& varying_map_1,
const OutputVariableList& output_variable_list_1,
const InterfaceBlockMap& interface_block_map_1,
MemoryProgramCache* program_cache)
: … { … }
MemoryProgramCache::ProgramCacheValue::~ProgramCacheValue() { … }
}
}