Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Side by Side Diff: gpu/command_buffer/service/memory_program_cache.h

Issue 10797055: gpu in-memory program cache implementation with a memory limit + lru eviction. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: nit fixes Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_
7
8 #include <map>
9 #include <string>
10
11 #include "base/hash_tables.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "gpu/command_buffer/service/program_cache.h"
15 #include "gpu/command_buffer/service/program_cache_lru_helper.h"
16 #include "gpu/command_buffer/service/shader_translator.h"
17
18 namespace gpu {
19 namespace gles2 {
20
21 // Program cache that stores binaries completely in-memory
22 class GPU_EXPORT MemoryProgramCache : public ProgramCache {
23 public:
24 static const size_t kDefaultMaxProgramCacheMemoryBytes = 6 * 1024 * 1024;
25
26 MemoryProgramCache();
27 explicit MemoryProgramCache(const size_t max_cache_size_bytes);
28 virtual ~MemoryProgramCache();
29
30 virtual ProgramLoadResult LoadLinkedProgram(
31 GLuint program,
32 ShaderManager::ShaderInfo* shader_a,
33 ShaderManager::ShaderInfo* shader_b,
34 const LocationMap* bind_attrib_location_map) const OVERRIDE;
35 virtual void SaveLinkedProgram(
36 GLuint program,
37 const ShaderManager::ShaderInfo* shader_a,
38 const ShaderManager::ShaderInfo* shader_b,
39 const LocationMap* bind_attrib_location_map) OVERRIDE;
40
41 private:
42 virtual void ClearBackend() OVERRIDE;
43
44 struct ProgramCacheValue : public base::RefCounted<ProgramCacheValue> {
45 public:
46 ProgramCacheValue(GLsizei _length,
47 GLenum _format,
48 const char* _data,
49 const char* _shader_0_hash,
50 const ShaderTranslator::VariableMap& _attrib_map_0,
51 const ShaderTranslator::VariableMap& _uniform_map_0,
52 const char* _shader_1_hash,
53 const ShaderTranslator::VariableMap& _attrib_map_1,
54 const ShaderTranslator::VariableMap& _uniform_map_1);
55 const GLsizei length;
56 const GLenum format;
57 const scoped_array<const char> data;
58 const std::string shader_0_hash;
59 const ShaderTranslator::VariableMap attrib_map_0;
60 const ShaderTranslator::VariableMap uniform_map_0;
61 const std::string shader_1_hash;
62 const ShaderTranslator::VariableMap attrib_map_1;
63 const ShaderTranslator::VariableMap uniform_map_1;
64
65 protected:
66 friend class base::RefCounted<ProgramCacheValue>;
67
68 ~ProgramCacheValue();
69
70 private:
71 DISALLOW_COPY_AND_ASSIGN(ProgramCacheValue);
72 };
73
74 typedef base::hash_map<std::string,
75 scoped_refptr<ProgramCacheValue> > StoreMap;
76
77 const size_t max_size_bytes_;
78 size_t curr_size_bytes_;
79 StoreMap store_;
80 ProgramCacheLruHelper eviction_helper_;
81
82 DISALLOW_COPY_AND_ASSIGN(MemoryProgramCache);
83 };
84
85 } // namespace gles2
86 } // namespace gpu
87
88 #endif // GPU_COMMAND_BUFFER_SERVICE_MEMORY_PROGRAM_CACHE_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | gpu/command_buffer/service/memory_program_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698