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

Side by Side Diff: content/browser/gpu/browser_gpu_memory_buffer_manager.cc

Issue 1256613002: Add tracing for GL texture objects (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@browser_process_id
Patch Set: Key texture manager memory dump provider registration off of memory_tracker_ 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/gpu/browser_gpu_memory_buffer_manager.h" 5 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 ~AllocateGpuMemoryBufferRequest() {} 140 ~AllocateGpuMemoryBufferRequest() {}
141 base::WaitableEvent event; 141 base::WaitableEvent event;
142 gfx::Size size; 142 gfx::Size size;
143 gfx::BufferFormat format; 143 gfx::BufferFormat format;
144 gfx::BufferUsage usage; 144 gfx::BufferUsage usage;
145 int client_id; 145 int client_id;
146 int surface_id; 146 int surface_id;
147 scoped_ptr<gfx::GpuMemoryBuffer> result; 147 scoped_ptr<gfx::GpuMemoryBuffer> result;
148 }; 148 };
149 149
150 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(int gpu_client_id) 150 BrowserGpuMemoryBufferManager::BrowserGpuMemoryBufferManager(
151 int gpu_client_id,
152 uint64_t gpu_client_tracing_id)
151 : factory_type_(GetGpuMemoryBufferFactoryType()), 153 : factory_type_(GetGpuMemoryBufferFactoryType()),
152 supported_configurations_( 154 supported_configurations_(
153 GetSupportedGpuMemoryBufferConfigurations(factory_type_)), 155 GetSupportedGpuMemoryBufferConfigurations(factory_type_)),
154 gpu_client_id_(gpu_client_id), 156 gpu_client_id_(gpu_client_id),
157 gpu_client_tracing_id_(gpu_client_tracing_id),
155 gpu_host_id_(0) { 158 gpu_host_id_(0) {
156 DCHECK(!g_gpu_memory_buffer_manager); 159 DCHECK(!g_gpu_memory_buffer_manager);
157 g_gpu_memory_buffer_manager = this; 160 g_gpu_memory_buffer_manager = this;
158 } 161 }
159 162
160 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() { 163 BrowserGpuMemoryBufferManager::~BrowserGpuMemoryBufferManager() {
161 g_gpu_memory_buffer_manager = nullptr; 164 g_gpu_memory_buffer_manager = nullptr;
162 } 165 }
163 166
164 // static 167 // static
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 DCHECK(valid_size); 288 DCHECK(valid_size);
286 289
287 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize, 290 dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
288 base::trace_event::MemoryAllocatorDump::kUnitsBytes, 291 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
289 buffer_size_in_bytes); 292 buffer_size_in_bytes);
290 293
291 // Create the cross-process ownership edge. If the client creates a 294 // Create the cross-process ownership edge. If the client creates a
292 // corresponding dump for the same buffer, this will avoid to 295 // corresponding dump for the same buffer, this will avoid to
293 // double-count them in tracing. If, instead, no other process will emit a 296 // double-count them in tracing. If, instead, no other process will emit a
294 // dump with the same guid, the segment will be accounted to the browser. 297 // dump with the same guid, the segment will be accounted to the browser.
295 const uint64 client_tracing_process_id = 298 uint64 client_tracing_process_id = ClientIdToTracingProcessId(client_id);
296 ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId( 299
297 client_id);
298 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid = 300 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid =
299 gfx::GetGpuMemoryBufferGUIDForTracing(client_tracing_process_id, 301 gfx::GetGpuMemoryBufferGUIDForTracing(client_tracing_process_id,
300 buffer_id); 302 buffer_id);
301 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); 303 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
302 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid); 304 pmd->AddOwnershipEdge(dump->guid(), shared_buffer_guid);
303 } 305 }
304 } 306 }
305 307
306 return true; 308 return true;
307 } 309 }
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return; 584 return;
583 } 585 }
584 586
585 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id); 587 GpuProcessHost* host = GpuProcessHost::FromID(buffer_it->second.gpu_host_id);
586 if (host) 588 if (host)
587 host->DestroyGpuMemoryBuffer(id, client_id, sync_point); 589 host->DestroyGpuMemoryBuffer(id, client_id, sync_point);
588 590
589 buffers.erase(buffer_it); 591 buffers.erase(buffer_it);
590 } 592 }
591 593
594 uint64_t BrowserGpuMemoryBufferManager::ClientIdToTracingProcessId(
595 int client_id) const {
596 if (client_id == gpu_client_id_) {
597 // The gpu_client uses a fixed tracing ID.
598 return gpu_client_tracing_id_;
599 }
600
601 // In normal cases, |client_id| is a child process id, so we can perform
602 // the standard conversion.
603 return ChildProcessHostImpl::ChildProcessUniqueIdToTracingProcessId(
604 client_id);
605 }
606
592 } // namespace content 607 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698