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> |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "gpu/command_buffer/service/common_decoder.h" | 14 #include "gpu/command_buffer/service/common_decoder.h" |
15 #include "gpu/command_buffer/service/gl_utils.h" | 15 #include "gpu/command_buffer/service/gl_utils.h" |
16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 16 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
17 #include "gpu/command_buffer/service/shader_manager.h" | 17 #include "gpu/command_buffer/service/shader_manager.h" |
18 #include "gpu/gpu_export.h" | 18 #include "gpu/gpu_export.h" |
19 | 19 |
20 namespace gpu { | 20 namespace gpu { |
21 namespace gles2 { | 21 namespace gles2 { |
22 | 22 |
| 23 class FeatureInfo; |
23 class ProgramCache; | 24 class ProgramCache; |
24 class ProgramManager; | 25 class ProgramManager; |
25 class Shader; | 26 class Shader; |
26 class ShaderManager; | 27 class ShaderManager; |
27 class FeatureInfo; | 28 class FeatureInfo; |
28 | 29 |
29 // This is used to track which attributes a particular program needs | 30 // 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 | 31 // so we can verify at glDrawXXX time that every attribute is either disabled |
31 // or if enabled that it points to a valid source. | 32 // or if enabled that it points to a valid source. |
32 class GPU_EXPORT Program : public base::RefCounted<Program> { | 33 class GPU_EXPORT Program : public base::RefCounted<Program> { |
(...skipping 29 matching lines...) Expand all Loading... |
62 kUniformMatrix4x2f = 1 << 19, | 63 kUniformMatrix4x2f = 1 << 19, |
63 kUniformMatrix4x3f = 1 << 20, | 64 kUniformMatrix4x3f = 1 << 20, |
64 }; | 65 }; |
65 struct FragmentInputInfo { | 66 struct FragmentInputInfo { |
66 FragmentInputInfo(GLenum _type, GLuint _location) | 67 FragmentInputInfo(GLenum _type, GLuint _location) |
67 : type(_type), location(_location) {} | 68 : type(_type), location(_location) {} |
68 FragmentInputInfo() : type(GL_NONE), location(0) {} | 69 FragmentInputInfo() : type(GL_NONE), location(0) {} |
69 GLenum type; | 70 GLenum type; |
70 GLuint location; | 71 GLuint location; |
71 }; | 72 }; |
| 73 struct ProgramOutputInfo { |
| 74 ProgramOutputInfo(GLuint _color_name, |
| 75 GLuint _index, |
| 76 const std::string& _name) |
| 77 : color_name(_color_name), index(_index), name(_name) {} |
| 78 ProgramOutputInfo() : color_name(0), index(0) {} |
| 79 GLuint color_name; |
| 80 GLuint index; |
| 81 std::string name; |
| 82 }; |
72 | 83 |
73 struct UniformInfo { | 84 struct UniformInfo { |
74 UniformInfo(); | 85 UniformInfo(); |
75 UniformInfo(const std::string& client_name, | 86 UniformInfo(const std::string& client_name, |
76 GLint client_location_base, | 87 GLint client_location_base, |
77 GLenum _type, | 88 GLenum _type, |
78 bool _is_array, | 89 bool _is_array, |
79 const std::vector<GLint>& service_locations); | 90 const std::vector<GLint>& service_locations); |
80 ~UniformInfo(); | 91 ~UniformInfo(); |
81 bool IsSampler() const { | 92 bool IsSampler() const { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 bool inactive_; | 148 bool inactive_; |
138 }; | 149 }; |
139 | 150 |
140 typedef std::vector<UniformInfo> UniformInfoVector; | 151 typedef std::vector<UniformInfo> UniformInfoVector; |
141 typedef std::vector<ShaderVariableLocationEntry<UniformInfo>> | 152 typedef std::vector<ShaderVariableLocationEntry<UniformInfo>> |
142 UniformLocationVector; | 153 UniformLocationVector; |
143 typedef std::vector<VertexAttrib> AttribInfoVector; | 154 typedef std::vector<VertexAttrib> AttribInfoVector; |
144 typedef std::vector<FragmentInputInfo> FragmentInputInfoVector; | 155 typedef std::vector<FragmentInputInfo> FragmentInputInfoVector; |
145 typedef std::vector<ShaderVariableLocationEntry<FragmentInputInfo>> | 156 typedef std::vector<ShaderVariableLocationEntry<FragmentInputInfo>> |
146 FragmentInputLocationVector; | 157 FragmentInputLocationVector; |
| 158 typedef std::vector<ProgramOutputInfo> ProgramOutputInfoVector; |
147 typedef std::vector<int> SamplerIndices; | 159 typedef std::vector<int> SamplerIndices; |
148 typedef std::map<std::string, GLint> LocationMap; | 160 typedef std::map<std::string, GLint> LocationMap; |
| 161 typedef std::map<std::string, std::pair<GLuint, GLuint>> LocationIndexMap; |
149 typedef std::vector<std::string> StringVector; | 162 typedef std::vector<std::string> StringVector; |
150 | 163 |
151 Program(ProgramManager* manager, GLuint service_id); | 164 Program(ProgramManager* manager, GLuint service_id); |
152 | 165 |
153 GLuint service_id() const { | 166 GLuint service_id() const { |
154 return service_id_; | 167 return service_id_; |
155 } | 168 } |
156 | 169 |
157 const SamplerIndices& sampler_indices() { | 170 const SamplerIndices& sampler_indices() { |
158 return sampler_indices_; | 171 return sampler_indices_; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 GLint GetUniformFakeLocation(const std::string& name) const; | 215 GLint GetUniformFakeLocation(const std::string& name) const; |
203 | 216 |
204 // Gets the UniformInfo of a uniform by location. | 217 // Gets the UniformInfo of a uniform by location. |
205 const UniformInfo* GetUniformInfoByFakeLocation( | 218 const UniformInfo* GetUniformInfoByFakeLocation( |
206 GLint fake_location, GLint* real_location, GLint* array_index) const; | 219 GLint fake_location, GLint* real_location, GLint* array_index) const; |
207 | 220 |
208 // Returns true if |fake_location| is a location for an inactive uniform, | 221 // Returns true if |fake_location| is a location for an inactive uniform, |
209 // -1 for bound, non-existing uniform. | 222 // -1 for bound, non-existing uniform. |
210 bool IsInactiveUniformLocationByFakeLocation(GLint fake_location) const; | 223 bool IsInactiveUniformLocationByFakeLocation(GLint fake_location) const; |
211 | 224 |
| 225 // Gets the ProgramOutputInfo of a fragment output by name. |
| 226 const ProgramOutputInfo* GetProgramOutputInfo( |
| 227 const std::string& original_name) const; |
| 228 |
212 // Gets all the program info. | 229 // Gets all the program info. |
213 void GetProgramInfo( | 230 void GetProgramInfo( |
214 ProgramManager* manager, CommonDecoder::Bucket* bucket) const; | 231 ProgramManager* manager, CommonDecoder::Bucket* bucket) const; |
215 | 232 |
216 // Gets all the UniformBlock info. | 233 // Gets all the UniformBlock info. |
217 // Return false on overflow. | 234 // Return false on overflow. |
218 bool GetUniformBlocks(CommonDecoder::Bucket* bucket) const; | 235 bool GetUniformBlocks(CommonDecoder::Bucket* bucket) const; |
219 | 236 |
220 // Gets all the TransformFeedbackVarying info. | 237 // Gets all the TransformFeedbackVarying info. |
221 // Return false on overflow. | 238 // Return false on overflow. |
222 bool GetTransformFeedbackVaryings(CommonDecoder::Bucket* bucket) const; | 239 bool GetTransformFeedbackVaryings(CommonDecoder::Bucket* bucket) const; |
223 | 240 |
224 // Gather all info through glGetActiveUniformsiv, except for size, type, | 241 // Gather all info through glGetActiveUniformsiv, except for size, type, |
225 // name_length, which we gather through glGetActiveUniform in | 242 // name_length, which we gather through glGetActiveUniform in |
226 // glGetProgramInfoCHROMIUM. | 243 // glGetProgramInfoCHROMIUM. |
227 bool GetUniformsES3(CommonDecoder::Bucket* bucket) const; | 244 bool GetUniformsES3(CommonDecoder::Bucket* bucket) const; |
228 | 245 |
| 246 // Returns the fragment shader output variable color name binding. |
| 247 // Returns -1 if |original_name| is not an out variable or error. |
| 248 GLint GetFragDataLocation(const std::string& original_name) const; |
| 249 |
| 250 // Returns the fragment shader output variable color index binding. |
| 251 // Returns -1 if |original_name| is not an out variable or error. |
| 252 GLint GetFragDataIndex(const std::string& original_name) const; |
| 253 |
229 // Sets the sampler values for a uniform. | 254 // Sets the sampler values for a uniform. |
230 // This is safe to call for any location. If the location is not | 255 // This is safe to call for any location. If the location is not |
231 // a sampler uniform nothing will happen. | 256 // a sampler uniform nothing will happen. |
232 // Returns false if fake_location is a sampler and any value | 257 // Returns false if fake_location is a sampler and any value |
233 // is >= num_texture_units. Returns true otherwise. | 258 // is >= num_texture_units. Returns true otherwise. |
234 bool SetSamplers( | 259 bool SetSamplers( |
235 GLint num_texture_units, GLint fake_location, | 260 GLint num_texture_units, GLint fake_location, |
236 GLsizei count, const GLint* value); | 261 GLsizei count, const GLint* value); |
237 | 262 |
238 bool IsDeleted() const { | 263 bool IsDeleted() const { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 // returns false if error. | 303 // returns false if error. |
279 bool SetUniformLocationBinding(const std::string& name, GLint location); | 304 bool SetUniformLocationBinding(const std::string& name, GLint location); |
280 | 305 |
281 // Detects if the shader version combination is not valid. | 306 // Detects if the shader version combination is not valid. |
282 bool DetectShaderVersionMismatch() const; | 307 bool DetectShaderVersionMismatch() const; |
283 | 308 |
284 // Sets fragment input-location binding from a | 309 // Sets fragment input-location binding from a |
285 // glBindFragmentInputLocationCHROMIUM() call. | 310 // glBindFragmentInputLocationCHROMIUM() call. |
286 void SetFragmentInputLocationBinding(const std::string& name, GLint location); | 311 void SetFragmentInputLocationBinding(const std::string& name, GLint location); |
287 | 312 |
| 313 // Sets program output variable location. Also sets color index to zero. |
| 314 void SetProgramOutputLocationBinding(const std::string& name, |
| 315 GLuint colorName); |
| 316 |
| 317 // Sets program output variable location and color index. |
| 318 void SetProgramOutputLocationIndexedBinding(const std::string& name, |
| 319 GLuint colorName, |
| 320 GLuint index); |
| 321 |
288 // Detects if there are attribute location conflicts from | 322 // Detects if there are attribute location conflicts from |
289 // glBindAttribLocation() calls. | 323 // glBindAttribLocation() calls. |
290 // We only consider the declared attributes in the program. | 324 // We only consider the declared attributes in the program. |
291 bool DetectAttribLocationBindingConflicts() const; | 325 bool DetectAttribLocationBindingConflicts() const; |
292 | 326 |
293 // Detects if there are uniform location conflicts from | 327 // Detects if there are uniform location conflicts from |
294 // glBindUniformLocationCHROMIUM() calls. | 328 // glBindUniformLocationCHROMIUM() calls. |
295 // We only consider the statically used uniforms in the program. | 329 // We only consider the statically used uniforms in the program. |
296 bool DetectUniformLocationBindingConflicts() const; | 330 bool DetectUniformLocationBindingConflicts() const; |
297 | 331 |
298 // Detects if there are uniforms of the same name but different type | 332 // Detects if there are uniforms of the same name but different type |
299 // or precision in vertex/fragment shaders. | 333 // or precision in vertex/fragment shaders. |
300 // Return true and set the first found conflicting hashed name to | 334 // Return true and set the first found conflicting hashed name to |
301 // conflicting_name if such cases are detected. | 335 // conflicting_name if such cases are detected. |
302 bool DetectUniformsMismatch(std::string* conflicting_name) const; | 336 bool DetectUniformsMismatch(std::string* conflicting_name) const; |
303 | 337 |
304 // Return true if a varying is statically used in fragment shader, but it | 338 // Return true if a varying is statically used in fragment shader, but it |
305 // is not declared in vertex shader. | 339 // is not declared in vertex shader. |
306 bool DetectVaryingsMismatch(std::string* conflicting_name) const; | 340 bool DetectVaryingsMismatch(std::string* conflicting_name) const; |
307 | 341 |
308 // Detects if there are fragment input location conflicts from | 342 // Detects if there are fragment input location conflicts from |
309 // glBindFragmentInputLocationCHROMIUM() calls. | 343 // glBindFragmentInputLocationCHROMIUM() calls. |
310 // We only consider the statically used fragment inputs in the program. | 344 // We only consider the statically used fragment inputs in the program. |
311 bool DetectFragmentInputLocationBindingConflicts() const; | 345 bool DetectFragmentInputLocationBindingConflicts() const; |
312 | 346 |
| 347 // Detects if there are program output location conflicts from |
| 348 // glBindFragDataLocation and ..LocationIndexedEXT calls. |
| 349 // We only consider the statically used program outputs in the program. |
| 350 bool DetectProgramOutputLocationBindingConflicts() const; |
| 351 |
313 // Return true if any built-in invariant matching rules are broken as in | 352 // Return true if any built-in invariant matching rules are broken as in |
314 // GLSL ES spec 1.00.17, section 4.6.4, Invariance and Linkage. | 353 // GLSL ES spec 1.00.17, section 4.6.4, Invariance and Linkage. |
315 bool DetectBuiltInInvariantConflicts() const; | 354 bool DetectBuiltInInvariantConflicts() const; |
316 | 355 |
317 // Return true if an uniform and an attribute share the same name. | 356 // Return true if an uniform and an attribute share the same name. |
318 bool DetectGlobalNameConflicts(std::string* conflicting_name) const; | 357 bool DetectGlobalNameConflicts(std::string* conflicting_name) const; |
319 | 358 |
320 // Return false if varyings can't be packed into the max available | 359 // Return false if varyings can't be packed into the max available |
321 // varying registers. | 360 // varying registers. |
322 bool CheckVaryingsPacking(VaryingsPackingOption option) const; | 361 bool CheckVaryingsPacking(VaryingsPackingOption option) const; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 deleted_ = true; | 404 deleted_ = true; |
366 } | 405 } |
367 | 406 |
368 // Resets the program. | 407 // Resets the program. |
369 void Reset(); | 408 void Reset(); |
370 | 409 |
371 // Updates the program info after a successful link. | 410 // Updates the program info after a successful link. |
372 void Update(); | 411 void Update(); |
373 void UpdateUniforms(); | 412 void UpdateUniforms(); |
374 void UpdateFragmentInputs(); | 413 void UpdateFragmentInputs(); |
| 414 void UpdateProgramOutputs(); |
375 | 415 |
376 // Process the program log, replacing the hashed names with original names. | 416 // Process the program log, replacing the hashed names with original names. |
377 std::string ProcessLogInfo(const std::string& log); | 417 std::string ProcessLogInfo(const std::string& log); |
378 | 418 |
379 // Updates the program log info from GL | 419 // Updates the program log info from GL |
380 void UpdateLogInfo(); | 420 void UpdateLogInfo(); |
381 | 421 |
382 template <typename VarT> | 422 template <typename VarT> |
383 void GetUniformBlockMembers( | 423 void GetUniformBlockMembers( |
384 Shader* shader, const std::vector<VarT>& fields, | 424 Shader* shader, const std::vector<VarT>& fields, |
(...skipping 13 matching lines...) Expand all Loading... |
398 // glBindAttribLocation() again with the mapped names. | 438 // glBindAttribLocation() again with the mapped names. |
399 // This is called right before the glLink() call, but after shaders are | 439 // This is called right before the glLink() call, but after shaders are |
400 // translated. | 440 // translated. |
401 void ExecuteBindAttribLocationCalls(); | 441 void ExecuteBindAttribLocationCalls(); |
402 | 442 |
403 // The names of transform feedback varyings need to be hashed just | 443 // The names of transform feedback varyings need to be hashed just |
404 // like bound attributes' locations, just before the link call. | 444 // like bound attributes' locations, just before the link call. |
405 // Returns false upon failure. | 445 // Returns false upon failure. |
406 bool ExecuteTransformFeedbackVaryingsCall(); | 446 bool ExecuteTransformFeedbackVaryingsCall(); |
407 | 447 |
| 448 void ExecuteProgramOutputBindCalls(); |
| 449 |
408 // Query VertexAttrib data returned by ANGLE translator by the mapped name. | 450 // Query VertexAttrib data returned by ANGLE translator by the mapped name. |
409 void GetVertexAttribData( | 451 void GetVertexAttribData( |
410 const std::string& name, std::string* original_name, GLenum* type) const; | 452 const std::string& name, std::string* original_name, GLenum* type) const; |
411 | 453 |
412 void DetachShaders(ShaderManager* manager); | 454 void DetachShaders(ShaderManager* manager); |
413 | 455 |
414 static inline size_t GetUniformLocationIndexFromFakeLocation( | 456 static inline size_t GetUniformLocationIndexFromFakeLocation( |
415 GLint fake_location) { | 457 GLint fake_location) { |
416 return static_cast<size_t>(fake_location & 0xFFFF); | 458 return static_cast<size_t>(fake_location & 0xFFFF); |
417 } | 459 } |
(...skipping 22 matching lines...) Expand all Loading... |
440 // Uniform info by index. | 482 // Uniform info by index. |
441 UniformInfoVector uniform_infos_; | 483 UniformInfoVector uniform_infos_; |
442 UniformLocationVector uniform_locations_; | 484 UniformLocationVector uniform_locations_; |
443 | 485 |
444 // The indices of the uniforms that are samplers. | 486 // The indices of the uniforms that are samplers. |
445 SamplerIndices sampler_indices_; | 487 SamplerIndices sampler_indices_; |
446 | 488 |
447 FragmentInputInfoVector fragment_input_infos_; | 489 FragmentInputInfoVector fragment_input_infos_; |
448 FragmentInputLocationVector fragment_input_locations_; | 490 FragmentInputLocationVector fragment_input_locations_; |
449 | 491 |
| 492 ProgramOutputInfoVector program_output_infos_; |
| 493 |
450 // The program this Program is tracking. | 494 // The program this Program is tracking. |
451 GLuint service_id_; | 495 GLuint service_id_; |
452 | 496 |
453 // Shaders by type of shader. | 497 // Shaders by type of shader. |
454 scoped_refptr<Shader> | 498 scoped_refptr<Shader> |
455 attached_shaders_[kMaxAttachedShaders]; | 499 attached_shaders_[kMaxAttachedShaders]; |
456 | 500 |
457 // True if this program is marked as deleted. | 501 // True if this program is marked as deleted. |
458 bool deleted_; | 502 bool deleted_; |
459 | 503 |
(...skipping 15 matching lines...) Expand all Loading... |
475 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. | 519 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. |
476 LocationMap bind_uniform_location_map_; | 520 LocationMap bind_uniform_location_map_; |
477 | 521 |
478 std::vector<std::string> transform_feedback_varyings_; | 522 std::vector<std::string> transform_feedback_varyings_; |
479 | 523 |
480 GLenum transform_feedback_buffer_mode_; | 524 GLenum transform_feedback_buffer_mode_; |
481 | 525 |
482 // Fragment input-location binding map from | 526 // Fragment input-location binding map from |
483 // glBindFragmentInputLocationCHROMIUM() calls. | 527 // glBindFragmentInputLocationCHROMIUM() calls. |
484 LocationMap bind_fragment_input_location_map_; | 528 LocationMap bind_fragment_input_location_map_; |
| 529 |
| 530 // output variable - (location,index) binding map from |
| 531 // glBindFragDataLocation() and ..IndexedEXT() calls. |
| 532 LocationIndexMap bind_program_output_location_index_map_; |
485 }; | 533 }; |
486 | 534 |
487 // Tracks the Programs. | 535 // Tracks the Programs. |
488 // | 536 // |
489 // NOTE: To support shared resources an instance of this class will | 537 // NOTE: To support shared resources an instance of this class will |
490 // need to be shared by multiple GLES2Decoders. | 538 // need to be shared by multiple GLES2Decoders. |
491 class GPU_EXPORT ProgramManager { | 539 class GPU_EXPORT ProgramManager { |
492 public: | 540 public: |
493 explicit ProgramManager(ProgramCache* program_cache, | 541 explicit ProgramManager(ProgramCache* program_cache, |
494 uint32 max_varying_vectors, | 542 uint32 max_varying_vectors, |
| 543 uint32 max_dual_source_draw_buffers, |
495 FeatureInfo* feature_info); | 544 FeatureInfo* feature_info); |
496 ~ProgramManager(); | 545 ~ProgramManager(); |
497 | 546 |
498 // Must call before destruction. | 547 // Must call before destruction. |
499 void Destroy(bool have_context); | 548 void Destroy(bool have_context); |
500 | 549 |
501 // Creates a new program. | 550 // Creates a new program. |
502 Program* CreateProgram(GLuint client_id, GLuint service_id); | 551 Program* CreateProgram(GLuint client_id, GLuint service_id); |
503 | 552 |
504 // Gets a program. | 553 // Gets a program. |
(...skipping 10 matching lines...) Expand all Loading... |
515 | 564 |
516 // Marks a program as used. | 565 // Marks a program as used. |
517 void UseProgram(Program* program); | 566 void UseProgram(Program* program); |
518 | 567 |
519 // Makes a program as unused. If deleted the program will be removed. | 568 // Makes a program as unused. If deleted the program will be removed. |
520 void UnuseProgram(ShaderManager* shader_manager, Program* program); | 569 void UnuseProgram(ShaderManager* shader_manager, Program* program); |
521 | 570 |
522 // Clears the uniforms for this program. | 571 // Clears the uniforms for this program. |
523 void ClearUniforms(Program* program); | 572 void ClearUniforms(Program* program); |
524 | 573 |
525 // Returns true if prefix is invalid for gl. | 574 // Returns true if |name| has a prefix that is intended for GL built-in shader |
526 static bool IsInvalidPrefix(const char* name, size_t length); | 575 // variables. |
| 576 static bool HasBuiltInPrefix(const std::string& name); |
527 | 577 |
528 // Check if a Program is owned by this ProgramManager. | 578 // Check if a Program is owned by this ProgramManager. |
529 bool IsOwned(Program* program) const; | 579 bool IsOwned(Program* program) const; |
530 | 580 |
531 static int32 MakeFakeLocation(int32 index, int32 element); | 581 static int32 MakeFakeLocation(int32 index, int32 element); |
532 | 582 |
533 uint32 max_varying_vectors() const { | 583 uint32 max_varying_vectors() const { |
534 return max_varying_vectors_; | 584 return max_varying_vectors_; |
535 } | 585 } |
536 | 586 |
| 587 uint32 max_dual_source_draw_buffers() const { |
| 588 return max_dual_source_draw_buffers_; |
| 589 } |
| 590 |
537 private: | 591 private: |
538 friend class Program; | 592 friend class Program; |
539 | 593 |
540 void StartTracking(Program* program); | 594 void StartTracking(Program* program); |
541 void StopTracking(Program* program); | 595 void StopTracking(Program* program); |
542 | 596 |
543 void RemoveProgramInfoIfUnused( | 597 void RemoveProgramInfoIfUnused( |
544 ShaderManager* shader_manager, Program* program); | 598 ShaderManager* shader_manager, Program* program); |
545 | 599 |
546 // Info for each "successfully linked" program by service side program Id. | 600 // Info for each "successfully linked" program by service side program Id. |
547 // TODO(gman): Choose a faster container. | 601 // TODO(gman): Choose a faster container. |
548 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; | 602 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; |
549 ProgramMap programs_; | 603 ProgramMap programs_; |
550 | 604 |
551 // Counts the number of Program allocated with 'this' as its manager. | 605 // Counts the number of Program allocated with 'this' as its manager. |
552 // Allows to check no Program will outlive this. | 606 // Allows to check no Program will outlive this. |
553 unsigned int program_count_; | 607 unsigned int program_count_; |
554 | 608 |
555 bool have_context_; | 609 bool have_context_; |
556 | 610 |
557 // Used to clear uniforms. | 611 // Used to clear uniforms. |
558 std::vector<uint8> zero_; | 612 std::vector<uint8> zero_; |
559 | 613 |
560 ProgramCache* program_cache_; | 614 ProgramCache* program_cache_; |
561 | 615 |
562 uint32 max_varying_vectors_; | 616 uint32 max_varying_vectors_; |
| 617 uint32 max_dual_source_draw_buffers_; |
563 | 618 |
564 scoped_refptr<FeatureInfo> feature_info_; | 619 scoped_refptr<FeatureInfo> feature_info_; |
565 | 620 |
566 DISALLOW_COPY_AND_ASSIGN(ProgramManager); | 621 DISALLOW_COPY_AND_ASSIGN(ProgramManager); |
567 }; | 622 }; |
568 | 623 |
569 inline const FeatureInfo& Program::feature_info() const { | 624 inline const FeatureInfo& Program::feature_info() const { |
570 return *manager_->feature_info_.get(); | 625 return *manager_->feature_info_.get(); |
571 } | 626 } |
572 | 627 |
573 } // namespace gles2 | 628 } // namespace gles2 |
574 } // namespace gpu | 629 } // namespace gpu |
575 | 630 |
576 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ | 631 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ |
OLD | NEW |