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

Side by Side Diff: cc/raster/staging_buffer_pool.cc

Issue 2467973004: Revert of Add BACKGROUND dump mode to various GPU/CC MemoryDumpProviders (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | cc/resources/resource_pool.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "cc/raster/staging_buffer_pool.h" 5 #include "cc/raster/staging_buffer_pool.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/memory/memory_coordinator_client_registry.h" 9 #include "base/memory/memory_coordinator_client_registry.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "base/trace_event/memory_dump_manager.h" 13 #include "base/trace_event/memory_dump_manager.h"
14 #include "cc/base/container_util.h" 14 #include "cc/base/container_util.h"
15 #include "cc/debug/traced_value.h" 15 #include "cc/debug/traced_value.h"
16 #include "cc/resources/scoped_resource.h" 16 #include "cc/resources/scoped_resource.h"
17 #include "gpu/command_buffer/client/gles2_interface.h" 17 #include "gpu/command_buffer/client/gles2_interface.h"
18 #include "ui/gfx/gpu_memory_buffer_tracing.h" 18 #include "ui/gfx/gpu_memory_buffer_tracing.h"
19 19
20 using base::trace_event::MemoryAllocatorDump;
21 using base::trace_event::MemoryAllocatorDumpGuid;
22 using base::trace_event::MemoryDumpLevelOfDetail;
23
24 namespace cc { 20 namespace cc {
25 namespace { 21 namespace {
26 22
27 // Delay between checking for query result to be available. 23 // Delay between checking for query result to be available.
28 const int kCheckForQueryResultAvailableTickRateMs = 1; 24 const int kCheckForQueryResultAvailableTickRateMs = 1;
29 25
30 // Number of attempts to allow before we perform a check that will wait for 26 // Number of attempts to allow before we perform a check that will wait for
31 // query to complete. 27 // query to complete.
32 const int kMaxCheckForQueryResultAvailableAttempts = 256; 28 const int kMaxCheckForQueryResultAvailableAttempts = 256;
33 29
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 89
94 void StagingBuffer::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, 90 void StagingBuffer::OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
95 ResourceFormat format, 91 ResourceFormat format,
96 bool in_free_list) const { 92 bool in_free_list) const {
97 if (!gpu_memory_buffer) 93 if (!gpu_memory_buffer)
98 return; 94 return;
99 95
100 gfx::GpuMemoryBufferId buffer_id = gpu_memory_buffer->GetId(); 96 gfx::GpuMemoryBufferId buffer_id = gpu_memory_buffer->GetId();
101 std::string buffer_dump_name = 97 std::string buffer_dump_name =
102 base::StringPrintf("cc/one_copy/staging_memory/buffer_%d", buffer_id.id); 98 base::StringPrintf("cc/one_copy/staging_memory/buffer_%d", buffer_id.id);
103 MemoryAllocatorDump* buffer_dump = pmd->CreateAllocatorDump(buffer_dump_name); 99 base::trace_event::MemoryAllocatorDump* buffer_dump =
100 pmd->CreateAllocatorDump(buffer_dump_name);
104 101
105 uint64_t buffer_size_in_bytes = 102 uint64_t buffer_size_in_bytes =
106 ResourceUtil::UncheckedSizeInBytes<uint64_t>(size, format); 103 ResourceUtil::UncheckedSizeInBytes<uint64_t>(size, format);
107 buffer_dump->AddScalar(MemoryAllocatorDump::kNameSize, 104 buffer_dump->AddScalar(base::trace_event::MemoryAllocatorDump::kNameSize,
108 MemoryAllocatorDump::kUnitsBytes, 105 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
109 buffer_size_in_bytes); 106 buffer_size_in_bytes);
110 buffer_dump->AddScalar("free_size", MemoryAllocatorDump::kUnitsBytes, 107 buffer_dump->AddScalar("free_size",
108 base::trace_event::MemoryAllocatorDump::kUnitsBytes,
111 in_free_list ? buffer_size_in_bytes : 0); 109 in_free_list ? buffer_size_in_bytes : 0);
112 110
113 // Emit an ownership edge towards a global allocator dump node. 111 // Emit an ownership edge towards a global allocator dump node.
114 const uint64_t tracing_process_id = 112 const uint64_t tracing_process_id =
115 base::trace_event::MemoryDumpManager::GetInstance() 113 base::trace_event::MemoryDumpManager::GetInstance()
116 ->GetTracingProcessId(); 114 ->GetTracingProcessId();
117 MemoryAllocatorDumpGuid shared_buffer_guid = 115 base::trace_event::MemoryAllocatorDumpGuid shared_buffer_guid =
118 gfx::GetGpuMemoryBufferGUIDForTracing(tracing_process_id, buffer_id); 116 gfx::GetGpuMemoryBufferGUIDForTracing(tracing_process_id, buffer_id);
119 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid); 117 pmd->CreateSharedGlobalAllocatorDump(shared_buffer_guid);
120 118
121 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps) 119 // By creating an edge with a higher |importance| (w.r.t. browser-side dumps)
122 // the tracing UI will account the effective size of the buffer to the child. 120 // the tracing UI will account the effective size of the buffer to the child.
123 const int kImportance = 2; 121 const int kImportance = 2;
124 pmd->AddOwnershipEdge(buffer_dump->guid(), shared_buffer_guid, kImportance); 122 pmd->AddOwnershipEdge(buffer_dump->guid(), shared_buffer_guid, kImportance);
125 } 123 }
126 124
127 StagingBufferPool::StagingBufferPool(base::SequencedTaskRunner* task_runner, 125 StagingBufferPool::StagingBufferPool(base::SequencedTaskRunner* task_runner,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 busy_buffers_.push_back(std::move(staging_buffer)); 180 busy_buffers_.push_back(std::move(staging_buffer));
183 181
184 ScheduleReduceMemoryUsage(); 182 ScheduleReduceMemoryUsage();
185 } 183 }
186 184
187 bool StagingBufferPool::OnMemoryDump( 185 bool StagingBufferPool::OnMemoryDump(
188 const base::trace_event::MemoryDumpArgs& args, 186 const base::trace_event::MemoryDumpArgs& args,
189 base::trace_event::ProcessMemoryDump* pmd) { 187 base::trace_event::ProcessMemoryDump* pmd) {
190 base::AutoLock lock(lock_); 188 base::AutoLock lock(lock_);
191 189
192 if (args.level_of_detail == MemoryDumpLevelOfDetail::BACKGROUND) { 190 for (const auto* buffer : buffers_) {
193 std::string dump_name("cc/one_copy/staging_memory"); 191 auto in_free_buffers =
194 MemoryAllocatorDump* dump = pmd->CreateAllocatorDump(dump_name); 192 std::find_if(free_buffers_.begin(), free_buffers_.end(),
195 dump->AddScalar(MemoryAllocatorDump::kNameSize, 193 [buffer](const std::unique_ptr<StagingBuffer>& b) {
196 MemoryAllocatorDump::kUnitsBytes, 194 return b.get() == buffer;
197 staging_buffer_usage_in_bytes_); 195 });
198 } else { 196 buffer->OnMemoryDump(pmd, buffer->format,
199 for (const auto* buffer : buffers_) { 197 in_free_buffers != free_buffers_.end());
200 auto in_free_buffers =
201 std::find_if(free_buffers_.begin(), free_buffers_.end(),
202 [buffer](const std::unique_ptr<StagingBuffer>& b) {
203 return b.get() == buffer;
204 });
205 buffer->OnMemoryDump(pmd, buffer->format,
206 in_free_buffers != free_buffers_.end());
207 }
208 } 198 }
199
209 return true; 200 return true;
210 } 201 }
211 202
212 void StagingBufferPool::AddStagingBuffer(const StagingBuffer* staging_buffer, 203 void StagingBufferPool::AddStagingBuffer(const StagingBuffer* staging_buffer,
213 ResourceFormat format) { 204 ResourceFormat format) {
214 lock_.AssertAcquired(); 205 lock_.AssertAcquired();
215 206
216 DCHECK(buffers_.find(staging_buffer) == buffers_.end()); 207 DCHECK(buffers_.find(staging_buffer) == buffers_.end());
217 buffers_.insert(staging_buffer); 208 buffers_.insert(staging_buffer);
218 int buffer_usage_in_bytes = 209 int buffer_usage_in_bytes =
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // Release all buffers, regardless of how recently they were used. 437 // Release all buffers, regardless of how recently they were used.
447 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max()); 438 ReleaseBuffersNotUsedSince(base::TimeTicks() + base::TimeDelta::Max());
448 } break; 439 } break;
449 case base::MemoryState::UNKNOWN: 440 case base::MemoryState::UNKNOWN:
450 // NOT_REACHED. 441 // NOT_REACHED.
451 break; 442 break;
452 } 443 }
453 } 444 }
454 445
455 } // namespace cc 446 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | cc/resources/resource_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698