Chromium Code Reviews| 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> |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "gpu/command_buffer/service/common_decoder.h" | 14 #include "gpu/command_buffer/service/common_decoder.h" |
| 15 #include "gpu/command_buffer/service/feature_info.h" | |
|
greggman
2012/06/26 23:00:27
forward declare instead?
dmurph
2012/07/04 00:01:29
Done.
| |
| 16 #include "gpu/command_buffer/service/gl_utils.h" | 16 #include "gpu/command_buffer/service/gl_utils.h" |
| 17 #include "gpu/command_buffer/service/program_cache.h" | |
|
greggman
2012/06/26 23:00:27
forward declare instead?
dmurph
2012/07/04 00:01:29
Done.
| |
| 17 #include "gpu/command_buffer/service/shader_manager.h" | 18 #include "gpu/command_buffer/service/shader_manager.h" |
| 18 #include "gpu/gpu_export.h" | 19 #include "gpu/gpu_export.h" |
| 19 | 20 |
| 20 namespace gpu { | 21 namespace gpu { |
| 21 namespace gles2 { | 22 namespace gles2 { |
| 22 | 23 |
| 23 // Tracks the Programs. | 24 // Tracks the Programs. |
| 24 // | 25 // |
| 25 // NOTE: To support shared resources an instance of this class will | 26 // NOTE: To support shared resources an instance of this class will |
| 26 // need to be shared by multiple GLES2Decoders. | 27 // need to be shared by multiple GLES2Decoders. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 bool IsValid() const { | 142 bool IsValid() const { |
| 142 return valid_; | 143 return valid_; |
| 143 } | 144 } |
| 144 | 145 |
| 145 bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); | 146 bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); |
| 146 bool DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); | 147 bool DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info); |
| 147 | 148 |
| 148 bool CanLink() const; | 149 bool CanLink() const; |
| 149 | 150 |
| 150 // Performs glLinkProgram and related activities. | 151 // Performs glLinkProgram and related activities. |
| 151 bool Link(); | 152 bool Link(ShaderManager* manager, |
| 153 ShaderTranslator* vertex_translator, | |
| 154 ShaderTranslator* fragment_shader, | |
| 155 FeatureInfo* feature_info); | |
| 152 | 156 |
| 153 // Performs glValidateProgram and related activities. | 157 // Performs glValidateProgram and related activities. |
| 154 void Validate(); | 158 void Validate(); |
| 155 | 159 |
| 156 const std::string* log_info() const { | 160 const std::string* log_info() const { |
| 157 return log_info_.get(); | 161 return log_info_.get(); |
| 158 } | 162 } |
| 159 | 163 |
| 160 bool InUse() const { | 164 bool InUse() const { |
| 161 DCHECK_GE(use_count_, 0); | 165 DCHECK_GE(use_count_, 0); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 277 // True if the uniforms have been cleared. | 281 // True if the uniforms have been cleared. |
| 278 bool uniforms_cleared_; | 282 bool uniforms_cleared_; |
| 279 | 283 |
| 280 // Log info | 284 // Log info |
| 281 scoped_ptr<std::string> log_info_; | 285 scoped_ptr<std::string> log_info_; |
| 282 | 286 |
| 283 // attribute-location binding map from glBindAttribLocation() calls. | 287 // attribute-location binding map from glBindAttribLocation() calls. |
| 284 std::map<std::string, GLint> bind_attrib_location_map_; | 288 std::map<std::string, GLint> bind_attrib_location_map_; |
| 285 }; | 289 }; |
| 286 | 290 |
| 287 ProgramManager(); | 291 explicit ProgramManager(ProgramCache* program_cache); |
| 288 ~ProgramManager(); | 292 ~ProgramManager(); |
| 289 | 293 |
| 290 // Must call before destruction. | 294 // Must call before destruction. |
| 291 void Destroy(bool have_context); | 295 void Destroy(bool have_context); |
| 292 | 296 |
| 293 // Creates a new program info. | 297 // Creates a new program info. |
| 294 ProgramInfo* CreateProgramInfo(GLuint client_id, GLuint service_id); | 298 ProgramInfo* CreateProgramInfo(GLuint client_id, GLuint service_id); |
| 295 | 299 |
| 296 // Gets a program info | 300 // Gets a program info |
| 297 ProgramInfo* GetProgramInfo(GLuint client_id); | 301 ProgramInfo* GetProgramInfo(GLuint client_id); |
| 298 | 302 |
| 299 // Gets a client id for a given service id. | 303 // Gets a client id for a given service id. |
| 300 bool GetClientId(GLuint service_id, GLuint* client_id) const; | 304 bool GetClientId(GLuint service_id, GLuint* client_id) const; |
| 301 | 305 |
| 306 // Gets the shader cache | |
| 307 ProgramCache* program_cache() const; | |
| 308 | |
| 302 // Marks a program as deleted. If it is not used the info will be deleted. | 309 // Marks a program as deleted. If it is not used the info will be deleted. |
| 303 void MarkAsDeleted(ShaderManager* shader_manager, ProgramInfo* info); | 310 void MarkAsDeleted(ShaderManager* shader_manager, ProgramInfo* info); |
| 304 | 311 |
| 305 // Marks a program as used. | 312 // Marks a program as used. |
| 306 void UseProgram(ProgramInfo* info); | 313 void UseProgram(ProgramInfo* info); |
| 307 | 314 |
| 308 // Makes a program as unused. If deleted the program info will be removed. | 315 // Makes a program as unused. If deleted the program info will be removed. |
| 309 void UnuseProgram(ShaderManager* shader_manager, ProgramInfo* info); | 316 void UnuseProgram(ShaderManager* shader_manager, ProgramInfo* info); |
| 310 | 317 |
| 311 // Clears the uniforms for this program. | 318 // Clears the uniforms for this program. |
| 312 void ClearUniforms(ProgramInfo* info); | 319 void ClearUniforms(ProgramInfo* info); |
| 313 | 320 |
| 314 // Returns true if prefix is invalid for gl. | 321 // Returns true if prefix is invalid for gl. |
| 315 static bool IsInvalidPrefix(const char* name, size_t length); | 322 static bool IsInvalidPrefix(const char* name, size_t length); |
| 316 | 323 |
| 317 // Check if a ProgramInfo is owned by this ProgramManager. | 324 // Check if a ProgramInfo is owned by this ProgramManager. |
| 318 bool IsOwned(ProgramInfo* info); | 325 bool IsOwned(ProgramInfo* info); |
| 319 | 326 |
| 327 GLint SwizzleLocation(GLint unswizzled_location) const; | |
|
greggman
2012/06/26 23:00:27
These changed. You probably need to rebase.
dmurph
2012/07/04 00:01:29
Done.
| |
| 328 GLint UnswizzleLocation(GLint swizzled_location) const; | |
| 329 | |
| 330 void DoCompileShader(ShaderManager::ShaderInfo* info, | |
| 331 ShaderTranslator* translator, | |
| 332 FeatureInfo* feature_info); | |
| 333 | |
| 320 private: | 334 private: |
| 321 void StartTracking(ProgramInfo* info); | 335 void StartTracking(ProgramInfo* info); |
| 322 void StopTracking(ProgramInfo* info); | 336 void StopTracking(ProgramInfo* info); |
| 323 | 337 |
| 324 // Info for each "successfully linked" program by service side program Id. | 338 // Info for each "successfully linked" program by service side program Id. |
| 325 // TODO(gman): Choose a faster container. | 339 // TODO(gman): Choose a faster container. |
| 326 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; | 340 typedef std::map<GLuint, ProgramInfo::Ref> ProgramInfoMap; |
| 327 ProgramInfoMap program_infos_; | 341 ProgramInfoMap program_infos_; |
| 328 | 342 |
| 329 // Counts the number of ProgramInfo allocated with 'this' as its manager. | 343 // Counts the number of ProgramInfo allocated with 'this' as its manager. |
| 330 // Allows to check no ProgramInfo will outlive this. | 344 // Allows to check no ProgramInfo will outlive this. |
| 331 unsigned int program_info_count_; | 345 unsigned int program_info_count_; |
| 332 | 346 |
| 333 bool have_context_; | 347 bool have_context_; |
| 334 | 348 |
| 335 bool disable_workarounds_; | 349 bool disable_workarounds_; |
| 336 | 350 |
| 337 // Used to clear uniforms. | 351 // Used to clear uniforms. |
| 338 std::vector<uint8> zero_; | 352 std::vector<uint8> zero_; |
| 339 | 353 |
| 354 ProgramCache* program_cache_; | |
| 355 | |
| 340 void RemoveProgramInfoIfUnused( | 356 void RemoveProgramInfoIfUnused( |
| 341 ShaderManager* shader_manager, ProgramInfo* info); | 357 ShaderManager* shader_manager, ProgramInfo* info); |
| 342 | 358 |
| 343 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 359 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
| 344 }; | 360 }; |
| 345 | 361 |
| 346 } // namespace gles2 | 362 } // namespace gles2 |
| 347 } // namespace gpu | 363 } // namespace gpu |
| 348 | 364 |
| 349 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 365 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |