| 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 15 matching lines...) Expand all Loading... |
| 26 #include "gpu/command_buffer/service/gl_stream_texture_image.h" | 26 #include "gpu/command_buffer/service/gl_stream_texture_image.h" |
| 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 "ui/gl/gl_context.h" | 30 #include "ui/gl/gl_context.h" |
| 31 #include "ui/gl/gl_implementation.h" | 31 #include "ui/gl/gl_implementation.h" |
| 32 #include "ui/gl/gl_state_restorer.h" | 32 #include "ui/gl/gl_state_restorer.h" |
| 33 #include "ui/gl/gl_version_info.h" | 33 #include "ui/gl/gl_version_info.h" |
| 34 #include "ui/gl/trace_util.h" | 34 #include "ui/gl/trace_util.h" |
| 35 | 35 |
| 36 using base::trace_event::MemoryAllocatorDump; |
| 37 using base::trace_event::MemoryDumpLevelOfDetail; |
| 38 |
| 36 namespace gpu { | 39 namespace gpu { |
| 37 namespace gles2 { | 40 namespace gles2 { |
| 38 | 41 |
| 39 namespace { | 42 namespace { |
| 40 | 43 |
| 41 // This should contain everything to uniquely identify a Texture. | 44 // This should contain everything to uniquely identify a Texture. |
| 42 const char TextureTag[] = "|Texture|"; | 45 const char TextureTag[] = "|Texture|"; |
| 43 struct TextureSignature { | 46 struct TextureSignature { |
| 44 GLenum target_; | 47 GLenum target_; |
| 45 GLint level_; | 48 GLint level_; |
| (...skipping 1620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1666 level_infos[level_index].image->OnMemoryDump( | 1669 level_infos[level_index].image->OnMemoryDump( |
| 1667 pmd, client_tracing_id, | 1670 pmd, client_tracing_id, |
| 1668 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), | 1671 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), |
| 1669 face_index, level_index)); | 1672 face_index, level_index)); |
| 1670 } | 1673 } |
| 1671 | 1674 |
| 1672 // If a level does not have a GLImage bound to it, then dump the | 1675 // If a level does not have a GLImage bound to it, then dump the |
| 1673 // texture allocation also as the storage is not provided by the | 1676 // texture allocation also as the storage is not provided by the |
| 1674 // GLImage in that case. | 1677 // GLImage in that case. |
| 1675 if (level_infos[level_index].image_state != BOUND) { | 1678 if (level_infos[level_index].image_state != BOUND) { |
| 1676 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( | 1679 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(base::StringPrintf( |
| 1677 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), | 1680 "%s/face_%d/level_%d", dump_name.c_str(), face_index, level_index)); |
| 1678 face_index, level_index)); | |
| 1679 dump->AddScalar( | 1681 dump->AddScalar( |
| 1680 base::trace_event::MemoryAllocatorDump::kNameSize, | 1682 MemoryAllocatorDump::kNameSize, MemoryAllocatorDump::kUnitsBytes, |
| 1681 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 1682 static_cast<uint64_t>(level_infos[level_index].estimated_size)); | 1683 static_cast<uint64_t>(level_infos[level_index].estimated_size)); |
| 1683 } | 1684 } |
| 1684 } | 1685 } |
| 1685 } | 1686 } |
| 1686 } | 1687 } |
| 1687 | 1688 |
| 1688 bool Texture::CanRenderTo(const FeatureInfo* feature_info, GLint level) const { | 1689 bool Texture::CanRenderTo(const FeatureInfo* feature_info, GLint level) const { |
| 1689 if (target_ == GL_TEXTURE_EXTERNAL_OES || target_ == 0) | 1690 if (target_ == GL_TEXTURE_EXTERNAL_OES || target_ == 0) |
| 1690 return false; | 1691 return false; |
| 1691 DCHECK_LT(0u, face_infos_.size()); | 1692 DCHECK_LT(0u, face_infos_.size()); |
| (...skipping 1422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3114 } | 3115 } |
| 3115 | 3116 |
| 3116 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { | 3117 ScopedTextureUploadTimer::~ScopedTextureUploadTimer() { |
| 3117 texture_state_->texture_upload_count++; | 3118 texture_state_->texture_upload_count++; |
| 3118 texture_state_->total_texture_upload_time += | 3119 texture_state_->total_texture_upload_time += |
| 3119 base::TimeTicks::Now() - begin_time_; | 3120 base::TimeTicks::Now() - begin_time_; |
| 3120 } | 3121 } |
| 3121 | 3122 |
| 3122 bool TextureManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 3123 bool TextureManager::OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| 3123 base::trace_event::ProcessMemoryDump* pmd) { | 3124 base::trace_event::ProcessMemoryDump* pmd) { |
| 3124 for (const auto& resource : textures_) { | 3125 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { |
| 3125 // Only dump memory info for textures actually owned by this TextureManager. | 3126 std::string dump_name = |
| 3126 DumpTextureRef(pmd, resource.second.get()); | 3127 base::StringPrintf("gpu/gl/textures/share_group_%" PRIu64 "", |
| 3127 } | 3128 memory_tracker_->ShareGroupTracingGUID()); |
| 3129 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); |
| 3130 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 3131 MemoryAllocatorDump::kUnitsBytes, mem_represented()); |
| 3132 } else { |
| 3133 for (const auto& resource : textures_) { |
| 3134 // Only dump memory info for textures actually owned by this |
| 3135 // TextureManager. |
| 3136 DumpTextureRef(pmd, resource.second.get()); |
| 3137 } |
| 3128 | 3138 |
| 3129 // Also dump TextureManager internal textures, if allocated. | 3139 // Also dump TextureManager internal textures, if allocated. |
| 3130 for (int i = 0; i < kNumDefaultTextures; i++) { | 3140 for (int i = 0; i < kNumDefaultTextures; i++) { |
| 3131 if (default_textures_[i]) { | 3141 if (default_textures_[i]) { |
| 3132 DumpTextureRef(pmd, default_textures_[i].get()); | 3142 DumpTextureRef(pmd, default_textures_[i].get()); |
| 3143 } |
| 3133 } | 3144 } |
| 3134 } | 3145 } |
| 3135 | 3146 |
| 3136 return true; | 3147 return true; |
| 3137 } | 3148 } |
| 3138 | 3149 |
| 3139 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, | 3150 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
| 3140 TextureRef* ref) { | 3151 TextureRef* ref) { |
| 3141 uint32_t size = ref->texture()->estimated_size(); | 3152 uint32_t size = ref->texture()->estimated_size(); |
| 3142 | 3153 |
| 3143 // Ignore unallocated texture IDs. | 3154 // Ignore unallocated texture IDs. |
| 3144 if (size == 0) | 3155 if (size == 0) |
| 3145 return; | 3156 return; |
| 3146 | 3157 |
| 3147 std::string dump_name = base::StringPrintf( | 3158 std::string dump_name = base::StringPrintf( |
| 3148 "gpu/gl/textures/share_group_%" PRIu64 "/texture_%d", | 3159 "gpu/gl/textures/share_group_%" PRIu64 "/texture_%d", |
| 3149 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); | 3160 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); |
| 3150 | 3161 |
| 3151 base::trace_event::MemoryAllocatorDump* dump = | 3162 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); |
| 3152 pmd->CreateAllocatorDump(dump_name); | 3163 dump->AddScalar(MemoryAllocatorDump::kNameSize, |
| 3153 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 3164 MemoryAllocatorDump::kUnitsBytes, |
| 3154 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | |
| 3155 static_cast<uint64_t>(size)); | 3165 static_cast<uint64_t>(size)); |
| 3156 | 3166 |
| 3157 // Add the |client_guid| which expresses shared ownership with the client | 3167 // Add the |client_guid| which expresses shared ownership with the client |
| 3158 // process. | 3168 // process. |
| 3159 auto client_guid = gl::GetGLTextureClientGUIDForTracing( | 3169 auto client_guid = gl::GetGLTextureClientGUIDForTracing( |
| 3160 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); | 3170 memory_tracker_->ShareGroupTracingGUID(), ref->client_id()); |
| 3161 pmd->CreateSharedGlobalAllocatorDump(client_guid); | 3171 pmd->CreateSharedGlobalAllocatorDump(client_guid); |
| 3162 pmd->AddOwnershipEdge(dump->guid(), client_guid); | 3172 pmd->AddOwnershipEdge(dump->guid(), client_guid); |
| 3163 | 3173 |
| 3164 // 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... |
| 3467 uint32_t TextureManager::GetServiceIdGeneration() const { | 3477 uint32_t TextureManager::GetServiceIdGeneration() const { |
| 3468 return current_service_id_generation_; | 3478 return current_service_id_generation_; |
| 3469 } | 3479 } |
| 3470 | 3480 |
| 3471 void TextureManager::IncrementServiceIdGeneration() { | 3481 void TextureManager::IncrementServiceIdGeneration() { |
| 3472 current_service_id_generation_++; | 3482 current_service_id_generation_++; |
| 3473 } | 3483 } |
| 3474 | 3484 |
| 3475 } // namespace gles2 | 3485 } // namespace gles2 |
| 3476 } // namespace gpu | 3486 } // namespace gpu |
| OLD | NEW |