| 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 15 matching lines...) Expand all Loading... |
| 26 class ShaderManager; | 26 class ShaderManager; |
| 27 class ShaderTranslator; | 27 class ShaderTranslator; |
| 28 | 28 |
| 29 // This is used to track which attributes a particular program needs | 29 // This is used to track which attributes a particular program needs |
| 30 // so we can verify at glDrawXXX time that every attribute is either disabled | 30 // so we can verify at glDrawXXX time that every attribute is either disabled |
| 31 // or if enabled that it points to a valid source. | 31 // or if enabled that it points to a valid source. |
| 32 class GPU_EXPORT Program : public base::RefCounted<Program> { | 32 class GPU_EXPORT Program : public base::RefCounted<Program> { |
| 33 public: | 33 public: |
| 34 static const int kMaxAttachedShaders = 2; | 34 static const int kMaxAttachedShaders = 2; |
| 35 | 35 |
| 36 enum VaryingsPackingOption { | |
| 37 kCountOnlyStaticallyUsed, | |
| 38 kCountAll | |
| 39 }; | |
| 40 | |
| 41 struct UniformInfo { | 36 struct UniformInfo { |
| 42 UniformInfo(); | 37 UniformInfo(); |
| 43 UniformInfo( | 38 UniformInfo( |
| 44 GLsizei _size, GLenum _type, GLint _fake_location_base, | 39 GLsizei _size, GLenum _type, GLint _fake_location_base, |
| 45 const std::string& _name); | 40 const std::string& _name); |
| 46 ~UniformInfo(); | 41 ~UniformInfo(); |
| 47 | 42 |
| 48 bool IsValid() const { | 43 bool IsValid() const { |
| 49 return size != 0; | 44 return size != 0; |
| 50 } | 45 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 149 |
| 155 bool AttachShader(ShaderManager* manager, Shader* shader); | 150 bool AttachShader(ShaderManager* manager, Shader* shader); |
| 156 bool DetachShader(ShaderManager* manager, Shader* shader); | 151 bool DetachShader(ShaderManager* manager, Shader* shader); |
| 157 | 152 |
| 158 bool CanLink() const; | 153 bool CanLink() const; |
| 159 | 154 |
| 160 // Performs glLinkProgram and related activities. | 155 // Performs glLinkProgram and related activities. |
| 161 bool Link(ShaderManager* manager, | 156 bool Link(ShaderManager* manager, |
| 162 ShaderTranslator* vertex_translator, | 157 ShaderTranslator* vertex_translator, |
| 163 ShaderTranslator* fragment_shader, | 158 ShaderTranslator* fragment_shader, |
| 164 VaryingsPackingOption varyings_packing_option, | |
| 165 const ShaderCacheCallback& shader_callback); | 159 const ShaderCacheCallback& shader_callback); |
| 166 | 160 |
| 167 // Performs glValidateProgram and related activities. | 161 // Performs glValidateProgram and related activities. |
| 168 void Validate(); | 162 void Validate(); |
| 169 | 163 |
| 170 const std::string* log_info() const { | 164 const std::string* log_info() const { |
| 171 return log_info_.get(); | 165 return log_info_.get(); |
| 172 } | 166 } |
| 173 | 167 |
| 174 bool InUse() const { | 168 bool InUse() const { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 197 | 191 |
| 198 // Return true if a varying is statically used in fragment shader, but it | 192 // Return true if a varying is statically used in fragment shader, but it |
| 199 // is not declared in vertex shader. | 193 // is not declared in vertex shader. |
| 200 bool DetectVaryingsMismatch() const; | 194 bool DetectVaryingsMismatch() const; |
| 201 | 195 |
| 202 // Return true if an uniform and an attribute share the same name. | 196 // Return true if an uniform and an attribute share the same name. |
| 203 bool DetectGlobalNameConflicts() const; | 197 bool DetectGlobalNameConflicts() const; |
| 204 | 198 |
| 205 // Return false if varyings can't be packed into the max available | 199 // Return false if varyings can't be packed into the max available |
| 206 // varying registers. | 200 // varying registers. |
| 207 bool CheckVaryingsPacking(VaryingsPackingOption option) const; | 201 bool CheckVaryingsPacking() const; |
| 208 | 202 |
| 209 // Visible for testing | 203 // Visible for testing |
| 210 const LocationMap& bind_attrib_location_map() const { | 204 const LocationMap& bind_attrib_location_map() const { |
| 211 return bind_attrib_location_map_; | 205 return bind_attrib_location_map_; |
| 212 } | 206 } |
| 213 | 207 |
| 214 private: | 208 private: |
| 215 friend class base::RefCounted<Program>; | 209 friend class base::RefCounted<Program>; |
| 216 friend class ProgramManager; | 210 friend class ProgramManager; |
| 217 | 211 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 | 414 |
| 421 uint32 max_varying_vectors_; | 415 uint32 max_varying_vectors_; |
| 422 | 416 |
| 423 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 417 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
| 424 }; | 418 }; |
| 425 | 419 |
| 426 } // namespace gles2 | 420 } // namespace gles2 |
| 427 } // namespace gpu | 421 } // namespace gpu |
| 428 | 422 |
| 429 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 423 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
| OLD | NEW |