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

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

Issue 11516014: Track managed memory usage in the command buffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix unit test compile error Created 8 years 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_TEXTURE_MANAGER_H_ 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/hash_tables.h" 11 #include "base/hash_tables.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/feature_info.h" 14 #include "gpu/command_buffer/service/feature_info.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/memory_tracking.h"
16 #include "gpu/gpu_export.h" 17 #include "gpu/gpu_export.h"
17 #include "ui/gl/gl_image.h" 18 #include "ui/gl/gl_image.h"
18 19
19 namespace gpu { 20 namespace gpu {
20 namespace gles2 { 21 namespace gles2 {
21 22
22 class GLES2Decoder; 23 class GLES2Decoder;
23 class Display; 24 class Display;
24 class TextureDefinition; 25 class TextureDefinition;
25 class MemoryTracker;
26 class MemoryTypeTracker;
27 26
28 // This class keeps track of the textures and their sizes so we can do NPOT and 27 // This class keeps track of the textures and their sizes so we can do NPOT and
29 // texture complete checking. 28 // texture complete checking.
30 // 29 //
31 // NOTE: To support shared resources an instance of this class will need to be 30 // NOTE: To support shared resources an instance of this class will need to be
32 // shared by multiple GLES2Decoders. 31 // shared by multiple GLES2Decoders.
33 class GPU_EXPORT TextureManager { 32 class GPU_EXPORT TextureManager {
34 public: 33 public:
35 enum DefaultAndBlackTextures { 34 enum DefaultAndBlackTextures {
36 kTexture2D, 35 kTexture2D,
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP. 304 // The target. 0 if unset, otherwise GL_TEXTURE_2D or GL_TEXTURE_CUBE_MAP.
306 GLenum target_; 305 GLenum target_;
307 306
308 // Texture parameters. 307 // Texture parameters.
309 GLenum min_filter_; 308 GLenum min_filter_;
310 GLenum mag_filter_; 309 GLenum mag_filter_;
311 GLenum wrap_s_; 310 GLenum wrap_s_;
312 GLenum wrap_t_; 311 GLenum wrap_t_;
313 GLenum usage_; 312 GLenum usage_;
314 313
314 // The accounting pool towards which the memory for this allocation should
315 // be charged. This will be rolled into a new GLenum texture parameter in
316 // a separate change.
317 MemoryTracker::Pool tracking_pool_;
318
315 // The maximum level that has been set. 319 // The maximum level that has been set.
316 GLint max_level_set_; 320 GLint max_level_set_;
317 321
318 // Whether or not this texture is "texture complete" 322 // Whether or not this texture is "texture complete"
319 bool texture_complete_; 323 bool texture_complete_;
320 324
321 // Whether or not this texture is "cube complete" 325 // Whether or not this texture is "cube complete"
322 bool cube_complete_; 326 bool cube_complete_;
323 327
324 // Whether or not this texture is non-power-of-two 328 // Whether or not this texture is non-power-of-two
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 case GL_SAMPLER_EXTERNAL_OES: 505 case GL_SAMPLER_EXTERNAL_OES:
502 return black_texture_ids_[kExternalOES]; 506 return black_texture_ids_[kExternalOES];
503 case GL_SAMPLER_2D_RECT_ARB: 507 case GL_SAMPLER_2D_RECT_ARB:
504 return black_texture_ids_[kRectangleARB]; 508 return black_texture_ids_[kRectangleARB];
505 default: 509 default:
506 NOTREACHED(); 510 NOTREACHED();
507 return 0; 511 return 0;
508 } 512 }
509 } 513 }
510 514
511 uint32 mem_represented() const { 515 size_t mem_represented() const {
512 return mem_represented_; 516 return
517 memory_tracker_managed_->GetMemRepresented() +
518 memory_tracker_unmanaged_->GetMemRepresented();
513 } 519 }
514 520
515 void SetLevelImage( 521 void SetLevelImage(
516 TextureInfo* info, 522 TextureInfo* info,
517 GLenum target, 523 GLenum target,
518 GLint level, 524 GLint level,
519 gfx::GLImage* image); 525 gfx::GLImage* image);
520 526
521 void AddToSignature( 527 void AddToSignature(
522 TextureInfo* info, 528 TextureInfo* info,
523 GLenum target, 529 GLenum target,
524 GLint level, 530 GLint level,
525 std::string* signature) const; 531 std::string* signature) const;
526 532
527 private: 533 private:
528 // Helper for Initialize(). 534 // Helper for Initialize().
529 TextureInfo::Ref CreateDefaultAndBlackTextures( 535 TextureInfo::Ref CreateDefaultAndBlackTextures(
530 GLenum target, 536 GLenum target,
531 GLuint* black_texture); 537 GLuint* black_texture);
532 538
533 void UpdateMemRepresented();
534
535 void StartTracking(TextureInfo* info); 539 void StartTracking(TextureInfo* info);
536 void StopTracking(TextureInfo* info); 540 void StopTracking(TextureInfo* info);
537 541
538 scoped_ptr<MemoryTypeTracker> texture_memory_tracker_; 542 MemoryTypeTracker* GetMemTracker(MemoryTracker::Pool tracking_pool);
543 scoped_ptr<MemoryTypeTracker> memory_tracker_managed_;
544 scoped_ptr<MemoryTypeTracker> memory_tracker_unmanaged_;
539 545
540 FeatureInfo::Ref feature_info_; 546 FeatureInfo::Ref feature_info_;
541 547
542 // Info for each texture in the system. 548 // Info for each texture in the system.
543 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap; 549 typedef base::hash_map<GLuint, TextureInfo::Ref> TextureInfoMap;
544 TextureInfoMap texture_infos_; 550 TextureInfoMap texture_infos_;
545 551
546 GLsizei max_texture_size_; 552 GLsizei max_texture_size_;
547 GLsizei max_cube_map_texture_size_; 553 GLsizei max_cube_map_texture_size_;
548 GLint max_levels_; 554 GLint max_levels_;
549 GLint max_cube_map_levels_; 555 GLint max_cube_map_levels_;
550 556
551 int num_unrenderable_textures_; 557 int num_unrenderable_textures_;
552 int num_unsafe_textures_; 558 int num_unsafe_textures_;
553 int num_uncleared_mips_; 559 int num_uncleared_mips_;
554 560
555 // Counts the number of TextureInfo allocated with 'this' as its manager. 561 // Counts the number of TextureInfo allocated with 'this' as its manager.
556 // Allows to check no TextureInfo will outlive this. 562 // Allows to check no TextureInfo will outlive this.
557 unsigned int texture_info_count_; 563 unsigned int texture_info_count_;
558 564
559 uint32 mem_represented_;
560
561 bool have_context_; 565 bool have_context_;
562 566
563 // Black (0,0,0,1) textures for when non-renderable textures are used. 567 // Black (0,0,0,1) textures for when non-renderable textures are used.
564 // NOTE: There is no corresponding TextureInfo for these textures. 568 // NOTE: There is no corresponding TextureInfo for these textures.
565 // TextureInfos are only for textures the client side can access. 569 // TextureInfos are only for textures the client side can access.
566 GLuint black_texture_ids_[kNumDefaultTextures]; 570 GLuint black_texture_ids_[kNumDefaultTextures];
567 571
568 // The default textures for each target (texture name = 0) 572 // The default textures for each target (texture name = 0)
569 TextureInfo::Ref default_textures_[kNumDefaultTextures]; 573 TextureInfo::Ref default_textures_[kNumDefaultTextures];
570 574
571 DISALLOW_COPY_AND_ASSIGN(TextureManager); 575 DISALLOW_COPY_AND_ASSIGN(TextureManager);
572 }; 576 };
573 577
574 } // namespace gles2 578 } // namespace gles2
575 } // namespace gpu 579 } // namespace gpu
576 580
577 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_ 581 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_MANAGER_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/renderbuffer_manager.cc ('k') | gpu/command_buffer/service/texture_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698