| Index: gpu/command_buffer/service/memory_program_cache.h
|
| diff --git a/gpu/command_buffer/service/memory_program_cache.h b/gpu/command_buffer/service/memory_program_cache.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..cc23049be51a44f4644269635c4bf909f45bb523
|
| --- /dev/null
|
| +++ b/gpu/command_buffer/service/memory_program_cache.h
|
| @@ -0,0 +1,89 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_program_cache_H_
|
| +#define GPU_COMMAND_BUFFER_SERVICE_MEMORY_program_cache_H_
|
| +
|
| +#include "base/hash_tables.h"
|
| +#include "gpu/command_buffer/service/program_cache.h"
|
| +#include "gpu/command_buffer/service/program_cache_lru_helper.h"
|
| +#include "gpu/command_buffer/service/shader_translator.h"
|
| +#include "net/disk_cache/disk_cache.h"
|
| +
|
| +namespace {
|
| +static const size_t kMaxMemoryCacheSizeBytes = 6*1024*1024;
|
| +typedef std::map<std::string, GLint> BindAttribMap;
|
| +} // anonymous namespace
|
| +
|
| +namespace gpu {
|
| +namespace gles2 {
|
| +
|
| +// Program cache that stores binaries completely in-memory
|
| +class GPU_EXPORT MemoryProgramCache : public ProgramCache {
|
| + public:
|
| + MemoryProgramCache()
|
| + : max_size_bytes_(kMaxMemoryCacheSizeBytes),
|
| + curr_size_bytes_(0) {}
|
| + virtual ~MemoryProgramCache();
|
| +
|
| + bool LoadLinkedProgram(
|
| + const GLuint program,
|
| + ShaderManager::ShaderInfo* shader_a,
|
| + ShaderManager::ShaderInfo* shader_b,
|
| + const BindAttribMap* bind_attrib_location_map) const;
|
| + void SaveLinkedProgram(
|
| + const GLuint program,
|
| + const ShaderManager::ShaderInfo* shader_a,
|
| + const ShaderManager::ShaderInfo* shader_b,
|
| + const BindAttribMap* bind_attrib_location_map);
|
| +
|
| + private:
|
| + void ClearBackend();
|
| +
|
| + struct StoreValue {
|
| + StoreValue() : length(0), format(0), data(NULL) { }
|
| + StoreValue(GLsizei _length,
|
| + GLenum _format,
|
| + const GLvoid* _data,
|
| + const char* _shader_0_hash,
|
| + const ShaderTranslator::VariableMap& _attrib_map_0,
|
| + const ShaderTranslator::VariableMap& _uniform_map_0,
|
| + const char* _shader_1_hash,
|
| + const ShaderTranslator::VariableMap& _attrib_map_1,
|
| + const ShaderTranslator::VariableMap& _uniform_map_1)
|
| + : length(_length),
|
| + format(_format),
|
| + data(_data),
|
| + shader_0_hash(_shader_0_hash, kHashLength),
|
| + attrib_map_0(_attrib_map_0),
|
| + uniform_map_0(_uniform_map_0),
|
| + shader_1_hash(_shader_1_hash, kHashLength),
|
| + attrib_map_1(_attrib_map_1),
|
| + uniform_map_1(_uniform_map_1) { }
|
| + GLsizei length;
|
| + GLenum format;
|
| + const GLvoid* data;
|
| + std::string shader_0_hash;
|
| + ShaderTranslator::VariableMap attrib_map_0;
|
| + ShaderTranslator::VariableMap uniform_map_0;
|
| + std::string shader_1_hash;
|
| + ShaderTranslator::VariableMap attrib_map_1;
|
| + ShaderTranslator::VariableMap uniform_map_1;
|
| + };
|
| +
|
| + typedef base::hash_map<std::string,
|
| + StoreValue> StoreMap;
|
| +
|
| + const size_t max_size_bytes_;
|
| + size_t curr_size_bytes_;
|
| + StoreMap store_;
|
| + ProgramCacheLruHelper lru_helper_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(MemoryProgramCache);
|
| +};
|
| +
|
| +} // namespace gles2
|
| +} // namespace gpu
|
| +
|
| +#endif /* GPU_COMMAND_BUFFER_SERVICE_MEMORY_program_cache_H_ */
|
|
|