Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: gpu/command_buffer/service/program_manager.h

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 177
177 // Gets all the TransformFeedbackVarying info. 178 // Gets all the TransformFeedbackVarying info.
178 // Return false on overflow. 179 // Return false on overflow.
179 bool GetTransformFeedbackVaryings(CommonDecoder::Bucket* bucket) const; 180 bool GetTransformFeedbackVaryings(CommonDecoder::Bucket* bucket) const;
180 181
181 // Gather all info through glGetActiveUniformsiv, except for size, type, 182 // Gather all info through glGetActiveUniformsiv, except for size, type,
182 // name_length, which we gather through glGetActiveUniform in 183 // name_length, which we gather through glGetActiveUniform in
183 // glGetProgramInfoCHROMIUM. 184 // glGetProgramInfoCHROMIUM.
184 bool GetUniformsES3(CommonDecoder::Bucket* bucket) const; 185 bool GetUniformsES3(CommonDecoder::Bucket* bucket) const;
185 186
187 // Returns the fragment shader output variable color name binding.
188 // Returns -1 if |original_name| is not an out variable or error.
189 GLint GetFragDataLocation(const std::string& original_name) const;
190
191 // Returns the fragment shader output variable color index binding.
192 // Returns -1 if |original_name| is not an out variable or error.
193 GLint GetFragDataIndex(const std::string& original_name) const;
194
186 // Sets the sampler values for a uniform. 195 // Sets the sampler values for a uniform.
187 // This is safe to call for any location. If the location is not 196 // This is safe to call for any location. If the location is not
188 // a sampler uniform nothing will happen. 197 // a sampler uniform nothing will happen.
189 // Returns false if fake_location is a sampler and any value 198 // Returns false if fake_location is a sampler and any value
190 // is >= num_texture_units. Returns true otherwise. 199 // is >= num_texture_units. Returns true otherwise.
191 bool SetSamplers( 200 bool SetSamplers(
192 GLint num_texture_units, GLint fake_location, 201 GLint num_texture_units, GLint fake_location,
193 GLsizei count, const GLint* value); 202 GLsizei count, const GLint* value);
194 203
195 bool IsDeleted() const { 204 bool IsDeleted() const {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 335
327 // Clears all the uniforms. 336 // Clears all the uniforms.
328 void ClearUniforms(std::vector<uint8>* zero_buffer); 337 void ClearUniforms(std::vector<uint8>* zero_buffer);
329 338
330 // If long attribate names are mapped during shader translation, call 339 // If long attribate names are mapped during shader translation, call
331 // glBindAttribLocation() again with the mapped names. 340 // glBindAttribLocation() again with the mapped names.
332 // This is called right before the glLink() call, but after shaders are 341 // This is called right before the glLink() call, but after shaders are
333 // translated. 342 // translated.
334 void ExecuteBindAttribLocationCalls(); 343 void ExecuteBindAttribLocationCalls();
335 344
345 void ExecuteBindFragDataLocationIndexedCalls();
346
336 bool AddUniformInfo( 347 bool AddUniformInfo(
337 GLsizei size, GLenum type, GLint location, GLint fake_base_location, 348 GLsizei size, GLenum type, GLint location, GLint fake_base_location,
338 const std::string& name, const std::string& original_name, 349 const std::string& name, const std::string& original_name,
339 size_t* next_available_index); 350 size_t* next_available_index);
340 351
341 enum VariableInfoType { kUniformVariableInfo, kVaryingVariableInfo }; 352 enum VariableInfoType { kUniformVariableInfo, kVaryingVariableInfo };
342 // Query uniform or varying data returned by ANGLE translator by the 353 // Query uniform or varying data returned by ANGLE translator by the
343 // mapped name. Some drivers incorrectly return an uniform name of 354 // mapped name. Some drivers incorrectly return an uniform name of
344 // size-1 array without "[0]". In this case, we correct the name by 355 // size-1 array without "[0]". In this case, we correct the name by
345 // appending "[0]" to it. 356 // appending "[0]" to it.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 }; 450 };
440 451
441 // Tracks the Programs. 452 // Tracks the Programs.
442 // 453 //
443 // NOTE: To support shared resources an instance of this class will 454 // NOTE: To support shared resources an instance of this class will
444 // need to be shared by multiple GLES2Decoders. 455 // need to be shared by multiple GLES2Decoders.
445 class GPU_EXPORT ProgramManager { 456 class GPU_EXPORT ProgramManager {
446 public: 457 public:
447 explicit ProgramManager(ProgramCache* program_cache, 458 explicit ProgramManager(ProgramCache* program_cache,
448 uint32 max_varying_vectors, 459 uint32 max_varying_vectors,
460 uint32 max_dual_source_draw_buffers,
449 FeatureInfo* feature_info); 461 FeatureInfo* feature_info);
450 ~ProgramManager(); 462 ~ProgramManager();
451 463
452 // Must call before destruction. 464 // Must call before destruction.
453 void Destroy(bool have_context); 465 void Destroy(bool have_context);
454 466
455 // Creates a new program. 467 // Creates a new program.
456 Program* CreateProgram(GLuint client_id, GLuint service_id); 468 Program* CreateProgram(GLuint client_id, GLuint service_id);
457 469
458 // Gets a program. 470 // Gets a program.
(...skipping 22 matching lines...) Expand all
481 493
482 // Check if a Program is owned by this ProgramManager. 494 // Check if a Program is owned by this ProgramManager.
483 bool IsOwned(Program* program); 495 bool IsOwned(Program* program);
484 496
485 static int32 MakeFakeLocation(int32 index, int32 element); 497 static int32 MakeFakeLocation(int32 index, int32 element);
486 498
487 uint32 max_varying_vectors() const { 499 uint32 max_varying_vectors() const {
488 return max_varying_vectors_; 500 return max_varying_vectors_;
489 } 501 }
490 502
503 uint32 max_dual_source_draw_buffers() const {
504 return max_dual_source_draw_buffers_;
505 }
506
491 private: 507 private:
492 friend class Program; 508 friend class Program;
493 509
494 void StartTracking(Program* program); 510 void StartTracking(Program* program);
495 void StopTracking(Program* program); 511 void StopTracking(Program* program);
496 512
497 void RemoveProgramInfoIfUnused( 513 void RemoveProgramInfoIfUnused(
498 ShaderManager* shader_manager, Program* program); 514 ShaderManager* shader_manager, Program* program);
499 515
500 // Info for each "successfully linked" program by service side program Id. 516 // Info for each "successfully linked" program by service side program Id.
501 // TODO(gman): Choose a faster container. 517 // TODO(gman): Choose a faster container.
502 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; 518 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap;
503 ProgramMap programs_; 519 ProgramMap programs_;
504 520
505 // Counts the number of Program allocated with 'this' as its manager. 521 // Counts the number of Program allocated with 'this' as its manager.
506 // Allows to check no Program will outlive this. 522 // Allows to check no Program will outlive this.
507 unsigned int program_count_; 523 unsigned int program_count_;
508 524
509 bool have_context_; 525 bool have_context_;
510 526
511 // Used to clear uniforms. 527 // Used to clear uniforms.
512 std::vector<uint8> zero_; 528 std::vector<uint8> zero_;
513 529
514 ProgramCache* program_cache_; 530 ProgramCache* program_cache_;
515 531
516 uint32 max_varying_vectors_; 532 uint32 max_varying_vectors_;
533 uint32 max_dual_source_draw_buffers_;
517 534
518 scoped_refptr<FeatureInfo> feature_info_; 535 scoped_refptr<FeatureInfo> feature_info_;
519 536
520 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 537 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
521 }; 538 };
522 539
523 inline const FeatureInfo& Program::feature_info() const { 540 inline const FeatureInfo& Program::feature_info() const {
524 return *manager_->feature_info_.get(); 541 return *manager_->feature_info_.get();
525 } 542 }
526 543
527 } // namespace gles2 544 } // namespace gles2
528 } // namespace gpu 545 } // namespace gpu
529 546
530 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 547 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698