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