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