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

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

Issue 148153025: Merge 249460 "Hookup clear_uniforms_before_first_program_use wor..." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1750/src/
Patch Set: 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 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls. 327 // uniform-location binding map from glBindUniformLocationCHROMIUM() calls.
330 LocationMap bind_uniform_location_map_; 328 LocationMap bind_uniform_location_map_;
331 }; 329 };
332 330
333 // Tracks the Programs. 331 // Tracks the Programs.
334 // 332 //
335 // NOTE: To support shared resources an instance of this class will 333 // NOTE: To support shared resources an instance of this class will
336 // need to be shared by multiple GLES2Decoders. 334 // need to be shared by multiple GLES2Decoders.
337 class GPU_EXPORT ProgramManager { 335 class GPU_EXPORT ProgramManager {
338 public: 336 public:
337 enum TranslatedShaderSourceType {
338 kANGLE,
339 kGL, // GL or GLES
340 };
341
339 explicit ProgramManager(ProgramCache* program_cache, 342 explicit ProgramManager(ProgramCache* program_cache,
340 uint32 max_varying_vectors); 343 uint32 max_varying_vectors);
341 ~ProgramManager(); 344 ~ProgramManager();
342 345
343 // Must call before destruction. 346 // Must call before destruction.
344 void Destroy(bool have_context); 347 void Destroy(bool have_context);
345 348
346 // Creates a new program. 349 // Creates a new program.
347 Program* CreateProgram(GLuint client_id, GLuint service_id); 350 Program* CreateProgram(GLuint client_id, GLuint service_id);
348 351
(...skipping 19 matching lines...) Expand all
368 void ClearUniforms(Program* program); 371 void ClearUniforms(Program* program);
369 372
370 // Returns true if prefix is invalid for gl. 373 // Returns true if prefix is invalid for gl.
371 static bool IsInvalidPrefix(const char* name, size_t length); 374 static bool IsInvalidPrefix(const char* name, size_t length);
372 375
373 // Check if a Program is owned by this ProgramManager. 376 // Check if a Program is owned by this ProgramManager.
374 bool IsOwned(Program* program); 377 bool IsOwned(Program* program);
375 378
376 static int32 MakeFakeLocation(int32 index, int32 element); 379 static int32 MakeFakeLocation(int32 index, int32 element);
377 380
378 void DoCompileShader(Shader* shader, 381 void DoCompileShader(
379 ShaderTranslator* translator, 382 Shader* shader,
380 FeatureInfo* feature_info); 383 ShaderTranslator* translator,
384 TranslatedShaderSourceType translated_shader_source_type);
381 385
382 uint32 max_varying_vectors() const { 386 uint32 max_varying_vectors() const {
383 return max_varying_vectors_; 387 return max_varying_vectors_;
384 } 388 }
385 389
386 private: 390 private:
387 friend class Program; 391 friend class Program;
388 392
389 void StartTracking(Program* program); 393 void StartTracking(Program* program);
390 void StopTracking(Program* program); 394 void StopTracking(Program* program);
391 395
392 void RemoveProgramInfoIfUnused( 396 void RemoveProgramInfoIfUnused(
393 ShaderManager* shader_manager, Program* program); 397 ShaderManager* shader_manager, Program* program);
394 398
395 // Info for each "successfully linked" program by service side program Id. 399 // Info for each "successfully linked" program by service side program Id.
396 // TODO(gman): Choose a faster container. 400 // TODO(gman): Choose a faster container.
397 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap; 401 typedef std::map<GLuint, scoped_refptr<Program> > ProgramMap;
398 ProgramMap programs_; 402 ProgramMap programs_;
399 403
400 // Counts the number of Program allocated with 'this' as its manager. 404 // Counts the number of Program allocated with 'this' as its manager.
401 // Allows to check no Program will outlive this. 405 // Allows to check no Program will outlive this.
402 unsigned int program_count_; 406 unsigned int program_count_;
403 407
404 bool have_context_; 408 bool have_context_;
405 409
406 bool disable_workarounds_;
407
408 // Used to clear uniforms. 410 // Used to clear uniforms.
409 std::vector<uint8> zero_; 411 std::vector<uint8> zero_;
410 412
411 ProgramCache* program_cache_; 413 ProgramCache* program_cache_;
412 414
413 uint32 max_varying_vectors_; 415 uint32 max_varying_vectors_;
414 416
415 DISALLOW_COPY_AND_ASSIGN(ProgramManager); 417 DISALLOW_COPY_AND_ASSIGN(ProgramManager);
416 }; 418 };
417 419
418 } // namespace gles2 420 } // namespace gles2
419 } // namespace gpu 421 } // namespace gpu
420 422
421 #endif // GPU_COMMAND_BUFFER_SERVICE_PROGRAM_MANAGER_H_ 423 #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