| 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 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 // Detects if there are uniforms of the same name but different type | 189 // Detects if there are uniforms of the same name but different type |
| 190 // or precision in vertex/fragment shaders. | 190 // or precision in vertex/fragment shaders. |
| 191 // Return true if such cases are detected. | 191 // Return true if such cases are detected. |
| 192 bool DetectUniformsMismatch() const; | 192 bool DetectUniformsMismatch() const; |
| 193 | 193 |
| 194 // Return true if a varying is statically used in fragment shader, but it | 194 // Return true if a varying is statically used in fragment shader, but it |
| 195 // is not declared in vertex shader. | 195 // is not declared in vertex shader. |
| 196 bool DetectVaryingsMismatch() const; | 196 bool DetectVaryingsMismatch() const; |
| 197 | 197 |
| 198 // Return false if varyings can't be packed into the max available |
| 199 // varying registers. |
| 200 bool CheckVaryingsPacking() const; |
| 201 |
| 198 // Visible for testing | 202 // Visible for testing |
| 199 const LocationMap& bind_attrib_location_map() const { | 203 const LocationMap& bind_attrib_location_map() const { |
| 200 return bind_attrib_location_map_; | 204 return bind_attrib_location_map_; |
| 201 } | 205 } |
| 202 | 206 |
| 203 private: | 207 private: |
| 204 friend class base::RefCounted<Program>; | 208 friend class base::RefCounted<Program>; |
| 205 friend class ProgramManager; | 209 friend class ProgramManager; |
| 206 | 210 |
| 207 ~Program(); | 211 ~Program(); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. | 326 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. |
| 323 LocationMap bind_uniform_location_map_; | 327 LocationMap bind_uniform_location_map_; |
| 324 }; | 328 }; |
| 325 | 329 |
| 326 // Tracks the Programs. | 330 // Tracks the Programs. |
| 327 // | 331 // |
| 328 // NOTE: To support shared resources an instance of this class will | 332 // NOTE: To support shared resources an instance of this class will |
| 329 // need to be shared by multiple GLES2Decoders. | 333 // need to be shared by multiple GLES2Decoders. |
| 330 class GPU_EXPORT ProgramManager { | 334 class GPU_EXPORT ProgramManager { |
| 331 public: | 335 public: |
| 332 explicit ProgramManager(ProgramCache* program_cache); | 336 explicit ProgramManager(ProgramCache* program_cache, |
| 337 uint32 max_varying_vectors); |
| 333 ~ProgramManager(); | 338 ~ProgramManager(); |
| 334 | 339 |
| 335 // Must call before destruction. | 340 // Must call before destruction. |
| 336 void Destroy(bool have_context); | 341 void Destroy(bool have_context); |
| 337 | 342 |
| 338 // Creates a new program. | 343 // Creates a new program. |
| 339 Program* CreateProgram(GLuint client_id, GLuint service_id); | 344 Program* CreateProgram(GLuint client_id, GLuint service_id); |
| 340 | 345 |
| 341 // Gets a program. | 346 // Gets a program. |
| 342 Program* GetProgram(GLuint client_id); | 347 Program* GetProgram(GLuint client_id); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 364 | 369 |
| 365 // Check if a Program is owned by this ProgramManager. | 370 // Check if a Program is owned by this ProgramManager. |
| 366 bool IsOwned(Program* program); | 371 bool IsOwned(Program* program); |
| 367 | 372 |
| 368 static int32 MakeFakeLocation(int32 index, int32 element); | 373 static int32 MakeFakeLocation(int32 index, int32 element); |
| 369 | 374 |
| 370 void DoCompileShader(Shader* shader, | 375 void DoCompileShader(Shader* shader, |
| 371 ShaderTranslator* translator, | 376 ShaderTranslator* translator, |
| 372 FeatureInfo* feature_info); | 377 FeatureInfo* feature_info); |
| 373 | 378 |
| 379 uint32 max_varying_vectors() const { |
| 380 return max_varying_vectors_; |
| 381 } |
| 382 |
| 374 private: | 383 private: |
| 375 friend class Program; | 384 friend class Program; |
| 376 | 385 |
| 377 void StartTracking(Program* program); | 386 void StartTracking(Program* program); |
| 378 void StopTracking(Program* program); | 387 void StopTracking(Program* program); |
| 379 | 388 |
| 389 void RemoveProgramInfoIfUnused( |
| 390 ShaderManager* shader_manager, Program* program); |
| 391 |
| 380 // Info for each "successfully linked" program by service side program Id. | 392 // Info for each "successfully linked" program by service side program Id. |
| 381 // TODO(gman): Choose a faster container. | 393 // TODO(gman): Choose a faster container. |
| 382 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; | 394 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; |
| 383 ProgramMap programs_; | 395 ProgramMap programs_; |
| 384 | 396 |
| 385 // Counts the number of Program allocated with 'this' as its manager. | 397 // Counts the number of Program allocated with 'this' as its manager. |
| 386 // Allows to check no Program will outlive this. | 398 // Allows to check no Program will outlive this. |
| 387 unsigned int program_count_; | 399 unsigned int program_count_; |
| 388 | 400 |
| 389 bool have_context_; | 401 bool have_context_; |
| 390 | 402 |
| 391 bool disable_workarounds_; | 403 bool disable_workarounds_; |
| 392 | 404 |
| 393 // Used to clear uniforms. | 405 // Used to clear uniforms. |
| 394 std::vector<uint8> zero_; | 406 std::vector<uint8> zero_; |
| 395 | 407 |
| 396 ProgramCache* program_cache_; | 408 ProgramCache* program_cache_; |
| 397 | 409 |
| 398 void RemoveProgramInfoIfUnused( | 410 uint32 max_varying_vectors_; |
| 399 ShaderManager* shader_manager, Program* program); | |
| 400 | 411 |
| 401 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 412 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
| 402 }; | 413 }; |
| 403 | 414 |
| 404 } // namespace gles2 | 415 } // namespace gles2 |
| 405 } // namespace gpu | 416 } // namespace gpu |
| 406 | 417 |
| 407 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 418 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |