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 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 if (image) | 1288 if (image) |
1289 image->WillModifyTexImage(); | 1289 image->WillModifyTexImage(); |
1290 } | 1290 } |
1291 | 1291 |
1292 void Texture::OnDidModifyPixels() { | 1292 void Texture::OnDidModifyPixels() { |
1293 gfx::GLImage* image = GetLevelImage(target(), 0); | 1293 gfx::GLImage* image = GetLevelImage(target(), 0); |
1294 if (image) | 1294 if (image) |
1295 image->DidModifyTexImage(); | 1295 image->DidModifyTexImage(); |
1296 } | 1296 } |
1297 | 1297 |
| 1298 void Texture::DumpLevelMemory(base::trace_event::ProcessMemoryDump* pmd, |
| 1299 uint64_t client_tracing_id, |
| 1300 const std::string& dump_name) const { |
| 1301 for (uint32_t face_index = 0; face_index < face_infos_.size(); ++face_index) { |
| 1302 const auto& level_infos = face_infos_[face_index].level_infos; |
| 1303 for (uint32_t level_index = 0; level_index < level_infos.size(); |
| 1304 ++level_index) { |
| 1305 // Skip levels with no size. Textures will have empty levels for all |
| 1306 // potential mip levels which are not in use. |
| 1307 if (!level_infos[level_index].estimated_size) |
| 1308 continue; |
| 1309 |
| 1310 if (level_infos[level_index].image) { |
| 1311 // If a level is backed by a GLImage, ask the GLImage to dump itself. |
| 1312 level_infos[level_index].image->OnMemoryDump( |
| 1313 pmd, client_tracing_id, |
| 1314 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), |
| 1315 face_index, level_index)); |
| 1316 } else { |
| 1317 // If a level is not backed by a GLImage, create a simple dump. |
| 1318 base::trace_event::MemoryAllocatorDump* dump = pmd->CreateAllocatorDump( |
| 1319 base::StringPrintf("%s/face_%d/level_%d", dump_name.c_str(), |
| 1320 face_index, level_index)); |
| 1321 dump->AddScalar( |
| 1322 base::trace_event::MemoryAllocatorDump::kNameSize, |
| 1323 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
| 1324 static_cast<uint64_t>(level_infos[level_index].estimated_size)); |
| 1325 } |
| 1326 } |
| 1327 } |
| 1328 } |
| 1329 |
1298 TextureRef::TextureRef(TextureManager* manager, | 1330 TextureRef::TextureRef(TextureManager* manager, |
1299 GLuint client_id, | 1331 GLuint client_id, |
1300 Texture* texture) | 1332 Texture* texture) |
1301 : manager_(manager), | 1333 : manager_(manager), |
1302 texture_(texture), | 1334 texture_(texture), |
1303 client_id_(client_id), | 1335 client_id_(client_id), |
1304 num_observers_(0) { | 1336 num_observers_(0) { |
1305 DCHECK(manager_); | 1337 DCHECK(manager_); |
1306 DCHECK(texture_); | 1338 DCHECK(texture_); |
1307 texture_->AddTextureRef(this); | 1339 texture_->AddTextureRef(this); |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2055 if (default_textures_[i]) { | 2087 if (default_textures_[i]) { |
2056 DumpTextureRef(pmd, default_textures_[i].get()); | 2088 DumpTextureRef(pmd, default_textures_[i].get()); |
2057 } | 2089 } |
2058 } | 2090 } |
2059 | 2091 |
2060 return true; | 2092 return true; |
2061 } | 2093 } |
2062 | 2094 |
2063 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, | 2095 void TextureManager::DumpTextureRef(base::trace_event::ProcessMemoryDump* pmd, |
2064 TextureRef* ref) { | 2096 TextureRef* ref) { |
2065 // TODO(ericrk): Trace image-backed textures. crbug.com/514914 | |
2066 if (ref->texture()->HasImages()) | |
2067 return; | |
2068 | |
2069 uint32_t size = ref->texture()->estimated_size(); | 2097 uint32_t size = ref->texture()->estimated_size(); |
2070 | 2098 |
2071 // Ignore unallocated texture IDs. | 2099 // Ignore unallocated texture IDs. |
2072 if (size == 0) | 2100 if (size == 0) |
2073 return; | 2101 return; |
2074 | 2102 |
2075 std::string dump_name = | 2103 std::string dump_name = |
2076 base::StringPrintf("gl/textures/client_%d/texture_%d", | 2104 base::StringPrintf("gl/textures/client_%d/texture_%d", |
2077 memory_tracker_->ClientId(), ref->client_id()); | 2105 memory_tracker_->ClientId(), ref->client_id()); |
| 2106 |
2078 base::trace_event::MemoryAllocatorDump* dump = | 2107 base::trace_event::MemoryAllocatorDump* dump = |
2079 pmd->CreateAllocatorDump(dump_name); | 2108 pmd->CreateAllocatorDump(dump_name); |
2080 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, | 2109 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, |
2081 base::trace_event::MemoryAllocatorDump::kUnitsBytes, | 2110 base::trace_event::MemoryAllocatorDump::kUnitsBytes, |
2082 static_cast<uint64_t>(size)); | 2111 static_cast<uint64_t>(size)); |
2083 | 2112 |
2084 // Add the |client_guid| which expresses shared ownership with the client | 2113 // Add the |client_guid| which expresses shared ownership with the client |
2085 // process. | 2114 // process. |
2086 auto client_guid = gfx::GetGLTextureGUIDForTracing( | 2115 auto client_guid = gfx::GetGLTextureGUIDForTracing( |
2087 memory_tracker_->ClientTracingId(), ref->client_id()); | 2116 memory_tracker_->ClientTracingId(), ref->client_id()); |
2088 pmd->CreateSharedGlobalAllocatorDump(client_guid); | 2117 pmd->CreateSharedGlobalAllocatorDump(client_guid); |
2089 pmd->AddOwnershipEdge(dump->guid(), client_guid); | 2118 pmd->AddOwnershipEdge(dump->guid(), client_guid); |
2090 | 2119 |
2091 // Add a |service_guid| which expresses shared ownership between the various | 2120 // Add a |service_guid| which expresses shared ownership between the various |
2092 // |client_guid|s. | 2121 // |client_guid|s. |
2093 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and | 2122 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and |
2094 // potentially cross-share-group sharing via EGLImages. crbug.com/512534 | 2123 // potentially cross-share-group sharing via EGLImages. crbug.com/512534 |
2095 auto service_guid = | 2124 auto service_guid = |
2096 gfx::GetGLTextureGUIDForTracing(0, ref->texture()->service_id()); | 2125 gfx::GetGLTextureGUIDForTracing(0, ref->texture()->service_id()); |
2097 pmd->CreateSharedGlobalAllocatorDump(service_guid); | 2126 pmd->CreateSharedGlobalAllocatorDump(service_guid); |
2098 | 2127 |
2099 int importance = 0; // Default importance. | 2128 int importance = 0; // Default importance. |
2100 // The link to the memory tracking |client_id| is given a higher importance | 2129 // The link to the memory tracking |client_id| is given a higher importance |
2101 // than other refs. | 2130 // than other refs. |
2102 if (ref == ref->texture()->memory_tracking_ref_) | 2131 if (ref == ref->texture()->memory_tracking_ref_) |
2103 importance = 2; | 2132 importance = 2; |
2104 | 2133 |
2105 pmd->AddOwnershipEdge(client_guid, service_guid, importance); | 2134 pmd->AddOwnershipEdge(client_guid, service_guid, importance); |
| 2135 |
| 2136 // Dump all sub-levels held by the texture. They will appear below the main |
| 2137 // gl/textures/client_X/texture_Y dump. |
| 2138 ref->texture()->DumpLevelMemory(pmd, memory_tracker_->ClientTracingId(), |
| 2139 dump_name); |
2106 } | 2140 } |
2107 | 2141 |
2108 } // namespace gles2 | 2142 } // namespace gles2 |
2109 } // namespace gpu | 2143 } // namespace gpu |
OLD | NEW |