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

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

Issue 147593011: Hookup clear_uniforms_before_first_program_use workaround with implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: same Created 6 years, 10 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 | Annotate | Revision Log
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;
24 class ProgramCache; 23 class ProgramCache;
25 class ProgramManager; 24 class ProgramManager;
26 class Shader; 25 class Shader;
27 class ShaderManager; 26 class ShaderManager;
28 class ShaderTranslator; 27 class ShaderTranslator;
29 28
30 // This is used to track which attributes a particular program needs 29 // This is used to track which attributes a particular program needs
31 // 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
32 // or if enabled that it points to a valid source. 31 // or if enabled that it points to a valid source.
33 class GPU_EXPORT Program : public base::RefCounted<Program> { 32 class GPU_EXPORT Program : public base::RefCounted<Program> {
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 149
151 bool AttachShader(ShaderManager* manager, Shader* shader); 150 bool AttachShader(ShaderManager* manager, Shader* shader);
152 bool DetachShader(ShaderManager* manager, Shader* shader); 151 bool DetachShader(ShaderManager* manager, Shader* shader);
153 152
154 bool CanLink() const; 153 bool CanLink() const;
155 154
156 // Performs glLinkProgram and related activities. 155 // Performs glLinkProgram and related activities.
157 bool Link(ShaderManager* manager, 156 bool Link(ShaderManager* manager,
158 ShaderTranslator* vertex_translator, 157 ShaderTranslator* vertex_translator,
159 ShaderTranslator* fragment_shader, 158 ShaderTranslator* fragment_shader,
160 FeatureInfo* feature_info,
161 const ShaderCacheCallback& shader_callback); 159 const ShaderCacheCallback& shader_callback);
162 160
163 // Performs glValidateProgram and related activities. 161 // Performs glValidateProgram and related activities.
164 void Validate(); 162 void Validate();
165 163
166 const std::string* log_info() const { 164 const std::string* log_info() const {
167 return log_info_.get(); 165 return log_info_.get();
168 } 166 }
169 167
170 bool InUse() const { 168 bool InUse() const {
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. 328 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls.
331 LocationMap bind_uniform_location_map_; 329 LocationMap bind_uniform_location_map_;
332 }; 330 };
333 331
334 // Tracks the Programs. 332 // Tracks the Programs.
335 // 333 //
336 // NOTE: To support shared resources an instance of this class will 334 // NOTE: To support shared resources an instance of this class will
337 // need to be shared by multiple GLES2Decoders. 335 // need to be shared by multiple GLES2Decoders.
338 class GPU_EXPORT ProgramManager { 336 class GPU_EXPORT ProgramManager {
339 public: 337 public:
338 enum TranslatedShaderSourceType {
339 kANGLE,
340 kGL, // GL or GLES
341 };
342
340 explicit ProgramManager(ProgramCache* program_cache, 343 explicit ProgramManager(ProgramCache* program_cache,
341 uint32 max_varying_vectors); 344 uint32 max_varying_vectors);
342 ~ProgramManager(); 345 ~ProgramManager();
343 346
344 // Must call before destruction. 347 // Must call before destruction.
345 void Destroy(bool have_context); 348 void Destroy(bool have_context);
346 349
347 // Creates a new program. 350 // Creates a new program.
348 Program* CreateProgram(GLuint client_id, GLuint service_id); 351 Program* CreateProgram(GLuint client_id, GLuint service_id);
349 352
(...skipping 19 matching lines...) Expand all
369 void ClearUniforms(Program* program); 372 void ClearUniforms(Program* program);
370 373
371 // Returns true if prefix is invalid for gl. 374 // Returns true if prefix is invalid for gl.
372 static bool IsInvalidPrefix(const char* name, size_t length); 375 static bool IsInvalidPrefix(const char* name, size_t length);
373 376
374 // Check if a Program is owned by this ProgramManager. 377 // Check if a Program is owned by this ProgramManager.
375 bool IsOwned(Program* program); 378 bool IsOwned(Program* program);
376 379
377 static int32 MakeFakeLocation(int32 index, int32 element); 380 static int32 MakeFakeLocation(int32 index, int32 element);
378 381
379 void DoCompileShader(Shader* shader, 382 void DoCompileShader(
380 ShaderTranslator* translator, 383 Shader* shader,
381 FeatureInfo* feature_info); 384 ShaderTranslator* translator,
385 TranslatedShaderSourceType translated_shader_source_type);
382 386
383 uint32 max_varying_vectors() const { 387 uint32 max_varying_vectors() const {
384 return max_varying_vectors_; 388 return max_varying_vectors_;
385 } 389 }
386 390
387 private: 391 private:
388 friend class Program; 392 friend class Program;
389 393
390 void StartTracking(Program* program); 394 void StartTracking(Program* program);
391 void StopTracking(Program* program); 395 void StopTracking(Program* program);
392 396
393 void RemoveProgramInfoIfUnused( 397 void RemoveProgramInfoIfUnused(
394 ShaderManager* shader_manager, Program* program); 398 ShaderManager* shader_manager, Program* program);
395 399
396 // Info for each "successfully linked" program by service side program Id. 400 // Info for each "successfully linked" program by service side program Id.
397 // TODO(gman): Choose a faster container. 401 // TODO(gman): Choose a faster container.
398 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; 402 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap;
399 ProgramMap programs_; 403 ProgramMap programs_;
400 404
401 // Counts the number of Program allocated with 'this' as its manager. 405 // Counts the number of Program allocated with 'this' as its manager.
402 // Allows to check no Program will outlive this. 406 // Allows to check no Program will outlive this.
403 unsigned int program_count_; 407 unsigned int program_count_;
404 408
405 bool have_context_; 409 bool have_context_;
406 410
407 bool disable_workarounds_;
408
409 // Used to clear uniforms. 411 // Used to clear uniforms.
410 std::vector<uint8> zero_; 412 std::vector<uint8> zero_;
411 413
412 ProgramCache* program_cache_; 414 ProgramCache* program_cache_;
413 415
414 uint32 max_varying_vectors_; 416 uint32 max_varying_vectors_;
415 417
416 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 418 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
417 }; 419 };
418 420
419 } // namespace gles2 421 } // namespace gles2
420 } // namespace gpu 422 } // namespace gpu
421 423
422 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 424 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc ('k') | gpu/command_buffer/service/program_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698