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