| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 } | 379 } |
| 380 | 380 |
| 381 const std::vector<std::string>& transform_feedback_varyings() const { | 381 const std::vector<std::string>& transform_feedback_varyings() const { |
| 382 return transform_feedback_varyings_; | 382 return transform_feedback_varyings_; |
| 383 } | 383 } |
| 384 | 384 |
| 385 GLenum transform_feedback_buffer_mode() const { | 385 GLenum transform_feedback_buffer_mode() const { |
| 386 return transform_feedback_buffer_mode_; | 386 return transform_feedback_buffer_mode_; |
| 387 } | 387 } |
| 388 | 388 |
| 389 // Return each draw buffer's corresponding fragment shader output variable's |
| 390 // base type: FLOAT, INT, or UINT. |
| 391 // If the draw buffer has no corresponding output variable, its base type |
| 392 // is UNDEFINED_TYPE. |
| 393 // The data are only valid after a successful link. |
| 394 const ShaderVariableBaseType* GetFragmentOutputBaseTypes() const { |
| 395 return fragment_output_base_types_.get(); |
| 396 } |
| 397 |
| 389 private: | 398 private: |
| 390 friend class base::RefCounted<Program>; | 399 friend class base::RefCounted<Program>; |
| 391 friend class ProgramManager; | 400 friend class ProgramManager; |
| 392 | 401 |
| 393 ~Program(); | 402 ~Program(); |
| 394 | 403 |
| 395 void set_log_info(const char* str) { | 404 void set_log_info(const char* str) { |
| 396 log_info_.reset(str ? new std::string(str) : NULL); | 405 log_info_.reset(str ? new std::string(str) : NULL); |
| 397 } | 406 } |
| 398 | 407 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 415 } | 424 } |
| 416 | 425 |
| 417 // Resets the program. | 426 // Resets the program. |
| 418 void Reset(); | 427 void Reset(); |
| 419 | 428 |
| 420 // Updates the program info after a successful link. | 429 // Updates the program info after a successful link. |
| 421 void Update(); | 430 void Update(); |
| 422 void UpdateUniforms(); | 431 void UpdateUniforms(); |
| 423 void UpdateFragmentInputs(); | 432 void UpdateFragmentInputs(); |
| 424 void UpdateProgramOutputs(); | 433 void UpdateProgramOutputs(); |
| 434 void UpdateFragmentOutputBaseTypes(); |
| 425 | 435 |
| 426 // Process the program log, replacing the hashed names with original names. | 436 // Process the program log, replacing the hashed names with original names. |
| 427 std::string ProcessLogInfo(const std::string& log); | 437 std::string ProcessLogInfo(const std::string& log); |
| 428 | 438 |
| 429 // Updates the program log info from GL | 439 // Updates the program log info from GL |
| 430 void UpdateLogInfo(); | 440 void UpdateLogInfo(); |
| 431 | 441 |
| 432 // Clears all the uniforms. | 442 // Clears all the uniforms. |
| 433 void ClearUniforms(std::vector<uint8_t>* zero_buffer); | 443 void ClearUniforms(std::vector<uint8_t>* zero_buffer); |
| 434 | 444 |
| 435 // If long attribate names are mapped during shader translation, call | 445 // If long attribate names are mapped during shader translation, call |
| 436 // glBindAttribLocation() again with the mapped names. | 446 // glBindAttribLocation() again with the mapped names. |
| 437 // This is called right before the glLink() call, but after shaders are | 447 // This is called right before the glLink() call, but after shaders are |
| 438 // translated. | 448 // translated. |
| 439 void ExecuteBindAttribLocationCalls(); | 449 void ExecuteBindAttribLocationCalls(); |
| 440 | 450 |
| 441 // The names of transform feedback varyings need to be hashed just | 451 // The names of transform feedback varyings need to be hashed just |
| 442 // like bound attributes' locations, just before the link call. | 452 // like bound attributes' locations, just before the link call. |
| 443 // Returns false upon failure. | 453 // Returns false upon failure. |
| 444 bool ExecuteTransformFeedbackVaryingsCall(); | 454 bool ExecuteTransformFeedbackVaryingsCall(); |
| 445 | 455 |
| 446 void ExecuteProgramOutputBindCalls(); | 456 void ExecuteProgramOutputBindCalls(); |
| 447 | 457 |
| 448 // Query VertexAttrib data returned by ANGLE translator by the mapped name. | 458 // Query VertexAttrib data returned by ANGLE translator by the mapped name. |
| 449 void GetVertexAttribData( | 459 void GetVertexAttribData( |
| 450 const std::string& name, std::string* original_name, GLenum* type) const; | 460 const std::string& name, std::string* original_name, GLenum* type) const; |
| 451 | 461 |
| 452 void DetachShaders(ShaderManager* manager); | 462 void DetachShaders(ShaderManager* manager); |
| 453 | 463 |
| 464 void ResetFragmentOutputBaseTypes(); |
| 465 |
| 454 static inline size_t GetUniformLocationIndexFromFakeLocation( | 466 static inline size_t GetUniformLocationIndexFromFakeLocation( |
| 455 GLint fake_location) { | 467 GLint fake_location) { |
| 456 return static_cast<size_t>(fake_location & 0xFFFF); | 468 return static_cast<size_t>(fake_location & 0xFFFF); |
| 457 } | 469 } |
| 458 | 470 |
| 459 static inline size_t GetArrayElementIndexFromFakeLocation( | 471 static inline size_t GetArrayElementIndexFromFakeLocation( |
| 460 GLint fake_location) { | 472 GLint fake_location) { |
| 461 return static_cast<size_t>((fake_location >> 16) & 0xFFFF); | 473 return static_cast<size_t>((fake_location >> 16) & 0xFFFF); |
| 462 } | 474 } |
| 463 | 475 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 486 | 498 |
| 487 FragmentInputInfoVector fragment_input_infos_; | 499 FragmentInputInfoVector fragment_input_infos_; |
| 488 FragmentInputLocationVector fragment_input_locations_; | 500 FragmentInputLocationVector fragment_input_locations_; |
| 489 | 501 |
| 490 ProgramOutputInfoVector program_output_infos_; | 502 ProgramOutputInfoVector program_output_infos_; |
| 491 | 503 |
| 492 // The program this Program is tracking. | 504 // The program this Program is tracking. |
| 493 GLuint service_id_; | 505 GLuint service_id_; |
| 494 | 506 |
| 495 // Shaders by type of shader. | 507 // Shaders by type of shader. |
| 496 scoped_refptr<Shader> | 508 scoped_refptr<Shader> attached_shaders_[kMaxAttachedShaders]; |
| 497 attached_shaders_[kMaxAttachedShaders]; | |
| 498 | 509 |
| 499 // True if this program is marked as deleted. | 510 // True if this program is marked as deleted. |
| 500 bool deleted_; | 511 bool deleted_; |
| 501 | 512 |
| 502 // This is true if glLinkProgram was successful at least once. | 513 // This is true if glLinkProgram was successful at least once. |
| 503 bool valid_; | 514 bool valid_; |
| 504 | 515 |
| 505 // This is true if glLinkProgram was successful last time it was called. | 516 // This is true if glLinkProgram was successful last time it was called. |
| 506 bool link_status_; | 517 bool link_status_; |
| 507 | 518 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 521 | 532 |
| 522 GLenum transform_feedback_buffer_mode_; | 533 GLenum transform_feedback_buffer_mode_; |
| 523 | 534 |
| 524 // Fragment input-location binding map from | 535 // Fragment input-location binding map from |
| 525 // glBindFragmentInputLocationCHROMIUM() calls. | 536 // glBindFragmentInputLocationCHROMIUM() calls. |
| 526 LocationMap bind_fragment_input_location_map_; | 537 LocationMap bind_fragment_input_location_map_; |
| 527 | 538 |
| 528 // output variable - (location,index) binding map from | 539 // output variable - (location,index) binding map from |
| 529 // glBindFragDataLocation() and ..IndexedEXT() calls. | 540 // glBindFragDataLocation() and ..IndexedEXT() calls. |
| 530 LocationIndexMap bind_program_output_location_index_map_; | 541 LocationIndexMap bind_program_output_location_index_map_; |
| 542 |
| 543 // Fragment output variable base types: FLOAT, INT, or UINT. |
| 544 std::unique_ptr<ShaderVariableBaseType[]> fragment_output_base_types_; |
| 531 }; | 545 }; |
| 532 | 546 |
| 533 // Tracks the Programs. | 547 // Tracks the Programs. |
| 534 // | 548 // |
| 535 // NOTE: To support shared resources an instance of this class will | 549 // NOTE: To support shared resources an instance of this class will |
| 536 // need to be shared by multiple GLES2Decoders. | 550 // need to be shared by multiple GLES2Decoders. |
| 537 class GPU_EXPORT ProgramManager { | 551 class GPU_EXPORT ProgramManager { |
| 538 public: | 552 public: |
| 539 ProgramManager(ProgramCache* program_cache, | 553 ProgramManager(ProgramCache* program_cache, |
| 540 uint32_t max_varying_vectors, | 554 uint32_t max_varying_vectors, |
| 555 uint32_t max_draw_buffers, |
| 541 uint32_t max_dual_source_draw_buffers, | 556 uint32_t max_dual_source_draw_buffers, |
| 542 const GpuPreferences& gpu_preferences, | 557 const GpuPreferences& gpu_preferences, |
| 543 FeatureInfo* feature_info); | 558 FeatureInfo* feature_info); |
| 544 ~ProgramManager(); | 559 ~ProgramManager(); |
| 545 | 560 |
| 546 // Must call before destruction. | 561 // Must call before destruction. |
| 547 void Destroy(bool have_context); | 562 void Destroy(bool have_context); |
| 548 | 563 |
| 549 // Creates a new program. | 564 // Creates a new program. |
| 550 Program* CreateProgram(GLuint client_id, GLuint service_id); | 565 Program* CreateProgram(GLuint client_id, GLuint service_id); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 574 // variables. | 589 // variables. |
| 575 static bool HasBuiltInPrefix(const std::string& name); | 590 static bool HasBuiltInPrefix(const std::string& name); |
| 576 | 591 |
| 577 // Check if a Program is owned by this ProgramManager. | 592 // Check if a Program is owned by this ProgramManager. |
| 578 bool IsOwned(Program* program) const; | 593 bool IsOwned(Program* program) const; |
| 579 | 594 |
| 580 static int32_t MakeFakeLocation(int32_t index, int32_t element); | 595 static int32_t MakeFakeLocation(int32_t index, int32_t element); |
| 581 | 596 |
| 582 uint32_t max_varying_vectors() const { return max_varying_vectors_; } | 597 uint32_t max_varying_vectors() const { return max_varying_vectors_; } |
| 583 | 598 |
| 599 uint32_t max_draw_buffers() const { return max_draw_buffers_; } |
| 600 |
| 584 uint32_t max_dual_source_draw_buffers() const { | 601 uint32_t max_dual_source_draw_buffers() const { |
| 585 return max_dual_source_draw_buffers_; | 602 return max_dual_source_draw_buffers_; |
| 586 } | 603 } |
| 587 | 604 |
| 588 private: | 605 private: |
| 589 friend class Program; | 606 friend class Program; |
| 590 | 607 |
| 591 void StartTracking(Program* program); | 608 void StartTracking(Program* program); |
| 592 void StopTracking(Program* program); | 609 void StopTracking(Program* program); |
| 593 | 610 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 604 unsigned int program_count_; | 621 unsigned int program_count_; |
| 605 | 622 |
| 606 bool have_context_; | 623 bool have_context_; |
| 607 | 624 |
| 608 // Used to clear uniforms. | 625 // Used to clear uniforms. |
| 609 std::vector<uint8_t> zero_; | 626 std::vector<uint8_t> zero_; |
| 610 | 627 |
| 611 ProgramCache* program_cache_; | 628 ProgramCache* program_cache_; |
| 612 | 629 |
| 613 uint32_t max_varying_vectors_; | 630 uint32_t max_varying_vectors_; |
| 631 uint32_t max_draw_buffers_; |
| 614 uint32_t max_dual_source_draw_buffers_; | 632 uint32_t max_dual_source_draw_buffers_; |
| 615 | 633 |
| 616 const GpuPreferences& gpu_preferences_; | 634 const GpuPreferences& gpu_preferences_; |
| 617 scoped_refptr<FeatureInfo> feature_info_; | 635 scoped_refptr<FeatureInfo> feature_info_; |
| 618 | 636 |
| 619 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 637 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
| 620 }; | 638 }; |
| 621 | 639 |
| 622 inline const FeatureInfo& Program::feature_info() const { | 640 inline const FeatureInfo& Program::feature_info() const { |
| 623 return *manager_->feature_info_.get(); | 641 return *manager_->feature_info_.get(); |
| 624 } | 642 } |
| 625 | 643 |
| 626 } // namespace gles2 | 644 } // namespace gles2 |
| 627 } // namespace gpu | 645 } // namespace gpu |
| 628 | 646 |
| 629 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 647 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |