OLD | NEW |
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_PROGRAM_MANAGER_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 bool IsValid() const { | 137 bool IsValid() const { |
138 return valid_; | 138 return valid_; |
139 } | 139 } |
140 | 140 |
141 bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); | 141 bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); |
142 bool DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); | 142 bool DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); |
143 | 143 |
144 bool CanLink() const; | 144 bool CanLink() const; |
145 | 145 |
146 // Performs glLinkProgram and related activities. | 146 // Performs glLinkProgram and related activities. |
147 void Link(); | 147 bool Link(); |
148 | 148 |
149 // Performs glValidateProgram and related activities. | 149 // Performs glValidateProgram and related activities. |
150 void Validate(); | 150 void Validate(); |
151 | 151 |
152 const std::string* log_info() const { | 152 const std::string* log_info() const { |
153 return log_info_.get(); | 153 return log_info_.get(); |
154 } | 154 } |
155 | 155 |
156 bool InUse() const { | 156 bool InUse() const { |
157 DCHECK_GE(use_count_, 0); | 157 DCHECK_GE(use_count_, 0); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 | 204 |
205 // Resets the program. | 205 // Resets the program. |
206 void Reset(); | 206 void Reset(); |
207 | 207 |
208 // Updates the program info after a successful link. | 208 // Updates the program info after a successful link. |
209 void Update(); | 209 void Update(); |
210 | 210 |
211 // Updates the program log info from GL | 211 // Updates the program log info from GL |
212 void UpdateLogInfo(); | 212 void UpdateLogInfo(); |
213 | 213 |
| 214 // Clears all the uniforms. |
| 215 void ClearUniforms(std::vector<uint8>* zero_buffer); |
| 216 |
214 // If long attribate names are mapped during shader translation, call | 217 // If long attribate names are mapped during shader translation, call |
215 // glBindAttribLocation() again with the mapped names. | 218 // glBindAttribLocation() again with the mapped names. |
216 // This is called right before the glLink() call, but after shaders are | 219 // This is called right before the glLink() call, but after shaders are |
217 // translated. | 220 // translated. |
218 void ExecuteBindAttribLocationCalls(); | 221 void ExecuteBindAttribLocationCalls(); |
219 | 222 |
220 const UniformInfo* AddUniformInfo( | 223 const UniformInfo* AddUniformInfo( |
221 GLsizei size, GLenum type, GLint location, | 224 GLsizei size, GLenum type, GLint location, |
222 const std::string& name, const std::string& original_name); | 225 const std::string& name, const std::string& original_name); |
223 | 226 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 | 268 |
266 // True if this program is marked as deleted. | 269 // True if this program is marked as deleted. |
267 bool deleted_; | 270 bool deleted_; |
268 | 271 |
269 // This is true if glLinkProgram was successful at least once. | 272 // This is true if glLinkProgram was successful at least once. |
270 bool valid_; | 273 bool valid_; |
271 | 274 |
272 // This is true if glLinkProgram was successful last time it was called. | 275 // This is true if glLinkProgram was successful last time it was called. |
273 bool link_status_; | 276 bool link_status_; |
274 | 277 |
| 278 // True if the uniforms have been cleared. |
| 279 bool uniforms_cleared_; |
| 280 |
275 // Log info | 281 // Log info |
276 scoped_ptr<std::string> log_info_; | 282 scoped_ptr<std::string> log_info_; |
277 | 283 |
278 // attribute-location binding map from glBindAttribLocation() calls. | 284 // attribute-location binding map from glBindAttribLocation() calls. |
279 std::map<std::string, GLint> bind_attrib_location_map_; | 285 std::map<std::string, GLint> bind_attrib_location_map_; |
280 }; | 286 }; |
281 | 287 |
282 ProgramManager(); | 288 ProgramManager(); |
283 ~ProgramManager(); | 289 ~ProgramManager(); |
284 | 290 |
(...skipping 11 matching lines...) Expand all Loading... |
296 | 302 |
297 // Marks a program as deleted. If it is not used the info will be deleted. | 303 // Marks a program as deleted. If it is not used the info will be deleted. |
298 void MarkAsDeleted(ShaderManager* shader_manager, ProgramInfo* info); | 304 void MarkAsDeleted(ShaderManager* shader_manager, ProgramInfo* info); |
299 | 305 |
300 // Marks a program as used. | 306 // Marks a program as used. |
301 void UseProgram(ProgramInfo* info); | 307 void UseProgram(ProgramInfo* info); |
302 | 308 |
303 // Makes a program as unused. If deleted the program info will be removed. | 309 // Makes a program as unused. If deleted the program info will be removed. |
304 void UnuseProgram(ShaderManager* shader_manager, ProgramInfo* info); | 310 void UnuseProgram(ShaderManager* shader_manager, ProgramInfo* info); |
305 | 311 |
| 312 // Clears the uniforms for this program. |
| 313 void ClearUniforms(ProgramInfo* info); |
| 314 |
306 // Returns true if prefix is invalid for gl. | 315 // Returns true if prefix is invalid for gl. |
307 static bool IsInvalidPrefix(const char* name, size_t length); | 316 static bool IsInvalidPrefix(const char* name, size_t length); |
308 | 317 |
309 // Check if a ProgramInfo is owned by this ProgramManager. | 318 // Check if a ProgramInfo is owned by this ProgramManager. |
310 bool IsOwned(ProgramInfo* info); | 319 bool IsOwned(ProgramInfo* info); |
311 | 320 |
312 GLint SwizzleLocation(GLint unswizzled_location) const; | 321 GLint SwizzleLocation(GLint unswizzled_location) const; |
313 GLint UnswizzleLocation(GLint swizzled_location) const; | 322 GLint UnswizzleLocation(GLint swizzled_location) const; |
314 | 323 |
315 private: | 324 private: |
316 void StartTracking(ProgramInfo* info); | 325 void StartTracking(ProgramInfo* info); |
317 void StopTracking(ProgramInfo* info); | 326 void StopTracking(ProgramInfo* info); |
318 | 327 |
319 // Info for each "successfully linked" program by service side program Id. | 328 // Info for each "successfully linked" program by service side program Id. |
320 // TODO(gman): Choose a faster container. | 329 // TODO(gman): Choose a faster container. |
321 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; | 330 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; |
322 ProgramInfoMap program_infos_; | 331 ProgramInfoMap program_infos_; |
323 | 332 |
324 int uniform_swizzle_; | 333 int uniform_swizzle_; |
325 | 334 |
326 // Counts the number of ProgramInfo allocated with 'this' as its manager. | 335 // Counts the number of ProgramInfo allocated with 'this' as its manager. |
327 // Allows to check no ProgramInfo will outlive this. | 336 // Allows to check no ProgramInfo will outlive this. |
328 unsigned int program_info_count_; | 337 unsigned int program_info_count_; |
329 | 338 |
330 bool have_context_; | 339 bool have_context_; |
331 | 340 |
| 341 // Used to clear uniforms. |
| 342 std::vector<uint8> zero_; |
| 343 |
332 void RemoveProgramInfoIfUnused( | 344 void RemoveProgramInfoIfUnused( |
333 ShaderManager* shader_manager, ProgramInfo* info); | 345 ShaderManager* shader_manager, ProgramInfo* info); |
334 | 346 |
335 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 347 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
336 }; | 348 }; |
337 | 349 |
338 } // namespace gles2 | 350 } // namespace gles2 |
339 } // namespace gpu | 351 } // namespace gpu |
340 | 352 |
341 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 353 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
OLD | NEW |