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 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 27 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
28 #include "gpu/command_buffer/service/mailbox_manager.h" | 28 #include "gpu/command_buffer/service/mailbox_manager.h" |
29 #include "gpu/command_buffer/service/memory_tracking.h" | 29 #include "gpu/command_buffer/service/memory_tracking.h" |
30 #include "gpu/command_buffer/service/progress_reporter.h" | 30 #include "gpu/command_buffer/service/progress_reporter.h" |
31 #include "ui/gl/gl_context.h" | 31 #include "ui/gl/gl_context.h" |
32 #include "ui/gl/gl_implementation.h" | 32 #include "ui/gl/gl_implementation.h" |
33 #include "ui/gl/gl_state_restorer.h" | 33 #include "ui/gl/gl_state_restorer.h" |
34 #include "ui/gl/gl_version_info.h" | 34 #include "ui/gl/gl_version_info.h" |
35 #include "ui/gl/trace_util.h" | 35 #include "ui/gl/trace_util.h" |
36 | 36 |
37 using base::trace_event::MemoryAllocatorDump; | |
38 using base::trace_event::MemoryDumpLevelOfDetail; | |
39 | |
40 namespace gpu { | 37 namespace gpu { |
41 namespace gles2 { | 38 namespace gles2 { |
42 | 39 |
43 namespace { | 40 namespace { |
44 | 41 |
45 // This should contain everything to uniquely identify a Texture. | 42 // This should contain everything to uniquely identify a Texture. |
46 const char TextureTag[] = "|Texture|"; | 43 const char TextureTag[] = "|Texture|"; |
47 struct TextureSignature { | 44 struct TextureSignature { |
48 GLenum target_; | 45 GLenum target_; |
49 GLint level_; | 46 GLint level_; |
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 level_infos[level_index].image->OnMemoryDump( | 1674 level_infos[level_index].image->OnMemoryDump( |
1678 pmd, client_tracing_id, | 1675 pmd, client_tracing_id, |
1679 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), | 1676 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), |
1680 face_index, level_index)); | 1677 face_index, level_index)); |
1681 } | 1678 } |
1682 | 1679 |
1683 // If a level does not have a GLImage bound to it, then dump the | 1680 // If a level does not have a GLImage bound to it, then dump the |
1684 // texture allocation also as the storage is not provided by the | 1681 // texture allocation also as the storage is not provided by the |
1685 // GLImage in that case. | 1682 // GLImage in that case. |
1686 if (level_infos[level_index].image_state != BOUND) { | 1683 if (level_infos[level_index].image_state != BOUND) { |
1687 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( | 1684 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( |
1688 "%s/face_%d/level_%d", dump_name.c_str(), face_index, level_index)); | 1685 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), |
| 1686 face_index, level_index)); |
1689 dump->AddScalar( | 1687 dump->AddScalar( |
1690 MemoryAllocatorDump::kNameSize, MemoryAllocatorDump::kUnitsBytes, | 1688 base::trace_event::MemoryAllocatorDump::kNameSize, |
| 1689 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
1691 static_cast<uint64_t>(level_infos[level_index].estimated_size)); | 1690 static_cast<uint64_t>(level_infos[level_index].estimated_size)); |
1692 } | 1691 } |
1693 } | 1692 } |
1694 } | 1693 } |
1695 } | 1694 } |
1696 | 1695 |
1697 bool Texture::CanRenderTo(const FeatureInfo* feature_info, GLint level) const { | 1696 bool Texture::CanRenderTo(const FeatureInfo* feature_info, GLint level) const { |
1698 if (target_ == GL_TEXTURE_EXTERNAL_OES || target_ == 0) | 1697 if (target_ == GL_TEXTURE_EXTERNAL_OES || target_ == 0) |
1699 return false; | 1698 return false; |
1700 DCHECK_LT(0u, face_infos_.size()); | 1699 DCHECK_LT(0u, face_infos_.size()); |
(...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3125 } | 3124 } |
3126 | 3125 |
3127 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 3126 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
3128 texture_state_->texture_upload_count++; | 3127 texture_state_->texture_upload_count++; |
3129 texture_state_->total_texture_upload_time += | 3128 texture_state_->total_texture_upload_time += |
3130 base::TimeTicks::Now() - begin_time_; | 3129 base::TimeTicks::Now() - begin_time_; |
3131 } | 3130 } |
3132 | 3131 |
3133 bool TextureManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 3132 bool TextureManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
3134 base::trace_event::ProcessMemoryDump* pmd) { | 3133 base::trace_event::ProcessMemoryDump* pmd) { |
3135 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { | |
3136 std::string dump_name = | |
3137 base::StringPrintf("gpu/gl/textures/share_group_%" PRIu64 "", | |
3138 memory_tracker_->ShareGroupTracingGUID()); | |
3139 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); | |
3140 dump->AddScalar(MemoryAllocatorDump::kNameSize, | |
3141 MemoryAllocatorDump::kUnitsBytes, mem_represented()); | |
3142 | |
3143 // Early out, no need for more detail in a BACKGROUND dump. | |
3144 return true; | |
3145 } | |
3146 | |
3147 for (const auto& resource : textures_) { | 3134 for (const auto& resource : textures_) { |
3148 // Only dump memory info for textures actually owned by this | 3135 // Only dump memory info for textures actually owned by this TextureManager. |
3149 // TextureManager. | |
3150 DumpTextureRef(pmd, resource.second.get()); | 3136 DumpTextureRef(pmd, resource.second.get()); |
3151 } | 3137 } |
3152 | 3138 |
3153 // Also dump TextureManager internal textures, if allocated. | 3139 // Also dump TextureManager internal textures, if allocated. |
3154 for (int i = 0; i < kNumDefaultTextures; i++) { | 3140 for (int i = 0; i < kNumDefaultTextures; i++) { |
3155 if (default_textures_[i]) { | 3141 if (default_textures_[i]) { |
3156 DumpTextureRef(pmd, default_textures_[i].get()); | 3142 DumpTextureRef(pmd, default_textures_[i].get()); |
3157 } | 3143 } |
3158 } | 3144 } |
3159 | 3145 |
3160 return true; | 3146 return true; |
3161 } | 3147 } |
3162 | 3148 |
3163 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, | 3149 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
3164 TextureRef* ref) { | 3150 TextureRef* ref) { |
3165 uint32_t size = ref->texture()->estimated_size(); | 3151 uint32_t size = ref->texture()->estimated_size(); |
3166 | 3152 |
3167 // Ignore unallocated texture IDs. | 3153 // Ignore unallocated texture IDs. |
3168 if (size == 0) | 3154 if (size == 0) |
3169 return; | 3155 return; |
3170 | 3156 |
3171 std::string dump_name = base::StringPrintf( | 3157 std::string dump_name = base::StringPrintf( |
3172 "gpu/gl/textures/share_group_%" PRIu64 "/texture_%d", | 3158 "gpu/gl/textures/share_group_%" PRIu64 "/texture_%d", |
3173 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); | 3159 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); |
3174 | 3160 |
3175 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); | 3161 base::trace_event::MemoryAllocatorDump* dump = |
3176 dump->AddScalar(MemoryAllocatorDump::kNameSize, | 3162 pmd->CreateAllocatorDump(dump_name); |
3177 MemoryAllocatorDump::kUnitsBytes, | 3163 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
| 3164 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
3178 static_cast<uint64_t>(size)); | 3165 static_cast<uint64_t>(size)); |
3179 | 3166 |
3180 // Add the |client_guid| which expresses shared ownership with the client | 3167 // Add the |client_guid| which expresses shared ownership with the client |
3181 // process. | 3168 // process. |
3182 auto client_guid = gl::GetGLTextureClientGUIDForTracing( | 3169 auto client_guid = gl::GetGLTextureClientGUIDForTracing( |
3183 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); | 3170 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); |
3184 pmd->CreateSharedGlobalAllocatorDump(client_guid); | 3171 pmd->CreateSharedGlobalAllocatorDump(client_guid); |
3185 pmd->AddOwnershipEdge(dump->guid(), client_guid); | 3172 pmd->AddOwnershipEdge(dump->guid(), client_guid); |
3186 | 3173 |
3187 // Add a |service_guid| which expresses shared ownership between the various | 3174 // Add a |service_guid| which expresses shared ownership between the various |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3490 uint32_t TextureManager::GetServiceIdGeneration() const { | 3477 uint32_t TextureManager::GetServiceIdGeneration() const { |
3491 return current_service_id_generation_; | 3478 return current_service_id_generation_; |
3492 } | 3479 } |
3493 | 3480 |
3494 void TextureManager::IncrementServiceIdGeneration() { | 3481 void TextureManager::IncrementServiceIdGeneration() { |
3495 current_service_id_generation_++; | 3482 current_service_id_generation_++; |
3496 } | 3483 } |
3497 | 3484 |
3498 } // namespace gles2 | 3485 } // namespace gles2 |
3499 } // namespace gpu | 3486 } // namespace gpu |
OLD | NEW |