Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(517)

Side by Side Diff: gpu/command_buffer/service/texture_manager.cc

Issue 1299713003: GLImage::OnMemoryDump Stubs + Some Impls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@images1.3
Patch Set: review feedback Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | ui/gfx/generic_shared_memory_id.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 uint64_t client_tracing_id,
1299 const std::string& dump_name) const {
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) {
reveman 2015/08/18 09:05:57 should we dump the memory used by each level in th
ericrk 2015/08/18 10:03:52 Dumping these, unless they are size 0. Images appe
1305 level_infos[level_index].image->OnMemoryDump(
1306 pmd, client_tracing_id,
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
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
2077 base::trace_event::MemoryAllocatorDump* dump = 2091 base::trace_event::MemoryAllocatorDump* dump =
2078 pmd->CreateAllocatorDump(dump_name); 2092 pmd->CreateAllocatorDump(dump_name);
2079 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 2093 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
2080 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 2094 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
2081 static_cast<uint64_t>(size)); 2095 static_cast<uint64_t>(size));
2082 2096
2083 // Add the |client_guid| which expresses shared ownership with the client 2097 // Add the |client_guid| which expresses shared ownership with the client
2084 // process. 2098 // process.
2085 auto client_guid = gfx::GetGLTextureGUIDForTracing( 2099 auto client_guid = gfx::GetGLTextureGUIDForTracing(
2086 memory_tracker_->ClientTracingId(), ref->client_id()); 2100 memory_tracker_->ClientTracingId(), ref->client_id());
2087 pmd->CreateSharedGlobalAllocatorDump(client_guid); 2101 pmd->CreateSharedGlobalAllocatorDump(client_guid);
2088 pmd->AddOwnershipEdge(dump->guid(), client_guid); 2102 pmd->AddOwnershipEdge(dump->guid(), client_guid);
2089 2103
2090 // Add a |service_guid| which expresses shared ownership between the various 2104 // Add a |service_guid| which expresses shared ownership between the various
2091 // |client_guid|s. 2105 // |client_guid|s.
2092 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and 2106 // TODO(ericrk): May need to ensure uniqueness using GLShareGroup and
2093 // potentially cross-share-group sharing via EGLImages. crbug.com/512534 2107 // potentially cross-share-group sharing via EGLImages. crbug.com/512534
2094 auto service_guid = 2108 auto service_guid =
2095 gfx::GetGLTextureGUIDForTracing(0, ref->texture()->service_id()); 2109 gfx::GetGLTextureGUIDForTracing(0, ref->texture()->service_id());
2096 pmd->CreateSharedGlobalAllocatorDump(service_guid); 2110 pmd->CreateSharedGlobalAllocatorDump(service_guid);
2097 2111
2098 int importance = 0; // Default importance. 2112 int importance = 0; // Default importance.
2099 // The link to the memory tracking |client_id| is given a higher importance 2113 // The link to the memory tracking |client_id| is given a higher importance
2100 // than other refs. 2114 // than other refs.
2101 if (ref == ref->texture()->memory_tracking_ref_) 2115 if (ref == ref->texture()->memory_tracking_ref_)
2102 importance = 2; 2116 importance = 2;
2103 2117
2104 pmd->AddOwnershipEdge(client_guid, service_guid, importance); 2118 pmd->AddOwnershipEdge(client_guid, service_guid, importance);
2119
2120 // If a texture has images, dump them now. They will appear below the main
2121 // gl/textures/client_X/texture_Y dump.
2122 if (ref->texture()->HasImages()) {
reveman 2015/08/18 09:05:57 is this "if" statement needed?
ericrk 2015/08/18 10:03:52 I guess not. Especially now that we are dumping mo
2123 ref->texture()->DumpImageMemory(pmd, memory_tracker_->ClientTracingId(),
2124 dump_name);
2125 }
2105 } 2126 }
2106 2127
2107 } // namespace gles2 2128 } // namespace gles2
2108 } // namespace gpu 2129 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | ui/gfx/generic_shared_memory_id.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698