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 #include "gpu/command_buffer/service/texture_manager.h" | 5 #include "gpu/command_buffer/service/texture_manager.h" |
6 #include "base/bits.h" | 6 #include "base/bits.h" |
7 #include "base/debug/trace_event.h" | |
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 7 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
9 #include "gpu/command_buffer/service/feature_info.h" | 8 #include "gpu/command_buffer/service/feature_info.h" |
10 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 9 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
11 #include "gpu/command_buffer/service/mailbox_manager.h" | 10 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 11 #include "gpu/command_buffer/service/memory_tracking.h" |
12 #include "gpu/command_buffer/service/texture_definition.h" | 12 #include "gpu/command_buffer/service/texture_definition.h" |
13 | 13 |
14 namespace gpu { | 14 namespace gpu { |
15 namespace gles2 { | 15 namespace gles2 { |
16 | 16 |
17 static size_t GLTargetToFaceIndex(GLenum target) { | 17 static size_t GLTargetToFaceIndex(GLenum target) { |
18 switch (target) { | 18 switch (target) { |
19 case GL_TEXTURE_2D: | 19 case GL_TEXTURE_2D: |
20 case GL_TEXTURE_EXTERNAL_OES: | 20 case GL_TEXTURE_EXTERNAL_OES: |
21 case GL_TEXTURE_RECTANGLE_ARB: | 21 case GL_TEXTURE_RECTANGLE_ARB: |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 info.cleared = decoder->ClearLevel( | 582 info.cleared = decoder->ClearLevel( |
583 service_id_, target_, info.target, info.level, info.format, info.type, | 583 service_id_, target_, info.target, info.level, info.format, info.type, |
584 info.width, info.height, immutable_); | 584 info.width, info.height, immutable_); |
585 if (!info.cleared) { | 585 if (!info.cleared) { |
586 ++num_uncleared_mips_; | 586 ++num_uncleared_mips_; |
587 } | 587 } |
588 return info.cleared; | 588 return info.cleared; |
589 } | 589 } |
590 | 590 |
591 TextureManager::TextureManager( | 591 TextureManager::TextureManager( |
| 592 MemoryTracker* memory_tracker, |
592 FeatureInfo* feature_info, | 593 FeatureInfo* feature_info, |
593 GLint max_texture_size, | 594 GLint max_texture_size, |
594 GLint max_cube_map_texture_size) | 595 GLint max_cube_map_texture_size) |
595 : feature_info_(feature_info), | 596 : texture_memory_tracker_(new MemoryTypeTracker( |
| 597 memory_tracker, |
| 598 "TextureManager", |
| 599 "TextureMemory")), |
| 600 feature_info_(feature_info), |
596 max_texture_size_(max_texture_size), | 601 max_texture_size_(max_texture_size), |
597 max_cube_map_texture_size_(max_cube_map_texture_size), | 602 max_cube_map_texture_size_(max_cube_map_texture_size), |
598 max_levels_(ComputeMipMapCount(max_texture_size, | 603 max_levels_(ComputeMipMapCount(max_texture_size, |
599 max_texture_size, | 604 max_texture_size, |
600 max_texture_size)), | 605 max_texture_size)), |
601 max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size, | 606 max_cube_map_levels_(ComputeMipMapCount(max_cube_map_texture_size, |
602 max_cube_map_texture_size, | 607 max_cube_map_texture_size, |
603 max_cube_map_texture_size)), | 608 max_cube_map_texture_size)), |
604 num_unrenderable_textures_(0), | 609 num_unrenderable_textures_(0), |
605 num_unsafe_textures_(0), | 610 num_unsafe_textures_(0), |
606 num_uncleared_mips_(0), | 611 num_uncleared_mips_(0), |
607 texture_info_count_(0), | 612 texture_info_count_(0), |
608 mem_represented_(0), | 613 mem_represented_(0), |
609 last_reported_mem_represented_(1), | |
610 have_context_(true) { | 614 have_context_(true) { |
611 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { | 615 for (int ii = 0; ii < kNumDefaultTextures; ++ii) { |
612 black_texture_ids_[ii] = 0; | 616 black_texture_ids_[ii] = 0; |
613 } | 617 } |
614 } | 618 } |
615 | 619 |
616 void TextureManager::UpdateMemRepresented() { | 620 void TextureManager::UpdateMemRepresented() { |
617 if (mem_represented_ != last_reported_mem_represented_) { | 621 texture_memory_tracker_->UpdateMemRepresented(mem_represented_); |
618 last_reported_mem_represented_ = mem_represented_; | |
619 TRACE_COUNTER_ID1( | |
620 "TextureManager", "TextureMemory", this, mem_represented_); | |
621 } | |
622 } | 622 } |
623 | 623 |
624 bool TextureManager::Initialize() { | 624 bool TextureManager::Initialize() { |
625 UpdateMemRepresented(); | 625 UpdateMemRepresented(); |
626 | 626 |
627 // TODO(gman): The default textures have to be real textures, not the 0 | 627 // TODO(gman): The default textures have to be real textures, not the 0 |
628 // texture because we simulate non shared resources on top of shared | 628 // texture because we simulate non shared resources on top of shared |
629 // resources and all contexts that share resource share the same default | 629 // resources and all contexts that share resource share the same default |
630 // texture. | 630 // texture. |
631 default_textures_[kTexture2D] = CreateDefaultAndBlackTextures( | 631 default_textures_[kTexture2D] = CreateDefaultAndBlackTextures( |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1044 | 1044 |
1045 GLsizei TextureManager::ComputeMipMapCount( | 1045 GLsizei TextureManager::ComputeMipMapCount( |
1046 GLsizei width, GLsizei height, GLsizei depth) { | 1046 GLsizei width, GLsizei height, GLsizei depth) { |
1047 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); | 1047 return 1 + base::bits::Log2Floor(std::max(std::max(width, height), depth)); |
1048 } | 1048 } |
1049 | 1049 |
1050 } // namespace gles2 | 1050 } // namespace gles2 |
1051 } // namespace gpu | 1051 } // namespace gpu |
1052 | 1052 |
1053 | 1053 |
OLD | NEW |