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

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

Issue 10534173: GPU Program Caching (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Style fixes, thorough tests 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } 56 }
57 57
58 const std::string* translated_source() const { 58 const std::string* translated_source() const {
59 return translated_source_.get(); 59 return translated_source_.get();
60 } 60 }
61 61
62 void SetStatus( 62 void SetStatus(
63 bool valid, const char* log, 63 bool valid, const char* log,
64 ShaderTranslatorInterface* translator); 64 ShaderTranslatorInterface* translator);
65 65
66 void set_pending_compilation(bool pending_cache_miss_compilation);
67
66 const VariableInfo* GetAttribInfo(const std::string& name) const; 68 const VariableInfo* GetAttribInfo(const std::string& name) const;
67 const VariableInfo* GetUniformInfo(const std::string& name) const; 69 const VariableInfo* GetUniformInfo(const std::string& name) const;
68 70
69 // If the original_name is not found, return NULL. 71 // If the original_name is not found, return NULL.
70 const std::string* GetAttribMappedName( 72 const std::string* GetAttribMappedName(
71 const std::string& original_name) const; 73 const std::string& original_name) const;
72 74
73 const std::string* log_info() const { 75 const std::string* log_info() const {
74 return log_info_.get(); 76 return log_info_.get();
75 } 77 }
76 78
77 bool IsValid() const { 79 bool IsValid() const {
78 return valid_; 80 return valid_;
79 } 81 }
80 82
81 bool IsDeleted() const { 83 bool IsDeleted() const {
82 return service_id_ == 0; 84 return service_id_ == 0;
83 } 85 }
84 86
85 bool InUse() const { 87 bool InUse() const {
86 DCHECK_GE(use_count_, 0); 88 DCHECK_GE(use_count_, 0);
87 return use_count_ != 0; 89 return use_count_ != 0;
88 } 90 }
89 91
92 bool IsPendingCacheMissCompilation() const {
93 return pending_cache_miss_compilation_;
94 }
95
96 // Used by shader cache.
97 const ShaderTranslator::VariableMap& attrib_map() const {
98 return attrib_map_;
99 }
100
101 // Used by shader cache.
102 const ShaderTranslator::VariableMap& uniform_map() const {
103 return uniform_map_;
104 }
105
106 // Used by shader cache.
107 void SetAttribMap(const ShaderTranslator::VariableMap& attrib_map) {
108 // copied because cache might be cleared
109 attrib_map_ = ShaderTranslator::VariableMap(attrib_map);
110 }
111
112 // Used by shader cache.
113 void SetUniformMap(const ShaderTranslator::VariableMap& uniform_map) {
114 // copied because cache might be cleared
115 uniform_map_ = ShaderTranslator::VariableMap(uniform_map);
116 }
117
90 private: 118 private:
91 typedef ShaderTranslator::VariableMap VariableMap; 119 typedef ShaderTranslator::VariableMap VariableMap;
92 120
93 friend class base::RefCounted<ShaderInfo>; 121 friend class base::RefCounted<ShaderInfo>;
94 friend class ShaderManager; 122 friend class ShaderManager;
95 123
96 ShaderInfo(GLuint service_id, GLenum shader_type); 124 ShaderInfo(GLuint service_id, GLenum shader_type);
97 ~ShaderInfo(); 125 ~ShaderInfo();
98 126
99 void IncUseCount(); 127 void IncUseCount();
(...skipping 15 matching lines...) Expand all
115 143
116 // The translated shader source. 144 // The translated shader source.
117 scoped_ptr<std::string> translated_source_; 145 scoped_ptr<std::string> translated_source_;
118 146
119 // The shader translation log. 147 // The shader translation log.
120 scoped_ptr<std::string> log_info_; 148 scoped_ptr<std::string> log_info_;
121 149
122 // The type info when the shader was last compiled. 150 // The type info when the shader was last compiled.
123 VariableMap attrib_map_; 151 VariableMap attrib_map_;
124 VariableMap uniform_map_; 152 VariableMap uniform_map_;
153
154 // If compilation was delayed for possible cache hit
155 bool pending_cache_miss_compilation_;
125 }; 156 };
126 157
127 ShaderManager(); 158 ShaderManager();
128 ~ShaderManager(); 159 ~ShaderManager();
129 160
130 // Must call before destruction. 161 // Must call before destruction.
131 void Destroy(bool have_context); 162 void Destroy(bool have_context);
132 163
133 // Creates a shader info for the given shader ID. 164 // Creates a shader info for the given shader ID.
134 ShaderInfo* CreateShaderInfo( 165 ShaderInfo* CreateShaderInfo(
(...skipping 28 matching lines...) Expand all
163 void RemoveShaderInfoIfUnused(ShaderInfo* info); 194 void RemoveShaderInfoIfUnused(ShaderInfo* info);
164 195
165 DISALLOW_COPY_AND_ASSIGN(ShaderManager); 196 DISALLOW_COPY_AND_ASSIGN(ShaderManager);
166 }; 197 };
167 198
168 } // namespace gles2 199 } // namespace gles2
169 } // namespace gpu 200 } // namespace gpu
170 201
171 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_ 202 #endif // GPU_COMMAND_BUFFER_SERVICE_SHADER_MANAGER_H_
172 203
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698