| 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 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 : size(_size), | 117 : size(_size), |
| 118 type(_type), | 118 type(_type), |
| 119 location(_location), | 119 location(_location), |
| 120 name(_name) { | 120 name(_name) { |
| 121 } | 121 } |
| 122 GLsizei size; | 122 GLsizei size; |
| 123 GLenum type; | 123 GLenum type; |
| 124 GLint location; | 124 GLint location; |
| 125 std::string name; | 125 std::string name; |
| 126 }; | 126 }; |
| 127 struct UniformBlockSizeInfo { |
| 128 uint32_t binding; |
| 129 uint32_t data_size; |
| 130 }; |
| 127 | 131 |
| 128 template <typename T> | 132 template <typename T> |
| 129 class ShaderVariableLocationEntry { | 133 class ShaderVariableLocationEntry { |
| 130 public: | 134 public: |
| 131 ShaderVariableLocationEntry() | 135 ShaderVariableLocationEntry() |
| 132 : shader_variable_(nullptr), inactive_(false) {} | 136 : shader_variable_(nullptr), inactive_(false) {} |
| 133 bool IsUnused() const { return !shader_variable_ && !inactive_; } | 137 bool IsUnused() const { return !shader_variable_ && !inactive_; } |
| 134 bool IsInactive() const { return inactive_; } | 138 bool IsInactive() const { return inactive_; } |
| 135 bool IsActive() const { return shader_variable_ != nullptr; } | 139 bool IsActive() const { return shader_variable_ != nullptr; } |
| 136 void SetInactive() { | 140 void SetInactive() { |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 396 |
| 393 // See member declaration for details. | 397 // See member declaration for details. |
| 394 // The data are only valid after a successful link. | 398 // The data are only valid after a successful link. |
| 395 uint32_t fragment_output_type_mask() const { | 399 uint32_t fragment_output_type_mask() const { |
| 396 return fragment_output_type_mask_; | 400 return fragment_output_type_mask_; |
| 397 } | 401 } |
| 398 uint32_t fragment_output_written_mask() const { | 402 uint32_t fragment_output_written_mask() const { |
| 399 return fragment_output_written_mask_; | 403 return fragment_output_written_mask_; |
| 400 } | 404 } |
| 401 | 405 |
| 406 // Update uniform block binding after a successful glUniformBlockBinding(). |
| 407 void SetUniformBlockBinding(GLuint index, GLuint binding); |
| 408 |
| 409 const std::vector<UniformBlockSizeInfo>& uniform_block_size_info() const { |
| 410 return uniform_block_size_info_; |
| 411 } |
| 412 |
| 402 private: | 413 private: |
| 403 friend class base::RefCounted<Program>; | 414 friend class base::RefCounted<Program>; |
| 404 friend class ProgramManager; | 415 friend class ProgramManager; |
| 405 | 416 |
| 406 ~Program(); | 417 ~Program(); |
| 407 | 418 |
| 408 void set_log_info(const char* str) { | 419 void set_log_info(const char* str) { |
| 409 log_info_.reset(str ? new std::string(str) : NULL); | 420 log_info_.reset(str ? new std::string(str) : NULL); |
| 410 } | 421 } |
| 411 | 422 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 429 | 440 |
| 430 // Resets the program. | 441 // Resets the program. |
| 431 void Reset(); | 442 void Reset(); |
| 432 | 443 |
| 433 // Updates the program info after a successful link. | 444 // Updates the program info after a successful link. |
| 434 void Update(); | 445 void Update(); |
| 435 void UpdateUniforms(); | 446 void UpdateUniforms(); |
| 436 void UpdateFragmentInputs(); | 447 void UpdateFragmentInputs(); |
| 437 void UpdateProgramOutputs(); | 448 void UpdateProgramOutputs(); |
| 438 void UpdateFragmentOutputBaseTypes(); | 449 void UpdateFragmentOutputBaseTypes(); |
| 450 void UpdateUniformBlockSizeInfo(); |
| 439 | 451 |
| 440 // Process the program log, replacing the hashed names with original names. | 452 // Process the program log, replacing the hashed names with original names. |
| 441 std::string ProcessLogInfo(const std::string& log); | 453 std::string ProcessLogInfo(const std::string& log); |
| 442 | 454 |
| 443 // Updates the program log info from GL | 455 // Updates the program log info from GL |
| 444 void UpdateLogInfo(); | 456 void UpdateLogInfo(); |
| 445 | 457 |
| 446 // Clears all the uniforms. | 458 // Clears all the uniforms. |
| 447 void ClearUniforms(std::vector<uint8_t>* zero_buffer); | 459 void ClearUniforms(std::vector<uint8_t>* zero_buffer); |
| 448 | 460 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 GLenum transform_feedback_buffer_mode_; | 547 GLenum transform_feedback_buffer_mode_; |
| 536 | 548 |
| 537 // Fragment input-location binding map from | 549 // Fragment input-location binding map from |
| 538 // glBindFragmentInputLocationCHROMIUM() calls. | 550 // glBindFragmentInputLocationCHROMIUM() calls. |
| 539 LocationMap bind_fragment_input_location_map_; | 551 LocationMap bind_fragment_input_location_map_; |
| 540 | 552 |
| 541 // output variable - (location,index) binding map from | 553 // output variable - (location,index) binding map from |
| 542 // glBindFragDataLocation() and ..IndexedEXT() calls. | 554 // glBindFragDataLocation() and ..IndexedEXT() calls. |
| 543 LocationIndexMap bind_program_output_location_index_map_; | 555 LocationIndexMap bind_program_output_location_index_map_; |
| 544 | 556 |
| 557 // It's stored in the order of uniform block indices, i.e., the first |
| 558 // entry is the info about UniformBlock with index 0, etc. |
| 559 std::vector<UniformBlockSizeInfo> uniform_block_size_info_; |
| 560 |
| 545 // Fragment output variable base types: FLOAT, INT, or UINT. | 561 // Fragment output variable base types: FLOAT, INT, or UINT. |
| 546 // We have up to 16 outputs, each is encoded into 2 bits, total 32 bits: | 562 // We have up to 16 outputs, each is encoded into 2 bits, total 32 bits: |
| 547 // the lowest 2 bits for location 0, the highest 2 bits for location 15. | 563 // the lowest 2 bits for location 0, the highest 2 bits for location 15. |
| 548 uint32_t fragment_output_type_mask_; | 564 uint32_t fragment_output_type_mask_; |
| 549 // Same layout as above, 2 bits per location, 0x03 if a location is occupied | 565 // Same layout as above, 2 bits per location, 0x03 if a location is occupied |
| 550 // by an output variable, 0x00 if not. | 566 // by an output variable, 0x00 if not. |
| 551 uint32_t fragment_output_written_mask_; | 567 uint32_t fragment_output_written_mask_; |
| 552 }; | 568 }; |
| 553 | 569 |
| 554 // Tracks the Programs. | 570 // Tracks the Programs. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 }; | 661 }; |
| 646 | 662 |
| 647 inline const FeatureInfo& Program::feature_info() const { | 663 inline const FeatureInfo& Program::feature_info() const { |
| 648 return *manager_->feature_info_.get(); | 664 return *manager_->feature_info_.get(); |
| 649 } | 665 } |
| 650 | 666 |
| 651 } // namespace gles2 | 667 } // namespace gles2 |
| 652 } // namespace gpu | 668 } // namespace gpu |
| 653 | 669 |
| 654 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 670 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |