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 <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1287 if (image) | 1287 if (image) |
1288 image->WillModifyTexImage(); | 1288 image->WillModifyTexImage(); |
1289 } | 1289 } |
1290 | 1290 |
1291 void Texture::OnDidModifyPixels() { | 1291 void Texture::OnDidModifyPixels() { |
1292 gfx::GLImage* image = GetLevelImage(target(), 0); | 1292 gfx::GLImage* image = GetLevelImage(target(), 0); |
1293 if (image) | 1293 if (image) |
1294 image->DidModifyTexImage(); | 1294 image->DidModifyTexImage(); |
1295 } | 1295 } |
1296 | 1296 |
1297 void Texture::DumpImageMemory(base::trace_event::ProcessMemoryDump* pmd, | |
1298 MemoryTracker* memory_tracker, | |
1299 const std::string& dump_name) const { | |
ericrk
2015/08/18 07:39:52
David, I remember you mentioning that we never had
ericrk
2015/08/18 09:00:47
Per offline discussion, not changing this.
| |
1300 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) { | |
1301 const auto& level_infos = face_infos_[face_index].level_infos; | |
1302 for (uint32_t level_index = 0; level_index < level_infos.size(); | |
1303 ++level_index) { | |
1304 if (level_infos[level_index].image) { | |
1305 level_infos[level_index].image->OnMemoryDump( | |
1306 pmd, memory_tracker->ClientTracingId(), | |
1307 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), | |
1308 face_index, level_index)); | |
1309 } | |
1310 } | |
1311 } | |
1312 } | |
1313 | |
1297 TextureRef::TextureRef(TextureManager* manager, | 1314 TextureRef::TextureRef(TextureManager* manager, |
1298 GLuint client_id, | 1315 GLuint client_id, |
1299 Texture* texture) | 1316 Texture* texture) |
1300 : manager_(manager), | 1317 : manager_(manager), |
1301 texture_(texture), | 1318 texture_(texture), |
1302 client_id_(client_id), | 1319 client_id_(client_id), |
1303 num_observers_(0) { | 1320 num_observers_(0) { |
1304 DCHECK(manager_); | 1321 DCHECK(manager_); |
1305 DCHECK(texture_); | 1322 DCHECK(texture_); |
1306 texture_->AddTextureRef(this); | 1323 texture_->AddTextureRef(this); |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2054 if (default_textures_[i]) { | 2071 if (default_textures_[i]) { |
2055 DumpTextureRef(pmd, default_textures_[i].get()); | 2072 DumpTextureRef(pmd, default_textures_[i].get()); |
2056 } | 2073 } |
2057 } | 2074 } |
2058 | 2075 |
2059 return true; | 2076 return true; |
2060 } | 2077 } |
2061 | 2078 |
2062 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, | 2079 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
2063 TextureRef* ref) { | 2080 TextureRef* ref) { |
2064 // TODO(ericrk): Trace image-backed textures. crbug.com/514914 | |
2065 if (ref->texture()->HasImages()) | |
2066 return; | |
2067 | |
2068 uint32_t size = ref->texture()->estimated_size(); | 2081 uint32_t size = ref->texture()->estimated_size(); |
2069 | 2082 |
2070 // Ignore unallocated texture IDs. | 2083 // Ignore unallocated texture IDs. |
2071 if (size == 0) | 2084 if (size == 0) |
2072 return; | 2085 return; |
2073 | 2086 |
2074 std::string dump_name = | 2087 std::string dump_name = |
2075 base::StringPrintf("gl/textures/client_%d/texture_%d", | 2088 base::StringPrintf("gl/textures/client_%d/texture_%d", |
2076 memory_tracker_->ClientId(), ref->client_id()); | 2089 memory_tracker_->ClientId(), ref->client_id()); |
2090 | |
2091 if (ref->texture()->HasImages()) { | |
reveman
2015/08/18 08:32:52
refactor this as discussed
ericrk
2015/08/18 09:00:47
Done.
| |
2092 ref->texture()->DumpImageMemory(pmd, memory_tracker_, dump_name); | |
2093 return; | |
2094 } | |
2095 | |
2077 base::trace_event::MemoryAllocatorDump* dump = | 2096 base::trace_event::MemoryAllocatorDump* dump = |
2078 pmd->CreateAllocatorDump(dump_name); | 2097 pmd->CreateAllocatorDump(dump_name); |
2079 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 2098 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
2080 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 2099 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
2081 static_cast<uint64_t>(size)); | 2100 static_cast<uint64_t>(size)); |
2082 | 2101 |
2083 // Add the |client_guid| which expresses shared ownership with the client | 2102 // Add the |client_guid| which expresses shared ownership with the client |
2084 // process. | 2103 // process. |
2085 auto client_guid = gfx::GetGLTextureGUIDForTracing( | 2104 auto client_guid = gfx::GetGLTextureGUIDForTracing( |
2086 memory_tracker_->ClientTracingId(), ref->client_id()); | 2105 memory_tracker_->ClientTracingId(), ref->client_id()); |
(...skipping 12 matching lines...) Expand all Loading... | |
2099 // The link to the memory tracking |client_id| is given a higher importance | 2118 // The link to the memory tracking |client_id| is given a higher importance |
2100 // than other refs. | 2119 // than other refs. |
2101 if (ref == ref->texture()->memory_tracking_ref_) | 2120 if (ref == ref->texture()->memory_tracking_ref_) |
2102 importance = 2; | 2121 importance = 2; |
2103 | 2122 |
2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2123 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
2105 } | 2124 } |
2106 | 2125 |
2107 } // namespace gles2 | 2126 } // namespace gles2 |
2108 } // namespace gpu | 2127 } // namespace gpu |
OLD | NEW |